forked from qt-creator/qt-creator
Enhance test tree model and item to support gtest
Change-Id: I982edc1e390623fa9935d8f70fc29474f56ecac5 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
@@ -73,6 +73,9 @@ static QIcon testTreeIcon(TestTreeItem::Type type)
|
|||||||
QIcon(QLatin1String(":/images/func.png")),
|
QIcon(QLatin1String(":/images/func.png")),
|
||||||
QIcon(QLatin1String(":/images/data.png"))
|
QIcon(QLatin1String(":/images/data.png"))
|
||||||
};
|
};
|
||||||
|
if (type == TestTreeItem::GTestCase)
|
||||||
|
return icons[1];
|
||||||
|
|
||||||
if (int(type) >= int(sizeof icons / sizeof *icons))
|
if (int(type) >= int(sizeof icons / sizeof *icons))
|
||||||
return icons[2];
|
return icons[2];
|
||||||
return icons[type];
|
return icons[type];
|
||||||
@@ -102,6 +105,9 @@ QVariant TestTreeItem::data(int /*column*/, int role) const
|
|||||||
case TestDataFunction:
|
case TestDataFunction:
|
||||||
case TestSpecialFunction:
|
case TestSpecialFunction:
|
||||||
case TestDataTag:
|
case TestDataTag:
|
||||||
|
case GTestCase:
|
||||||
|
case GTestName:
|
||||||
|
case GTestNameDisabled:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
case TestClass:
|
case TestClass:
|
||||||
return m_name.isEmpty() ? QVariant() : checked();
|
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);
|
QStyledItemDelegate::paint(painter, opt, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,11 +40,13 @@ TestTreeModel::TestTreeModel(QObject *parent) :
|
|||||||
TreeModel(parent),
|
TreeModel(parent),
|
||||||
m_autoTestRootItem(new TestTreeItem(tr("Auto Tests"), QString(), TestTreeItem::Root)),
|
m_autoTestRootItem(new TestTreeItem(tr("Auto Tests"), QString(), TestTreeItem::Root)),
|
||||||
m_quickTestRootItem(new TestTreeItem(tr("Qt Quick 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_parser(new TestCodeParser(this)),
|
||||||
m_connectionsInitialized(false)
|
m_connectionsInitialized(false)
|
||||||
{
|
{
|
||||||
rootItem()->appendChild(m_autoTestRootItem);
|
rootItem()->appendChild(m_autoTestRootItem);
|
||||||
rootItem()->appendChild(m_quickTestRootItem);
|
rootItem()->appendChild(m_quickTestRootItem);
|
||||||
|
rootItem()->appendChild(m_googleTestRootItem);
|
||||||
|
|
||||||
connect(m_parser, &TestCodeParser::cacheCleared, this,
|
connect(m_parser, &TestCodeParser::cacheCleared, this,
|
||||||
&TestTreeModel::removeAllTestItems, Qt::QueuedConnection);
|
&TestTreeModel::removeAllTestItems, Qt::QueuedConnection);
|
||||||
@@ -170,6 +172,9 @@ Qt::ItemFlags TestTreeModel::flags(const QModelIndex &index) const
|
|||||||
case TestTreeItem::TestDataFunction:
|
case TestTreeItem::TestDataFunction:
|
||||||
case TestTreeItem::TestSpecialFunction:
|
case TestTreeItem::TestSpecialFunction:
|
||||||
case TestTreeItem::TestDataTag:
|
case TestTreeItem::TestDataTag:
|
||||||
|
case TestTreeItem::GTestCase:
|
||||||
|
case TestTreeItem::GTestName:
|
||||||
|
case TestTreeItem::GTestNameDisabled:
|
||||||
default:
|
default:
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
}
|
}
|
||||||
@@ -177,7 +182,8 @@ Qt::ItemFlags TestTreeModel::flags(const QModelIndex &index) const
|
|||||||
|
|
||||||
bool TestTreeModel::hasTests() 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
|
QList<TestConfiguration *> TestTreeModel::getAllTestCases() const
|
||||||
@@ -533,6 +539,7 @@ void TestTreeModel::removeAllTestItems()
|
|||||||
{
|
{
|
||||||
m_autoTestRootItem->removeChildren();
|
m_autoTestRootItem->removeChildren();
|
||||||
m_quickTestRootItem->removeChildren();
|
m_quickTestRootItem->removeChildren();
|
||||||
|
m_googleTestRootItem->removeChildren();
|
||||||
emit testTreeModelChanged();
|
emit testTreeModelChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,6 +565,8 @@ TestTreeItem *TestTreeModel::rootItemForType(TestTreeModel::Type type)
|
|||||||
return m_autoTestRootItem;
|
return m_autoTestRootItem;
|
||||||
case QuickTest:
|
case QuickTest:
|
||||||
return m_quickTestRootItem;
|
return m_quickTestRootItem;
|
||||||
|
case GoogleTest:
|
||||||
|
return m_googleTestRootItem;
|
||||||
}
|
}
|
||||||
QTC_ASSERT(false, return 0);
|
QTC_ASSERT(false, return 0);
|
||||||
}
|
}
|
||||||
@@ -569,6 +578,8 @@ QModelIndex TestTreeModel::rootIndexForType(TestTreeModel::Type type)
|
|||||||
return index(0, 0);
|
return index(0, 0);
|
||||||
case QuickTest:
|
case QuickTest:
|
||||||
return index(1, 0);
|
return index(1, 0);
|
||||||
|
case GoogleTest:
|
||||||
|
return index(2, 0);
|
||||||
}
|
}
|
||||||
QTC_ASSERT(false, return QModelIndex());
|
QTC_ASSERT(false, return QModelIndex());
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,8 @@ class TestTreeModel : public Utils::TreeModel
|
|||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
AutoTest,
|
AutoTest,
|
||||||
QuickTest
|
QuickTest,
|
||||||
|
GoogleTest
|
||||||
};
|
};
|
||||||
|
|
||||||
static TestTreeModel* instance();
|
static TestTreeModel* instance();
|
||||||
@@ -95,6 +96,7 @@ private:
|
|||||||
|
|
||||||
TestTreeItem *m_autoTestRootItem;
|
TestTreeItem *m_autoTestRootItem;
|
||||||
TestTreeItem *m_quickTestRootItem;
|
TestTreeItem *m_quickTestRootItem;
|
||||||
|
TestTreeItem *m_googleTestRootItem;
|
||||||
TestCodeParser *m_parser;
|
TestCodeParser *m_parser;
|
||||||
bool m_connectionsInitialized;
|
bool m_connectionsInitialized;
|
||||||
QAtomicInt m_refCounter;
|
QAtomicInt m_refCounter;
|
||||||
|
Reference in New Issue
Block a user