diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp index 0b870f0bc0d..9e0defa04cd 100644 --- a/src/plugins/autotest/autotestplugin.cpp +++ b/src/plugins/autotest/autotestplugin.cpp @@ -511,7 +511,7 @@ public: ExtensionSystem::PluginManager::registerScenario("TestModelManagerInterface", [] { return dd->m_loadProjectScenario(); }); - addTest(&dd->m_testTreeModel); + addTestCreator(createAutotestUnitTests); #endif } diff --git a/src/plugins/autotest/autotestunittests.cpp b/src/plugins/autotest/autotestunittests.cpp index 7ef019dac15..d1fd8880ab1 100644 --- a/src/plugins/autotest/autotestunittests.cpp +++ b/src/plugins/autotest/autotestunittests.cpp @@ -34,16 +34,40 @@ using namespace ExtensionSystem; using namespace ProjectExplorer; using namespace Utils; -namespace Autotest { -namespace Internal { +namespace Autotest::Internal { -AutoTestUnitTests::AutoTestUnitTests(TestTreeModel *model, QObject *parent) - : QObject(parent), - m_model(model) +class AutotestUnitTests : public QObject { -} + Q_OBJECT -void AutoTestUnitTests::initTestCase() +public: + AutotestUnitTests() + : m_model(TestTreeModel::instance()) + {} + +private slots: + void initTestCase(); + void cleanupTestCase(); + void testCodeParser(); + void testCodeParser_data(); + void testCodeParserSwitchStartup(); + void testCodeParserSwitchStartup_data(); + void testCodeParserGTest(); + void testCodeParserGTest_data(); + void testCodeParserBoostTest(); + void testCodeParserBoostTest_data(); + void testModelManagerInterface(); + +private: + TestTreeModel *m_model = nullptr; + CppEditor::Tests::TemporaryCopiedDir *m_tmpDir = nullptr; + bool m_isQt4 = false; + bool m_checkBoost = false; + ProjectExplorer::Kit *m_kit = nullptr; +}; + + +void AutotestUnitTests::initTestCase() { const QList allKits = KitManager::kits(); if (allKits.count() == 0) @@ -80,12 +104,12 @@ void AutoTestUnitTests::initTestCase() theQtTestFramework().quickCheckForDerivedTests.setValue(true); } -void AutoTestUnitTests::cleanupTestCase() +void AutotestUnitTests::cleanupTestCase() { delete m_tmpDir; } -void AutoTestUnitTests::testCodeParser() +void AutotestUnitTests::testCodeParser() { QFETCH(FilePath, projectFilePath); QFETCH(int, expectedAutoTestsCount); @@ -110,7 +134,7 @@ void AutoTestUnitTests::testCodeParser() QCOMPARE(m_model->dataTagsCount(), expectedDataTagsCount); } -void AutoTestUnitTests::testCodeParser_data() +void AutotestUnitTests::testCodeParser_data() { QTest::addColumn("projectFilePath"); QTest::addColumn("expectedAutoTestsCount"); @@ -133,7 +157,7 @@ void AutoTestUnitTests::testCodeParser_data() << 4 << 10 << 5 << 10; } -void AutoTestUnitTests::testCodeParserSwitchStartup() +void AutotestUnitTests::testCodeParserSwitchStartup() { QFETCH(FilePaths, projectFilePaths); QFETCH(QList, expectedAutoTestsCount); @@ -161,7 +185,7 @@ void AutoTestUnitTests::testCodeParserSwitchStartup() } } -void AutoTestUnitTests::testCodeParserSwitchStartup_data() +void AutotestUnitTests::testCodeParserSwitchStartup_data() { QTest::addColumn("projectFilePaths"); QTest::addColumn >("expectedAutoTestsCount"); @@ -187,7 +211,7 @@ void AutoTestUnitTests::testCodeParserSwitchStartup_data() << expectedUnnamedQuickTests << expectedDataTagsCount; } -void AutoTestUnitTests::testCodeParserGTest() +void AutotestUnitTests::testCodeParserGTest() { if (qtcEnvironmentVariableIsEmpty("GOOGLETEST_DIR")) QSKIP("This test needs googletest - set GOOGLETEST_DIR (point to googletest repository)"); @@ -226,7 +250,7 @@ void AutoTestUnitTests::testCodeParserGTest() QCOMPARE(m_model->boostTestNamesCount(), 0); } -void AutoTestUnitTests::testCodeParserGTest_data() +void AutotestUnitTests::testCodeParserGTest_data() { QTest::addColumn("projectFilePath"); QTest::newRow("simpleGoogletest") @@ -235,7 +259,7 @@ void AutoTestUnitTests::testCodeParserGTest_data() << m_tmpDir->filePath() / "simple_gt/simple_gt.qbs"; } -void AutoTestUnitTests::testCodeParserBoostTest() +void AutotestUnitTests::testCodeParserBoostTest() { if (!m_checkBoost) QSKIP("This test needs boost - set BOOST_INCLUDE_DIR (or have it installed)"); @@ -281,7 +305,7 @@ void AutoTestUnitTests::testCodeParserBoostTest() QCOMPARE(m_model->gtestNamesCount(), 0); } -void AutoTestUnitTests::testCodeParserBoostTest_data() +void AutotestUnitTests::testCodeParserBoostTest_data() { QTest::addColumn("projectFilePath"); QTest::addColumn("extension"); @@ -300,10 +324,16 @@ static int executeScenario(const QString &scenario) return QProcess::execute(data.m_executable, data.m_args + additionalArgs); } -void AutoTestUnitTests::testModelManagerInterface() +void AutotestUnitTests::testModelManagerInterface() { QCOMPARE(executeScenario("TestModelManagerInterface"), 0); } -} // namespace Internal -} // namespace Autotest +QObject *createAutotestUnitTests() +{ + return new AutotestUnitTests; +} + +} // namespace Autotest::Internal + +#include "autotestunittests.moc" diff --git a/src/plugins/autotest/autotestunittests.h b/src/plugins/autotest/autotestunittests.h index 752599cb45c..ff5930e418c 100644 --- a/src/plugins/autotest/autotestunittests.h +++ b/src/plugins/autotest/autotestunittests.h @@ -5,43 +5,8 @@ #include -namespace CppEditor { namespace Tests { class TemporaryCopiedDir; } } -namespace ProjectExplorer { class Kit; } +namespace Autotest::Internal { -namespace Autotest { +QObject *createAutotestUnitTests(); -class TestTreeModel; - -namespace Internal { - -class AutoTestUnitTests : public QObject -{ - Q_OBJECT -public: - explicit AutoTestUnitTests(TestTreeModel *model, QObject *parent = nullptr); - -signals: - -private slots: - void initTestCase(); - void cleanupTestCase(); - void testCodeParser(); - void testCodeParser_data(); - void testCodeParserSwitchStartup(); - void testCodeParserSwitchStartup_data(); - void testCodeParserGTest(); - void testCodeParserGTest_data(); - void testCodeParserBoostTest(); - void testCodeParserBoostTest_data(); - void testModelManagerInterface(); - -private: - TestTreeModel *m_model = nullptr; - CppEditor::Tests::TemporaryCopiedDir *m_tmpDir = nullptr; - bool m_isQt4 = false; - bool m_checkBoost = false; - ProjectExplorer::Kit *m_kit = nullptr; -}; - -} // namespace Internal } // namespace Autotest