AutoTest: Provide easy Id<->ITestFramework * mapping

They are 1:1, idea is to replace (most of the) Id uses with the
framework itself, overall simplifying e.g. TestFrameworkManager.

For a salami-tactics transition, easy convervion between the two helps.

Change-Id: Ib6d166ae34a3189d900353be7a181a1e45467a7c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2020-03-13 12:16:26 +01:00
parent 22cdc47077
commit c1f210dd69
3 changed files with 11 additions and 1 deletions

View File

@@ -62,6 +62,8 @@ public:
Core::Id settingsId() const;
Core::Id id() const { return Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(name()); }
bool active() const { return m_active; }
void setActive(bool active) { m_active = active; }
bool grouping() const { return m_grouping; }

View File

@@ -74,7 +74,7 @@ TestFrameworkManager::~TestFrameworkManager()
bool TestFrameworkManager::registerTestFramework(ITestFramework *framework)
{
QTC_ASSERT(framework, return false);
Id id = Id(Constants::FRAMEWORK_PREFIX).withSuffix(framework->name());
Id id = framework->id();
QTC_ASSERT(!m_registeredFrameworks.contains(id), delete framework; return false);
// TODO check for unique priority before registering
qCDebug(LOG) << "Registering" << id;
@@ -156,6 +156,11 @@ ITestParser *TestFrameworkManager::testParserForTestFramework(const Id &framewor
return testParser;
}
ITestFramework *TestFrameworkManager::frameworkForId(Id frameworkId)
{
return instance()->m_registeredFrameworks.value(frameworkId, nullptr);
}
IFrameworkSettings *TestFrameworkManager::settingsForTestFramework(
const Id &frameworkId) const
{

View File

@@ -54,6 +54,9 @@ class TestFrameworkManager
public:
static TestFrameworkManager *instance();
virtual ~TestFrameworkManager();
static ITestFramework *frameworkForId(Core::Id frameworkId);
bool registerTestFramework(ITestFramework *framework);
void activateFrameworksFromSettings(const Internal::TestSettings *settings);