forked from qt-creator/qt-creator
Add 'Run This Test' capability to data tags
Change-Id: I3eb99f0a0652053cb05a3457a37ff335bab5580b Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
This commit is contained in:
@@ -103,7 +103,8 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||
int type = index.data(TypeRole).toInt();
|
||||
const QString &unnamed = tr(Constants::UNNAMED_QUICKTESTS);
|
||||
if ((type == TestTreeItem::TEST_FUNCTION && index.parent().data().toString() != unnamed)
|
||||
|| (type == TestTreeItem::TEST_CLASS && index.data().toString() != unnamed)) {
|
||||
|| (type == TestTreeItem::TEST_CLASS && index.data().toString() != unnamed)
|
||||
|| (type == TestTreeItem::TEST_DATATAG)) {
|
||||
runThisTest = new QAction(tr("Run This Test"), &menu);
|
||||
runThisTest->setEnabled(enabled);
|
||||
connect(runThisTest, &QAction::triggered,
|
||||
@@ -247,7 +248,8 @@ void TestNavigationWidget::onRunThisTestTriggered()
|
||||
return;
|
||||
|
||||
TestTreeItem *item = static_cast<TestTreeItem *>(sourceIndex.internalPointer());
|
||||
if (item->type() == TestTreeItem::TEST_CLASS || item->type() == TestTreeItem::TEST_FUNCTION) {
|
||||
if (item->type() == TestTreeItem::TEST_CLASS || item->type() == TestTreeItem::TEST_FUNCTION
|
||||
|| item->type() == TestTreeItem::TEST_DATATAG) {
|
||||
if (TestConfiguration *configuration = m_model->getTestConfiguration(item)) {
|
||||
TestRunner *runner = TestRunner::instance();
|
||||
runner->setSelectedTests( {configuration} );
|
||||
|
||||
@@ -558,6 +558,17 @@ TestConfiguration *TestTreeModel::getTestConfiguration(const TestTreeItem *item)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TestTreeItem::TEST_DATATAG: {
|
||||
const TestTreeItem *function = item->parent();
|
||||
const TestTreeItem *parent = function ? function->parent() : 0;
|
||||
if (!parent)
|
||||
return 0;
|
||||
const QString functionWithTag = function->name() + QLatin1Char(':') + item->name();
|
||||
config = new TestConfiguration(parent->name(), QStringList() << functionWithTag);
|
||||
config->setMainFilePath(parent->filePath());
|
||||
config->setProject(project);
|
||||
break;
|
||||
}
|
||||
// not supported items
|
||||
default:
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user