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 {
|
||||
|
||||
ITestFramework::ITestFramework(bool activeByDefault)
|
||||
ITestBase::ITestBase(bool activeByDefault)
|
||||
: m_active(activeByDefault)
|
||||
{}
|
||||
|
||||
ITestFramework::~ITestFramework()
|
||||
{
|
||||
delete m_testParser;
|
||||
}
|
||||
|
||||
TestTreeItem *ITestFramework::rootNode()
|
||||
TestTreeItem *ITestBase::rootNode()
|
||||
{
|
||||
if (!m_rootNode)
|
||||
m_rootNode = createRootNode();
|
||||
@@ -45,25 +40,18 @@ TestTreeItem *ITestFramework::rootNode()
|
||||
return m_rootNode;
|
||||
}
|
||||
|
||||
ITestParser *ITestFramework::testParser()
|
||||
{
|
||||
if (!m_testParser)
|
||||
m_testParser = createTestParser();
|
||||
return m_testParser;
|
||||
}
|
||||
|
||||
Utils::Id ITestFramework::settingsId() const
|
||||
Utils::Id ITestBase::settingsId() const
|
||||
{
|
||||
return Utils::Id(Constants::SETTINGSPAGE_PREFIX)
|
||||
.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());
|
||||
}
|
||||
|
||||
void ITestFramework::resetRootNode()
|
||||
void ITestBase::resetRootNode()
|
||||
{
|
||||
if (!m_rootNode)
|
||||
return;
|
||||
@@ -73,4 +61,21 @@ void ITestFramework::resetRootNode()
|
||||
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
|
||||
|
@@ -32,40 +32,53 @@ namespace Autotest {
|
||||
|
||||
class IFrameworkSettings;
|
||||
|
||||
class ITestFramework
|
||||
class ITestBase
|
||||
{
|
||||
public:
|
||||
explicit ITestFramework(bool activeByDefault);
|
||||
virtual ~ITestFramework();
|
||||
explicit ITestBase(bool activeByDefault);
|
||||
virtual ~ITestBase() = default;
|
||||
|
||||
virtual const char *name() const = 0;
|
||||
virtual unsigned priority() const = 0; // should this be modifyable?
|
||||
|
||||
virtual IFrameworkSettings *frameworkSettings() { return nullptr; }
|
||||
|
||||
TestTreeItem *rootNode();
|
||||
ITestParser *testParser();
|
||||
|
||||
Utils::Id settingsId() const;
|
||||
Utils::Id id() const;
|
||||
|
||||
bool active() const { return m_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; }
|
||||
void setGrouping(bool group) { m_grouping = group; }
|
||||
// framework specific tool tip to be displayed on the general settings page
|
||||
virtual QString groupingToolTip() const { return QString(); }
|
||||
|
||||
void resetRootNode();
|
||||
|
||||
protected:
|
||||
virtual ITestParser *createTestParser() = 0;
|
||||
virtual TestTreeItem *createRootNode() = 0;
|
||||
|
||||
private:
|
||||
TestTreeItem *m_rootNode = nullptr;
|
||||
ITestParser *m_testParser = nullptr;
|
||||
bool m_active = false;
|
||||
bool m_grouping = false;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user