MCPcopy Create free account
hub / github.com/KDE/kdevelop / runSelectedTests

Method runSelectedTests

plugins/testview/testview.cpp:232–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230
231
232void TestView::runSelectedTests()
233{
234 QModelIndexList indexes = m_tree->selectionModel()->selectedIndexes();
235 if (indexes.isEmpty())
236 {
237 //if there's no selection we'll run all of them (or only the filtered)
238 //in case there's a filter.
239 const int rc = m_filter->rowCount();
240 indexes.reserve(rc);
241 for(int i=0; i<rc; ++i) {
242 indexes << m_filter->index(i, 0);
243 }
244 }
245
246 QList<KJob*> jobs;
247 ITestController* tc = ICore::self()->testController();
248
249 /*
250 * NOTE: If a test suite or a single test case was selected,
251 * the job is launched in Verbose mode with raised output window.
252 * If a project is selected, it is launched silently.
253 *
254 * This is the somewhat-intuitive approach. Maybe a configuration should be offered.
255 */
256
257 for (const QModelIndex& idx : std::as_const(indexes)) {
258 QModelIndex index = m_filter->mapToSource(idx);
259 if (index.parent().isValid() && indexes.contains(index.parent()))
260 {
261 continue;
262 }
263 QStandardItem* item = m_model->itemFromIndex(index);
264 if (item->parent() == nullptr)
265 {
266 // A project was selected
267 IProject* project = ICore::self()->projectController()->findProjectByName(item->data(ProjectRole).toString());
268 const auto suites = tc->testSuitesForProject(project);
269 for (ITestSuite* suite : suites) {
270 jobs << suite->launchAllCases(ITestSuite::Silent);
271 }
272 }
273 else if (item->parent()->parent() == nullptr)
274 {
275 // A suite was selected
276 IProject* project = ICore::self()->projectController()->findProjectByName(item->parent()->data(ProjectRole).toString());
277 ITestSuite* suite = tc->findTestSuite(project, item->data(SuiteRole).toString());
278 jobs << suite->launchAllCases(ITestSuite::Verbose);
279 }
280 else
281 {
282 // This was a single test case
283 IProject* project = ICore::self()->projectController()->findProjectByName(item->parent()->parent()->data(ProjectRole).toString());
284 ITestSuite* suite = tc->findTestSuite(project, item->parent()->data(SuiteRole).toString());
285 const QString testCase = item->data(CaseRole).toString();
286 jobs << suite->launchCase(testCase, ITestSuite::Verbose);
287 }
288 }
289

Callers

nothing calls this directly

Calls 15

testControllerMethod · 0.80
findProjectByNameMethod · 0.80
projectControllerMethod · 0.80
testSuitesForProjectMethod · 0.80
findTestSuiteMethod · 0.80
setPropertyMethod · 0.80
registerJobMethod · 0.80
runControllerMethod · 0.80
isEmptyMethod · 0.45
rowCountMethod · 0.45
reserveMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected