AutoTest: Improve type safety in TestTreeItem

Ensures that the static_cast<>() in framework() always succeeds.

Change-Id: I6aff0cf12a565bd6f9791c67979698729d7143e5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Bernhard Beschow
2021-01-29 19:32:39 +01:00
parent ed6083b521
commit 0e0c2ca91c
8 changed files with 14 additions and 14 deletions

View File

@@ -48,11 +48,11 @@ public:
Q_FLAGS(TestState)
Q_DECLARE_FLAGS(TestStates, TestState)
explicit BoostTestTreeItem(ITestBase *base,
explicit BoostTestTreeItem(ITestFramework *framework,
const QString &name = QString(),
const QString &filePath = QString(),
Type type = Root)
: TestTreeItem(base, name, filePath, type)
: TestTreeItem(framework, name, filePath, type)
{}
public:

View File

@@ -41,9 +41,9 @@ public:
Q_FLAGS(TestState)
Q_DECLARE_FLAGS(TestStates, TestState)
explicit CatchTreeItem(ITestBase *testBase, const QString &name = QString(),
explicit CatchTreeItem(ITestFramework *testFramework, const QString &name = QString(),
const QString &filePath = QString(), Type type = Root)
: TestTreeItem(testBase, name, filePath, type) {}
: TestTreeItem(testFramework, name, filePath, type) {}
void setStates(CatchTreeItem::TestStates state) { m_state = state; }
CatchTreeItem::TestStates states() const { return m_state; }

View File

@@ -46,11 +46,11 @@ public:
Q_FLAGS(TestState)
Q_DECLARE_FLAGS(TestStates, TestState)
explicit GTestTreeItem(ITestBase *testBase,
explicit GTestTreeItem(ITestFramework *testFramework,
const QString &name = QString(),
const QString &filePath = QString(),
Type type = Root)
: TestTreeItem(testBase, name, filePath, type), m_state(Enabled)
: TestTreeItem(testFramework, name, filePath, type), m_state(Enabled)
{}
TestTreeItem *copyWithoutChildren() override;

View File

@@ -34,9 +34,9 @@
namespace Autotest {
namespace Internal {
QtTestTreeItem::QtTestTreeItem(ITestBase *testBase, const QString &name,
QtTestTreeItem::QtTestTreeItem(ITestFramework *testFramework, const QString &name,
const QString &filePath, TestTreeItem::Type type)
: TestTreeItem(testBase, name, filePath, type)
: TestTreeItem(testFramework, name, filePath, type)
{
if (type == TestDataTag)
setData(0, Qt::Checked, Qt::CheckStateRole);

View File

@@ -33,7 +33,7 @@ namespace Internal {
class QtTestTreeItem : public TestTreeItem
{
public:
explicit QtTestTreeItem(ITestBase *framework, const QString &name = QString(),
explicit QtTestTreeItem(ITestFramework *framework, const QString &name = QString(),
const QString &filePath = QString(), Type type = Root);
TestTreeItem *copyWithoutChildren() override;

View File

@@ -33,11 +33,11 @@ namespace Internal {
class QuickTestTreeItem : public TestTreeItem
{
public:
explicit QuickTestTreeItem(ITestBase *testBase,
explicit QuickTestTreeItem(ITestFramework *testFramework,
const QString &name = QString(),
const QString &filePath = QString(),
Type type = Root)
: TestTreeItem(testBase, name, filePath, type)
: TestTreeItem(testFramework, name, filePath, type)
{}
TestTreeItem *copyWithoutChildren() override;

View File

@@ -164,9 +164,9 @@ ITestConfiguration *ITestTreeItem::asConfiguration(TestRunMode mode) const
/****************************** TestTreeItem ********************************************/
TestTreeItem::TestTreeItem(ITestBase *testBase, const QString &name,
TestTreeItem::TestTreeItem(ITestFramework *testFramework, const QString &name,
const QString &filePath, Type type)
: ITestTreeItem(testBase, name, filePath, type)
: ITestTreeItem(testFramework, name, filePath, type)
{
switch (type) {
case Root:

View File

@@ -120,7 +120,7 @@ private:
class TestTreeItem : public ITestTreeItem
{
public:
explicit TestTreeItem(ITestBase *testBase,
explicit TestTreeItem(ITestFramework *testFramework,
const QString &name = QString(),
const QString &filePath = QString(),
Type type = Root);