diff options
author | Christian Stenger <christian.stenger@qt.io> | 2017-05-08 12:09:11 +0200 |
---|---|---|
committer | Christian Stenger <christian.stenger@qt.io> | 2017-05-19 10:02:55 +0000 |
commit | cccc6b37ecc02feae653160e436bc245f42750bf (patch) | |
tree | cb02fa7ede2419cc2aab1d3a5f1dd7e6a540d38d /src/plugins/autotest/gtest/gtesttreeitem.cpp | |
parent | 36ec37b29d22a5128d1ab088a73d6b5237ac56f5 (diff) | |
download | qt-creator-cccc6b37ecc02feae653160e436bc245f42750bf.tar.gz |
AutoTest: Remove not needed code
As this functionality had been simplified GTest* classes had been
ignored. Continue the simplification and finally remove now useless
code and file.
Change-Id: I89170cd5f05bb93bf30a05fdbf5370012bc9741a
Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/autotest/gtest/gtesttreeitem.cpp')
-rw-r--r-- | src/plugins/autotest/gtest/gtesttreeitem.cpp | 63 |
1 files changed, 11 insertions, 52 deletions
diff --git a/src/plugins/autotest/gtest/gtesttreeitem.cpp b/src/plugins/autotest/gtest/gtesttreeitem.cpp index 540f7c6679..e3a44fc964 100644 --- a/src/plugins/autotest/gtest/gtesttreeitem.cpp +++ b/src/plugins/autotest/gtest/gtesttreeitem.cpp @@ -26,7 +26,6 @@ #include "gtesttreeitem.h" #include "gtestconfiguration.h" #include "gtestparser.h" -#include "../autotest_utils.h" #include <projectexplorer/session.h> #include <utils/qtcassert.h> @@ -116,34 +115,6 @@ TestConfiguration *GTestTreeItem::debugConfiguration() const return config; } -// used as key inside getAllTestCases()/getSelectedTestCases() for Google Tests -class ProFileWithDisplayName -{ -public: - ProFileWithDisplayName(const QString &file, const QString &name) - : proFile(file), displayName(name) {} - QString proFile; - QString displayName; - - bool operator==(const ProFileWithDisplayName &rhs) const - { - return proFile == rhs.proFile && displayName == rhs.displayName; - } -}; - -// needed as ProFileWithDisplayName is used as key inside a QHash -bool operator<(const ProFileWithDisplayName &lhs, const ProFileWithDisplayName &rhs) -{ - return lhs.proFile == rhs.proFile ? lhs.displayName < rhs.displayName - : lhs.proFile < rhs.proFile; -} - -// needed as ProFileWithDisplayName is used as a key inside a QHash -uint qHash(const ProFileWithDisplayName &lhs) -{ - return ::qHash(lhs.proFile) ^ ::qHash(lhs.displayName); -} - QList<TestConfiguration *> GTestTreeItem::getAllTestConfigurations() const { QList<TestConfiguration *> result; @@ -152,28 +123,24 @@ QList<TestConfiguration *> GTestTreeItem::getAllTestConfigurations() const if (!project || type() != Root) return result; - QHash<ProFileWithDisplayName, int> proFilesWithTestSets; + QHash<QString, int> proFilesWithTestSets; for (int row = 0, count = childCount(); row < count; ++row) { const GTestTreeItem *child = static_cast<const GTestTreeItem *>(childItem(row)); const int grandChildCount = child->childCount(); for (int grandChildRow = 0; grandChildRow < grandChildCount; ++grandChildRow) { const TestTreeItem *grandChild = child->childItem(grandChildRow); - ProFileWithDisplayName key(grandChild->proFile(), - TestUtils::getCMakeDisplayNameIfNecessary(grandChild->filePath(), - grandChild->proFile())); - + const QString &key = grandChild->proFile(); proFilesWithTestSets.insert(key, proFilesWithTestSets[key] + 1); } } - QHash<ProFileWithDisplayName, int>::ConstIterator it = proFilesWithTestSets.begin(); - QHash<ProFileWithDisplayName, int>::ConstIterator end = proFilesWithTestSets.end(); + QHash<QString, int>::ConstIterator it = proFilesWithTestSets.begin(); + QHash<QString, int>::ConstIterator end = proFilesWithTestSets.end(); for ( ; it != end; ++it) { - const ProFileWithDisplayName &key = it.key(); GTestConfiguration *tc = new GTestConfiguration; tc->setTestCaseCount(it.value()); - tc->setProjectFile(key.proFile); + tc->setProjectFile(it.key()); tc->setProject(project); result << tc; } @@ -187,13 +154,6 @@ struct TestCases int additionalTestCaseCount = 0; }; -static const ProFileWithDisplayName createProfile(const TestTreeItem *item) -{ - return ProFileWithDisplayName( - item->proFile(), - TestUtils::getCMakeDisplayNameIfNecessary(item->filePath(), item->proFile())); -} - QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const { QList<TestConfiguration *> result; @@ -201,7 +161,7 @@ QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const if (!project || type() != Root) return result; - QHash<ProFileWithDisplayName, TestCases> proFilesWithCheckedTestSets; + QHash<QString, TestCases> proFilesWithCheckedTestSets; for (int row = 0, count = childCount(); row < count; ++row) { const GTestTreeItem *child = static_cast<const GTestTreeItem *>(childItem(row)); @@ -212,7 +172,7 @@ QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const case Qt::Unchecked: continue; case Qt::Checked: { - auto &testCases = proFilesWithCheckedTestSets[createProfile(child->childItem(0))]; + auto &testCases = proFilesWithCheckedTestSets[child->childItem(0)->proFile()]; testCases.filters.append(gtestFilter(child->state()).arg(child->name()).arg('*')); testCases.additionalTestCaseCount += grandChildCount - 1; break; @@ -221,7 +181,7 @@ QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const for (int grandChildRow = 0; grandChildRow < grandChildCount; ++grandChildRow) { const TestTreeItem *grandChild = child->childItem(grandChildRow); if (grandChild->checked() == Qt::Checked) { - proFilesWithCheckedTestSets[createProfile(grandChild)].filters.append( + proFilesWithCheckedTestSets[grandChild->proFile()].filters.append( gtestFilter(child->state()).arg(child->name()).arg(grandChild->name())); } } @@ -230,14 +190,13 @@ QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const } } - QHash<ProFileWithDisplayName, TestCases>::ConstIterator it = proFilesWithCheckedTestSets.begin(); - QHash<ProFileWithDisplayName, TestCases>::ConstIterator end = proFilesWithCheckedTestSets.end(); + QHash<QString, TestCases>::ConstIterator it = proFilesWithCheckedTestSets.begin(); + QHash<QString, TestCases>::ConstIterator end = proFilesWithCheckedTestSets.end(); for ( ; it != end; ++it) { - const ProFileWithDisplayName &proFileWithDisplayName = it.key(); GTestConfiguration *tc = new GTestConfiguration; tc->setTestCases(it.value().filters); tc->setTestCaseCount(tc->testCaseCount() + it.value().additionalTestCaseCount); - tc->setProjectFile(proFileWithDisplayName.proFile); + tc->setProjectFile(it.key()); tc->setProject(project); result << tc; } |