From 0d11d880ca0af8c2c5bc069f05e0851729563ad3 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 7 Aug 2019 10:25:43 +0200 Subject: [PATCH] AutoTest: Unify container usage in TestFrameworkManager And provide an accessor for the framework's priority which will be needed later on. Change-Id: I5a2480699d9467ee50e2cc44b9d4ff58f9e8da88 Reviewed-by: David Schulz --- src/plugins/autotest/testcodeparser.cpp | 2 +- src/plugins/autotest/testcodeparser.h | 2 +- src/plugins/autotest/testframeworkmanager.cpp | 15 +++++++++++---- src/plugins/autotest/testframeworkmanager.h | 6 +++--- src/plugins/autotest/testtreemodel.cpp | 2 +- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp index 755d0e57dea..1081c80acaf 100644 --- a/src/plugins/autotest/testcodeparser.cpp +++ b/src/plugins/autotest/testcodeparser.cpp @@ -115,7 +115,7 @@ void TestCodeParser::setState(State state) } } -void TestCodeParser::syncTestFrameworks(const QVector &frameworkIds) +void TestCodeParser::syncTestFrameworks(const QList &frameworkIds) { if (m_parserState != Idle) { // there's a running parse diff --git a/src/plugins/autotest/testcodeparser.h b/src/plugins/autotest/testcodeparser.h index 0bd9fa85a51..674219dcc9d 100644 --- a/src/plugins/autotest/testcodeparser.h +++ b/src/plugins/autotest/testcodeparser.h @@ -62,7 +62,7 @@ public: State state() const { return m_parserState; } bool isParsing() const { return m_parserState == PartialParse || m_parserState == FullParse; } void setDirty() { m_dirty = true; } - void syncTestFrameworks(const QVector &frameworkIds); + void syncTestFrameworks(const QList &frameworkIds); #ifdef WITH_TESTS bool furtherParsingExpected() const { return m_singleShotScheduled || m_fullUpdatePostponed || m_partialUpdatePostponed; } diff --git a/src/plugins/autotest/testframeworkmanager.cpp b/src/plugins/autotest/testframeworkmanager.cpp index e96ee536ffc..fd8f1261183 100644 --- a/src/plugins/autotest/testframeworkmanager.cpp +++ b/src/plugins/autotest/testframeworkmanager.cpp @@ -120,9 +120,9 @@ QList TestFrameworkManager::sortedRegisteredFrameworkIds() const return registered; } -QVector TestFrameworkManager::activeFrameworkIds() const +QList TestFrameworkManager::activeFrameworkIds() const { - QVector active; + QList active; FrameworkIterator it = m_registeredFrameworks.begin(); FrameworkIterator end = m_registeredFrameworks.end(); for ( ; it != end; ++it) { @@ -132,9 +132,9 @@ QVector TestFrameworkManager::activeFrameworkIds() const return active; } -QVector TestFrameworkManager::sortedActiveFrameworkIds() const +QList TestFrameworkManager::sortedActiveFrameworkIds() const { - QVector active = activeFrameworkIds(); + QList active = activeFrameworkIds(); Utils::sort(active, [this] (const Core::Id &lhs, const Core::Id &rhs) { return m_registeredFrameworks[lhs]->priority() < m_registeredFrameworks[rhs]->priority(); }); @@ -210,5 +210,12 @@ bool TestFrameworkManager::hasActiveFrameworks() const return false; } +unsigned TestFrameworkManager::priority(const Core::Id &frameworkId) const +{ + if (ITestFramework *framework = m_registeredFrameworks.value(frameworkId)) + return framework->priority(); + return unsigned(-1); +} + } // namespace Internal } // namespace Autotest diff --git a/src/plugins/autotest/testframeworkmanager.h b/src/plugins/autotest/testframeworkmanager.h index 27532020247..7814ca2e819 100644 --- a/src/plugins/autotest/testframeworkmanager.h +++ b/src/plugins/autotest/testframeworkmanager.h @@ -58,7 +58,7 @@ public: QString frameworkNameForId(const Core::Id &id) const; QList registeredFrameworkIds() const; QList sortedRegisteredFrameworkIds() const; - QVector sortedActiveFrameworkIds() const; + QList sortedActiveFrameworkIds() const; TestTreeItem *rootNodeForTestFramework(const Core::Id &frameworkId) const; ITestParser *testParserForTestFramework(const Core::Id &frameworkId) const; @@ -69,9 +69,9 @@ public: void setGroupingEnabledFor(const Core::Id &frameworkId, bool enabled); QString groupingToolTip(const Core::Id &frameworkId) const; bool hasActiveFrameworks() const; - + unsigned priority(const Core::Id &frameworkId) const; private: - QVector activeFrameworkIds() const; + QList activeFrameworkIds() const; explicit TestFrameworkManager(); QHash m_registeredFrameworks; QHash > m_frameworkSettings; diff --git a/src/plugins/autotest/testtreemodel.cpp b/src/plugins/autotest/testtreemodel.cpp index 953e93dc9c7..cb58de73ea0 100644 --- a/src/plugins/autotest/testtreemodel.cpp +++ b/src/plugins/autotest/testtreemodel.cpp @@ -204,7 +204,7 @@ void TestTreeModel::syncTestFrameworks() removeTestRootNodes(); TestFrameworkManager *frameworkManager = TestFrameworkManager::instance(); - QVector sortedIds = frameworkManager->sortedActiveFrameworkIds(); + QList sortedIds = frameworkManager->sortedActiveFrameworkIds(); for (const Core::Id &id : sortedIds) rootItem()->appendChild(frameworkManager->rootNodeForTestFramework(id));