forked from qt-creator/qt-creator
AutoTest: Introduce ITestBase
Make ITestBase the base class for ITestFramework. Preparation for adding support for testing tools. Change-Id: If9184dcbd94c10b17bba83c0d02b0ecb50458e67 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -28,16 +28,11 @@
|
|||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
|
|
||||||
ITestFramework::ITestFramework(bool activeByDefault)
|
ITestBase::ITestBase(bool activeByDefault)
|
||||||
: m_active(activeByDefault)
|
: m_active(activeByDefault)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ITestFramework::~ITestFramework()
|
TestTreeItem *ITestBase::rootNode()
|
||||||
{
|
|
||||||
delete m_testParser;
|
|
||||||
}
|
|
||||||
|
|
||||||
TestTreeItem *ITestFramework::rootNode()
|
|
||||||
{
|
{
|
||||||
if (!m_rootNode)
|
if (!m_rootNode)
|
||||||
m_rootNode = createRootNode();
|
m_rootNode = createRootNode();
|
||||||
@@ -45,25 +40,18 @@ TestTreeItem *ITestFramework::rootNode()
|
|||||||
return m_rootNode;
|
return m_rootNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
ITestParser *ITestFramework::testParser()
|
Utils::Id ITestBase::settingsId() const
|
||||||
{
|
|
||||||
if (!m_testParser)
|
|
||||||
m_testParser = createTestParser();
|
|
||||||
return m_testParser;
|
|
||||||
}
|
|
||||||
|
|
||||||
Utils::Id ITestFramework::settingsId() const
|
|
||||||
{
|
{
|
||||||
return Utils::Id(Constants::SETTINGSPAGE_PREFIX)
|
return Utils::Id(Constants::SETTINGSPAGE_PREFIX)
|
||||||
.withSuffix(QString("%1.%2").arg(priority()).arg(QLatin1String(name())));
|
.withSuffix(QString("%1.%2").arg(priority()).arg(QLatin1String(name())));
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Id ITestFramework::id() const
|
Utils::Id ITestBase::id() const
|
||||||
{
|
{
|
||||||
return Utils::Id(Constants::FRAMEWORK_PREFIX).withSuffix(name());
|
return Utils::Id(Constants::FRAMEWORK_PREFIX).withSuffix(name());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ITestFramework::resetRootNode()
|
void ITestBase::resetRootNode()
|
||||||
{
|
{
|
||||||
if (!m_rootNode)
|
if (!m_rootNode)
|
||||||
return;
|
return;
|
||||||
@@ -73,4 +61,21 @@ void ITestFramework::resetRootNode()
|
|||||||
m_rootNode = nullptr;
|
m_rootNode = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ITestFramework::ITestFramework(bool activeByDefault)
|
||||||
|
: ITestBase(activeByDefault)
|
||||||
|
{}
|
||||||
|
|
||||||
|
ITestFramework::~ITestFramework()
|
||||||
|
{
|
||||||
|
delete m_testParser;
|
||||||
|
}
|
||||||
|
|
||||||
|
ITestParser *ITestFramework::testParser()
|
||||||
|
{
|
||||||
|
if (!m_testParser)
|
||||||
|
m_testParser = createTestParser();
|
||||||
|
return m_testParser;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Autotest
|
} // namespace Autotest
|
||||||
|
@@ -32,40 +32,53 @@ namespace Autotest {
|
|||||||
|
|
||||||
class IFrameworkSettings;
|
class IFrameworkSettings;
|
||||||
|
|
||||||
class ITestFramework
|
class ITestBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ITestFramework(bool activeByDefault);
|
explicit ITestBase(bool activeByDefault);
|
||||||
virtual ~ITestFramework();
|
virtual ~ITestBase() = default;
|
||||||
|
|
||||||
virtual const char *name() const = 0;
|
virtual const char *name() const = 0;
|
||||||
virtual unsigned priority() const = 0; // should this be modifyable?
|
virtual unsigned priority() const = 0; // should this be modifyable?
|
||||||
|
|
||||||
virtual IFrameworkSettings *frameworkSettings() { return nullptr; }
|
|
||||||
|
|
||||||
TestTreeItem *rootNode();
|
TestTreeItem *rootNode();
|
||||||
ITestParser *testParser();
|
|
||||||
|
|
||||||
Utils::Id settingsId() const;
|
Utils::Id settingsId() const;
|
||||||
Utils::Id id() const;
|
Utils::Id id() const;
|
||||||
|
|
||||||
bool active() const { return m_active; }
|
bool active() const { return m_active; }
|
||||||
void setActive(bool active) { m_active = active; }
|
void setActive(bool active) { m_active = active; }
|
||||||
|
|
||||||
|
void resetRootNode();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual TestTreeItem *createRootNode() = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
TestTreeItem *m_rootNode = nullptr;
|
||||||
|
bool m_active = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ITestFramework : public ITestBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit ITestFramework(bool activeByDefault);
|
||||||
|
~ITestFramework() override;
|
||||||
|
|
||||||
|
virtual IFrameworkSettings *frameworkSettings() { return nullptr; }
|
||||||
|
|
||||||
|
ITestParser *testParser();
|
||||||
|
|
||||||
bool grouping() const { return m_grouping; }
|
bool grouping() const { return m_grouping; }
|
||||||
void setGrouping(bool group) { m_grouping = group; }
|
void setGrouping(bool group) { m_grouping = group; }
|
||||||
// framework specific tool tip to be displayed on the general settings page
|
// framework specific tool tip to be displayed on the general settings page
|
||||||
virtual QString groupingToolTip() const { return QString(); }
|
virtual QString groupingToolTip() const { return QString(); }
|
||||||
|
|
||||||
void resetRootNode();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ITestParser *createTestParser() = 0;
|
virtual ITestParser *createTestParser() = 0;
|
||||||
virtual TestTreeItem *createRootNode() = 0;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TestTreeItem *m_rootNode = nullptr;
|
|
||||||
ITestParser *m_testParser = nullptr;
|
ITestParser *m_testParser = nullptr;
|
||||||
bool m_active = false;
|
|
||||||
bool m_grouping = false;
|
bool m_grouping = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user