forked from qt-creator/qt-creator
AutoTest: Extract decision of adding filtered items
The old approach was working due to the fact that all test frameworks followed a fixed type scheme and tried to handle differences between the AutoTest plugin and the "real" world of the test framework internally. Generalizing this decision does no more make sense when adding an optional test suite layer. Change-Id: I4788150a8935d8e35e557df8475aa95c8ca545b4 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -540,5 +540,10 @@ TestTreeItem *GTestTreeItem::applyFilters()
|
|||||||
return filtered;
|
return filtered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GTestTreeItem::shouldBeAddedAfterFiltering() const
|
||||||
|
{
|
||||||
|
return type() == TestTreeItem::TestFunctionOrSet || childCount();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Autotest
|
} // namespace Autotest
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ public:
|
|||||||
bool isGroupNodeFor(const TestTreeItem *other) const override;
|
bool isGroupNodeFor(const TestTreeItem *other) const override;
|
||||||
bool isGroupable() const override;
|
bool isGroupable() const override;
|
||||||
TestTreeItem *applyFilters() override;
|
TestTreeItem *applyFilters() override;
|
||||||
|
bool shouldBeAddedAfterFiltering() const override;
|
||||||
private:
|
private:
|
||||||
bool modifyTestSetContent(const GTestParseResult *result);
|
bool modifyTestSetContent(const GTestParseResult *result);
|
||||||
QList<TestConfiguration *> getTestConfigurations(bool ignoreCheckState) const;
|
QList<TestConfiguration *> getTestConfigurations(bool ignoreCheckState) const;
|
||||||
|
|||||||
@@ -126,6 +126,8 @@ public:
|
|||||||
// based on (internal) filters this will be used to filter out sub items (and remove them)
|
// based on (internal) filters this will be used to filter out sub items (and remove them)
|
||||||
// returns a copy of the item that contains the filtered out children or nullptr
|
// returns a copy of the item that contains the filtered out children or nullptr
|
||||||
virtual TestTreeItem *applyFilters() { return nullptr; }
|
virtual TestTreeItem *applyFilters() { return nullptr; }
|
||||||
|
// decide whether an item should still be added to the treemodel
|
||||||
|
virtual bool shouldBeAddedAfterFiltering() const { return true; }
|
||||||
virtual QSet<QString> internalTargets() const;
|
virtual QSet<QString> internalTargets() const;
|
||||||
protected:
|
protected:
|
||||||
void copyBasicDataFrom(const TestTreeItem *other);
|
void copyBasicDataFrom(const TestTreeItem *other);
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ void TestTreeModel::syncTestFrameworks()
|
|||||||
void TestTreeModel::filterAndInsert(TestTreeItem *item, TestTreeItem *root, bool groupingEnabled)
|
void TestTreeModel::filterAndInsert(TestTreeItem *item, TestTreeItem *root, bool groupingEnabled)
|
||||||
{
|
{
|
||||||
TestTreeItem *filtered = item->applyFilters();
|
TestTreeItem *filtered = item->applyFilters();
|
||||||
if (item->type() != TestTreeItem::TestCase || item->childCount())
|
if (item->shouldBeAddedAfterFiltering())
|
||||||
insertItemInParent(item, root, groupingEnabled);
|
insertItemInParent(item, root, groupingEnabled);
|
||||||
else // might be that all children have been filtered out
|
else // might be that all children have been filtered out
|
||||||
delete item;
|
delete item;
|
||||||
|
|||||||
Reference in New Issue
Block a user