diff --git a/src/plugins/autotest/autotest.pro b/src/plugins/autotest/autotest.pro index a22a584ff3a..f8ae42d7466 100644 --- a/src/plugins/autotest/autotest.pro +++ b/src/plugins/autotest/autotest.pro @@ -59,7 +59,6 @@ HEADERS += \ testcodeparser.h \ autotestplugin.h \ autotest_global.h \ - autotest_utils.h \ autotestconstants.h \ testrunner.h \ testconfiguration.h \ diff --git a/src/plugins/autotest/autotest.qbs b/src/plugins/autotest/autotest.qbs index 6f6354e00c8..4b8c13f257d 100644 --- a/src/plugins/autotest/autotest.qbs +++ b/src/plugins/autotest/autotest.qbs @@ -33,7 +33,6 @@ QtcPlugin { "autotest.qrc", "autotesticons.h", "autotest_global.h", - "autotest_utils.h", "autotestconstants.h", "autotestplugin.cpp", "autotestplugin.h", diff --git a/src/plugins/autotest/autotest_utils.h b/src/plugins/autotest/autotest_utils.h deleted file mode 100644 index 15982d61293..00000000000 --- a/src/plugins/autotest/autotest_utils.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include -#include - -#include - -namespace Autotest { -namespace Internal { - -class TestUtils -{ -public: - static QString getCMakeDisplayNameIfNecessary(const QString &filePath, const QString &proFile) - { - static const QString CMAKE_LISTS("CMakeLists.txt"); - if (!proFile.endsWith(CMAKE_LISTS)) - return QString(); - - const QList &projectParts - = CppTools::CppModelManager::instance()->projectPart(filePath); - if (projectParts.size()) - return projectParts.first()->displayName; - - return QString(); - } -}; - -} // namespace Internal -} // namespace Autotest diff --git a/src/plugins/autotest/gtest/gtestparser.cpp b/src/plugins/autotest/gtest/gtestparser.cpp index 83e84a5092f..b21f161f06c 100644 --- a/src/plugins/autotest/gtest/gtestparser.cpp +++ b/src/plugins/autotest/gtest/gtestparser.cpp @@ -27,7 +27,9 @@ #include "gtesttreeitem.h" #include "gtestvisitors.h" #include "gtest_utils.h" -#include "../autotest_utils.h" + +#include +#include namespace Autotest { namespace Internal { diff --git a/src/plugins/autotest/gtest/gtesttreeitem.cpp b/src/plugins/autotest/gtest/gtesttreeitem.cpp index 540f7c6679d..e3a44fc9646 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 #include @@ -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 GTestTreeItem::getAllTestConfigurations() const { QList result; @@ -152,28 +123,24 @@ QList GTestTreeItem::getAllTestConfigurations() const if (!project || type() != Root) return result; - QHash proFilesWithTestSets; + QHash proFilesWithTestSets; for (int row = 0, count = childCount(); row < count; ++row) { const GTestTreeItem *child = static_cast(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::ConstIterator it = proFilesWithTestSets.begin(); - QHash::ConstIterator end = proFilesWithTestSets.end(); + QHash::ConstIterator it = proFilesWithTestSets.begin(); + QHash::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 GTestTreeItem::getSelectedTestConfigurations() const { QList result; @@ -201,7 +161,7 @@ QList GTestTreeItem::getSelectedTestConfigurations() const if (!project || type() != Root) return result; - QHash proFilesWithCheckedTestSets; + QHash proFilesWithCheckedTestSets; for (int row = 0, count = childCount(); row < count; ++row) { const GTestTreeItem *child = static_cast(childItem(row)); @@ -212,7 +172,7 @@ QList 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 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 GTestTreeItem::getSelectedTestConfigurations() const } } - QHash::ConstIterator it = proFilesWithCheckedTestSets.begin(); - QHash::ConstIterator end = proFilesWithCheckedTestSets.end(); + QHash::ConstIterator it = proFilesWithCheckedTestSets.begin(); + QHash::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; } diff --git a/src/plugins/autotest/qtest/qttestparser.cpp b/src/plugins/autotest/qtest/qttestparser.cpp index 8371f6d6142..93376cba7c9 100644 --- a/src/plugins/autotest/qtest/qttestparser.cpp +++ b/src/plugins/autotest/qtest/qttestparser.cpp @@ -27,8 +27,9 @@ #include "qttesttreeitem.h" #include "qttestvisitors.h" #include "qttest_utils.h" -#include "../autotest_utils.h" +#include +#include #include #include diff --git a/src/plugins/autotest/qtest/qttesttreeitem.cpp b/src/plugins/autotest/qtest/qttesttreeitem.cpp index 9236b796313..53f60b22fee 100644 --- a/src/plugins/autotest/qtest/qttesttreeitem.cpp +++ b/src/plugins/autotest/qtest/qttesttreeitem.cpp @@ -26,7 +26,6 @@ #include "qttesttreeitem.h" #include "qttestconfiguration.h" #include "qttestparser.h" -#include "../autotest_utils.h" #include #include diff --git a/src/plugins/autotest/quick/quicktestparser.cpp b/src/plugins/autotest/quick/quicktestparser.cpp index cb7e5a04646..b7528f414cc 100644 --- a/src/plugins/autotest/quick/quicktestparser.cpp +++ b/src/plugins/autotest/quick/quicktestparser.cpp @@ -27,9 +27,10 @@ #include "quicktesttreeitem.h" #include "quicktestvisitors.h" #include "quicktest_utils.h" -#include "../autotest_utils.h" #include "../testcodeparser.h" +#include +#include #include #include #include diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp index 001ea5d48b0..6f444da8b4b 100644 --- a/src/plugins/autotest/testcodeparser.cpp +++ b/src/plugins/autotest/testcodeparser.cpp @@ -24,7 +24,6 @@ ****************************************************************************/ #include "autotestconstants.h" -#include "autotest_utils.h" #include "autotestplugin.h" #include "testcodeparser.h" #include "testframeworkmanager.h" diff --git a/src/plugins/autotest/testtreeitem.cpp b/src/plugins/autotest/testtreeitem.cpp index 7b912b8085a..bbba24cfb3b 100644 --- a/src/plugins/autotest/testtreeitem.cpp +++ b/src/plugins/autotest/testtreeitem.cpp @@ -24,7 +24,6 @@ ****************************************************************************/ #include "autotestconstants.h" -#include "autotest_utils.h" #include "itestparser.h" #include "testconfiguration.h" #include "testtreeitem.h"