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:
Christian Stenger
2019-05-15 07:20:18 +02:00
parent 7ac9990fe6
commit 9c06940dc9
4 changed files with 9 additions and 1 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;