forked from qt-creator/qt-creator
AutoTest: Ensure removal of empty items if possible
Change-Id: I2cac91e56e8f22f89f88bbc82cc5f7b526500529 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -348,6 +348,12 @@ bool QuickTestTreeItem::isGroupNodeFor(const TestTreeItem *other) const
|
|||||||
return TestTreeItem::isGroupNodeFor(other);
|
return TestTreeItem::isGroupNodeFor(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QuickTestTreeItem::removeOnSweepIfEmpty() const
|
||||||
|
{
|
||||||
|
return TestTreeItem::removeOnSweepIfEmpty()
|
||||||
|
|| (type() == TestCase && name().isEmpty()); // remove pseudo item '<unnamed>'
|
||||||
|
}
|
||||||
|
|
||||||
TestTreeItem *QuickTestTreeItem::createParentGroupNode() const
|
TestTreeItem *QuickTestTreeItem::createParentGroupNode() const
|
||||||
{
|
{
|
||||||
if (filePath().isEmpty() || name().isEmpty())
|
if (filePath().isEmpty() || name().isEmpty())
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
bool modify(const TestParseResult *result) override;
|
bool modify(const TestParseResult *result) override;
|
||||||
bool lessThan(const TestTreeItem *other, SortMode mode) const override;
|
bool lessThan(const TestTreeItem *other, SortMode mode) const override;
|
||||||
bool isGroupNodeFor(const TestTreeItem *other) const override;
|
bool isGroupNodeFor(const TestTreeItem *other) const override;
|
||||||
|
bool removeOnSweepIfEmpty() const override;
|
||||||
TestTreeItem *createParentGroupNode() const override;
|
TestTreeItem *createParentGroupNode() const override;
|
||||||
QSet<QString> internalTargets() const override;
|
QSet<QString> internalTargets() const override;
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ public:
|
|||||||
void markForRemoval(bool mark);
|
void markForRemoval(bool mark);
|
||||||
void markForRemovalRecursively(bool mark);
|
void markForRemovalRecursively(bool mark);
|
||||||
virtual void markForRemovalRecursively(const QString &filePath);
|
virtual void markForRemovalRecursively(const QString &filePath);
|
||||||
|
virtual bool removeOnSweepIfEmpty() const { return m_type == GroupNode; }
|
||||||
bool markedForRemoval() const { return m_status == MarkedForRemoval; }
|
bool markedForRemoval() const { return m_status == MarkedForRemoval; }
|
||||||
bool newlyAdded() const { return m_status == NewlyAdded; }
|
bool newlyAdded() const { return m_status == NewlyAdded; }
|
||||||
TestTreeItem *parentItem() const;
|
TestTreeItem *parentItem() const;
|
||||||
|
|||||||
@@ -255,6 +255,10 @@ bool TestTreeModel::sweepChildren(TestTreeItem *item)
|
|||||||
hasChanged = true;
|
hasChanged = true;
|
||||||
} else if (child->hasChildren()) {
|
} else if (child->hasChildren()) {
|
||||||
hasChanged |= sweepChildren(child);
|
hasChanged |= sweepChildren(child);
|
||||||
|
if (!child->hasChildren() && child->removeOnSweepIfEmpty()) {
|
||||||
|
destroyItem(child);
|
||||||
|
revalidateCheckState(item);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
hasChanged |= child->newlyAdded();
|
hasChanged |= child->newlyAdded();
|
||||||
}
|
}
|
||||||
@@ -285,7 +289,7 @@ void TestTreeModel::insertItemInParent(TestTreeItem *item, TestTreeItem *root, b
|
|||||||
void TestTreeModel::revalidateCheckState(TestTreeItem *item)
|
void TestTreeModel::revalidateCheckState(TestTreeItem *item)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(item, return);
|
QTC_ASSERT(item, return);
|
||||||
QTC_ASSERT(item->hasChildren(), return);
|
|
||||||
const TestTreeItem::Type type = item->type();
|
const TestTreeItem::Type type = item->type();
|
||||||
if (type == TestTreeItem::TestSpecialFunction || type == TestTreeItem::TestDataFunction
|
if (type == TestTreeItem::TestSpecialFunction || type == TestTreeItem::TestDataFunction
|
||||||
|| type == TestTreeItem::TestDataTag) {
|
|| type == TestTreeItem::TestDataTag) {
|
||||||
|
|||||||
Reference in New Issue
Block a user