Commit 8e3d2529 authored by Christian Stenger's avatar Christian Stenger
Browse files

Enhance test tree model and item to support gtest



Change-Id: I982edc1e390623fa9935d8f70fc29474f56ecac5
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 42def5bb
......@@ -73,6 +73,9 @@ static QIcon testTreeIcon(TestTreeItem::Type type)
QIcon(QLatin1String(":/images/func.png")),
QIcon(QLatin1String(":/images/data.png"))
};
if (type == TestTreeItem::GTestCase)
return icons[1];
if (int(type) >= int(sizeof icons / sizeof *icons))
return icons[2];
return icons[type];
......@@ -102,6 +105,9 @@ QVariant TestTreeItem::data(int /*column*/, int role) const
case TestDataFunction:
case TestSpecialFunction:
case TestDataTag:
case GTestCase:
case GTestName:
case GTestNameDisabled:
return QVariant();
case TestClass:
return m_name.isEmpty() ? QVariant() : checked();
......
......@@ -64,6 +64,10 @@ void TestTreeItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
}
}
// paint disabled googletests in gray
if (index.data(TypeRole).toInt() == TestTreeItem::GTestNameDisabled)
opt.palette.setColor(QPalette::Text, QColor(0xa0, 0xa0, 0xa0));
QStyledItemDelegate::paint(painter, opt, index);
}
......
......@@ -40,11 +40,13 @@ TestTreeModel::TestTreeModel(QObject *parent) :
TreeModel(parent),
m_autoTestRootItem(new TestTreeItem(tr("Auto Tests"), QString(), TestTreeItem::Root)),
m_quickTestRootItem(new TestTreeItem(tr("Qt Quick Tests"), QString(), TestTreeItem::Root)),
m_googleTestRootItem(new TestTreeItem(tr("Google Tests"), QString(), TestTreeItem::Root)),
m_parser(new TestCodeParser(this)),
m_connectionsInitialized(false)
{
rootItem()->appendChild(m_autoTestRootItem);
rootItem()->appendChild(m_quickTestRootItem);
rootItem()->appendChild(m_googleTestRootItem);
connect(m_parser, &TestCodeParser::cacheCleared, this,
&TestTreeModel::removeAllTestItems, Qt::QueuedConnection);
......@@ -170,6 +172,9 @@ Qt::ItemFlags TestTreeModel::flags(const QModelIndex &index) const
case TestTreeItem::TestDataFunction:
case TestTreeItem::TestSpecialFunction:
case TestTreeItem::TestDataTag:
case TestTreeItem::GTestCase:
case TestTreeItem::GTestName:
case TestTreeItem::GTestNameDisabled:
default:
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
......@@ -177,7 +182,8 @@ Qt::ItemFlags TestTreeModel::flags(const QModelIndex &index) const
bool TestTreeModel::hasTests() const
{
return m_autoTestRootItem->childCount() > 0 || m_quickTestRootItem->childCount() > 0;
return m_autoTestRootItem->childCount() > 0 || m_quickTestRootItem->childCount() > 0
|| m_googleTestRootItem->childCount() > 0;
}
QList<TestConfiguration *> TestTreeModel::getAllTestCases() const
......@@ -533,6 +539,7 @@ void TestTreeModel::removeAllTestItems()
{
m_autoTestRootItem->removeChildren();
m_quickTestRootItem->removeChildren();
m_googleTestRootItem->removeChildren();
emit testTreeModelChanged();
}
......@@ -558,6 +565,8 @@ TestTreeItem *TestTreeModel::rootItemForType(TestTreeModel::Type type)
return m_autoTestRootItem;
case QuickTest:
return m_quickTestRootItem;
case GoogleTest:
return m_googleTestRootItem;
}
QTC_ASSERT(false, return 0);
}
......@@ -569,6 +578,8 @@ QModelIndex TestTreeModel::rootIndexForType(TestTreeModel::Type type)
return index(0, 0);
case QuickTest:
return index(1, 0);
case GoogleTest:
return index(2, 0);
}
QTC_ASSERT(false, return QModelIndex());
}
......
......@@ -42,7 +42,8 @@ class TestTreeModel : public Utils::TreeModel
public:
enum Type {
AutoTest,
QuickTest
QuickTest,
GoogleTest
};
static TestTreeModel* instance();
......@@ -95,6 +96,7 @@ private:
TestTreeItem *m_autoTestRootItem;
TestTreeItem *m_quickTestRootItem;
TestTreeItem *m_googleTestRootItem;
TestCodeParser *m_parser;
bool m_connectionsInitialized;
QAtomicInt m_refCounter;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment