summaryrefslogtreecommitdiff
path: root/src/plugins/autotest
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@theqtcompany.com>2016-02-11 13:53:12 +0100
committerChristian Stenger <christian.stenger@theqtcompany.com>2016-02-26 09:40:00 +0000
commitcb9909083b9f700c07e3a5c6e9df795339ca3ab6 (patch)
tree041f2ccf4f18d7795d8d8115eff1329b182e3309 /src/plugins/autotest
parent47c37556007041e4556b57da5cd73a736cc9b0ae (diff)
downloadqt-creator-cb9909083b9f700c07e3a5c6e9df795339ca3ab6.tar.gz
AutoTest: Don't duplicate information inside TestTreeItem
For Quick Test and Google Test tree items the referencing file is always the same as the main file, so remove this duplication and use the referencing file as this information is mandatory. Change-Id: Ib9ddb1d546ed785a4f1aad133a63138c929379c2 Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
Diffstat (limited to 'src/plugins/autotest')
-rw-r--r--src/plugins/autotest/testtreeitem.h3
-rw-r--r--src/plugins/autotest/testtreemodel.cpp30
2 files changed, 14 insertions, 19 deletions
diff --git a/src/plugins/autotest/testtreeitem.h b/src/plugins/autotest/testtreeitem.h
index 26a8825936..1b7415252d 100644
--- a/src/plugins/autotest/testtreeitem.h
+++ b/src/plugins/autotest/testtreeitem.h
@@ -92,8 +92,6 @@ public:
unsigned line() const { return m_line; }
void setColumn(unsigned column) { m_column = column; }
unsigned column() const { return m_column; }
- QString mainFile() const { return m_mainFile; }
- void setMainFile(const QString &mainFile) { m_mainFile = mainFile; }
QString referencingFile() const { return m_referencingFile; }
void setReferencingFile(const QString &referencingFile) { m_referencingFile = referencingFile; }
void setChecked(const Qt::CheckState checked);
@@ -127,7 +125,6 @@ private:
Type m_type;
unsigned m_line;
unsigned m_column;
- QString m_mainFile; // main for Quick tests, project file for gtest
QString m_referencingFile;
TestStates m_state;
bool m_markedForRemoval;
diff --git a/src/plugins/autotest/testtreemodel.cpp b/src/plugins/autotest/testtreemodel.cpp
index 66f389ed47..f506a9a130 100644
--- a/src/plugins/autotest/testtreemodel.cpp
+++ b/src/plugins/autotest/testtreemodel.cpp
@@ -254,14 +254,14 @@ QList<TestConfiguration *> TestTreeModel::getAllTestCases() const
if (child->name().isEmpty()) {
for (int childRow = 0, ccount = child->childCount(); childRow < ccount; ++ childRow) {
const TestTreeItem *grandChild = child->childItem(childRow);
- const QString mainFile = grandChild->mainFile();
+ const QString mainFile = grandChild->referencingFile();
foundMains.insert(mainFile, foundMains.contains(mainFile)
? foundMains.value(mainFile) + 1 : 1);
}
continue;
}
// named Quick Test
- const QString mainFile = child->mainFile();
+ const QString mainFile = child->referencingFile();
foundMains.insert(mainFile, foundMains.contains(mainFile)
? foundMains.value(mainFile) + child->childCount()
: child->childCount());
@@ -281,7 +281,7 @@ QList<TestConfiguration *> TestTreeModel::getAllTestCases() const
for (int row = 0, count = m_googleTestRootItem->childCount(); row < count; ++row) {
const TestTreeItem *child = m_googleTestRootItem->childItem(row);
for (int childRow = 0, childCount = child->childCount(); childRow < childCount; ++childRow) {
- const QString &proFilePath = child->childItem(childRow)->mainFile();
+ const QString &proFilePath = child->childItem(childRow)->referencingFile();
foundMains.insert(proFilePath, foundMains.contains(proFilePath)
? foundMains.value(proFilePath) + 1 : 1);
}
@@ -347,7 +347,7 @@ QList<TestConfiguration *> TestTreeModel::getSelectedTests() const
if (TestTreeItem *unnamed = unnamedQuickTests()) {
for (int childRow = 0, ccount = unnamed->childCount(); childRow < ccount; ++ childRow) {
const TestTreeItem *grandChild = unnamed->childItem(childRow);
- const QString mainFile = grandChild->mainFile();
+ const QString mainFile = grandChild->referencingFile();
if (foundMains.contains(mainFile)) {
QTC_ASSERT(testConfiguration,
qWarning() << "Illegal state (unnamed Quick Test listed as named)";
@@ -386,8 +386,8 @@ QList<TestConfiguration *> TestTreeModel::getSelectedTests() const
testFunctions << child->name() + QLatin1String("::") + grandChild->name();
}
TestConfiguration *tc;
- if (foundMains.contains(child->mainFile())) {
- tc = foundMains[child->mainFile()];
+ if (foundMains.contains(child->referencingFile())) {
+ tc = foundMains[child->referencingFile()];
QStringList oldFunctions(tc->testCases());
// if oldFunctions.size() is 0 this test configuration is used for at least one
// unnamed test case
@@ -400,9 +400,9 @@ QList<TestConfiguration *> TestTreeModel::getSelectedTests() const
}
} else {
tc = new TestConfiguration(QString(), testFunctions);
- tc->setMainFilePath(child->mainFile());
+ tc->setMainFilePath(child->referencingFile());
tc->setProject(project);
- foundMains.insert(child->mainFile(), tc);
+ foundMains.insert(child->referencingFile(), tc);
}
break;
}
@@ -426,7 +426,7 @@ QList<TestConfiguration *> TestTreeModel::getSelectedTests() const
int grandChildCount = child->childCount();
for (int grandChildRow = 0; grandChildRow < grandChildCount; ++grandChildRow) {
const TestTreeItem *grandChild = child->childItem(grandChildRow);
- const QString &proFile = grandChild->mainFile();
+ const QString &proFile = grandChild->referencingFile();
QStringList enabled = proFilesWithEnabledTestSets.value(proFile);
if (grandChild->checked() == Qt::Checked) {
QString testSpecifier = child->name() + QLatin1Char('.') + grandChild->name();
@@ -469,7 +469,7 @@ TestConfiguration *TestTreeModel::getTestConfiguration(const TestTreeItem *item)
+ item->childItem(row)->name();
}
config = new TestConfiguration(QString(), testFunctions);
- config->setMainFilePath(item->mainFile());
+ config->setMainFilePath(item->referencingFile());
config->setProject(project);
} else {
// normal auto test
@@ -485,7 +485,7 @@ TestConfiguration *TestTreeModel::getTestConfiguration(const TestTreeItem *item)
// it's a Quick Test function of a named TestCase
QStringList testFunction(parent->name() + QLatin1String("::") + item->name());
config = new TestConfiguration(QString(), testFunction);
- config->setMainFilePath(parent->mainFile());
+ config->setMainFilePath(parent->referencingFile());
config->setProject(project);
} else {
// normal auto test
@@ -515,7 +515,7 @@ TestConfiguration *TestTreeModel::getTestConfiguration(const TestTreeItem *item)
if (int childCount = item->childCount()) {
config = new TestConfiguration(QString(), QStringList(testSpecifier));
config->setTestCaseCount(childCount);
- config->setProFile(item->childItem(0)->mainFile());
+ config->setProFile(item->childItem(0)->referencingFile());
config->setProject(project);
config->setTestType(TestTypeGTest);
}
@@ -530,7 +530,7 @@ TestConfiguration *TestTreeModel::getTestConfiguration(const TestTreeItem *item)
testSpecifier.append(QLatin1String("/*"));
}
config = new TestConfiguration(QString(), QStringList(testSpecifier));
- config->setProFile(item->mainFile());
+ config->setProFile(item->referencingFile());
config->setProject(project);
config->setTestType(TestTypeGTest);
break;
@@ -672,7 +672,6 @@ static TestTreeItem *constructUnnamedQuickFunctionTestTreeItem(const QString &fu
TestTreeItem *treeItem = new TestTreeItem(functionName, location.m_name, location.m_type);
treeItem->setLine(location.m_line);
treeItem->setColumn(location.m_column);
- treeItem->setMainFile(referencingFile); // FIXME: can be handled by referencingFile
treeItem->setReferencingFile(referencingFile);
return treeItem;
}
@@ -703,7 +702,6 @@ static TestTreeItem *constructTestTreeItem(const TestParseResult &result)
}
} else {
treeItem = new TestTreeItem(result.testCaseName, result.fileName, TestTreeItem::TestClass);
- treeItem->setMainFile(result.referencingFile); // FIXME: can be handled by referencingFile
treeItem->setReferencingFile(result.referencingFile);
treeItem->setLine(result.line);
treeItem->setColumn(result.column);
@@ -727,7 +725,7 @@ static TestTreeItem *constructGTestSetTreeItem(const QString &filePath,
treeItem->setState(location.m_state);
treeItem->setLine(location.m_line);
treeItem->setColumn(location.m_column);
- treeItem->setMainFile(referencingFile);
+ treeItem->setReferencingFile(referencingFile);
return treeItem;
}