forked from qt-creator/qt-creator
Make disabled a state instead of separate type
State will be enhanced later on to provide better support for gtest. Change-Id: I3f3f6b986d6a25ebd36fe44330c792608844b35c Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
This commit is contained in:
committed by
Niels Weber
parent
00f93b95a7
commit
eca35ce868
@@ -434,6 +434,7 @@ static TestTreeItem *constructTestTreeItem(const QString &fileName,
|
|||||||
locationAndType.m_type);
|
locationAndType.m_type);
|
||||||
treeItemChild->setLine(locationAndType.m_line);
|
treeItemChild->setLine(locationAndType.m_line);
|
||||||
treeItemChild->setColumn(locationAndType.m_column);
|
treeItemChild->setColumn(locationAndType.m_column);
|
||||||
|
treeItemChild->setState(locationAndType.m_state);
|
||||||
|
|
||||||
// check for data tags and if there are any for this function add them
|
// check for data tags and if there are any for this function add them
|
||||||
const QString qualifiedFunctionName = testCaseName + QLatin1String("::") + functionName;
|
const QString qualifiedFunctionName = testCaseName + QLatin1String("::") + functionName;
|
||||||
@@ -445,6 +446,7 @@ static TestTreeItem *constructTestTreeItem(const QString &fileName,
|
|||||||
tagLocation.m_type);
|
tagLocation.m_type);
|
||||||
tagTreeItem->setLine(tagLocation.m_line);
|
tagTreeItem->setLine(tagLocation.m_line);
|
||||||
tagTreeItem->setColumn(tagLocation.m_column);
|
tagTreeItem->setColumn(tagLocation.m_column);
|
||||||
|
tagTreeItem->setState(tagLocation.m_state);
|
||||||
treeItemChild->appendChild(tagTreeItem);
|
treeItemChild->appendChild(tagTreeItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -464,6 +466,7 @@ static TestTreeItem *constructGTestTreeItem(const QString &filePath, const GTest
|
|||||||
foreach (const TestCodeLocationAndType &locationAndType, testSets) {
|
foreach (const TestCodeLocationAndType &locationAndType, testSets) {
|
||||||
TestTreeItem *treeItemChild = new TestTreeItem(locationAndType.m_name, filePath,
|
TestTreeItem *treeItemChild = new TestTreeItem(locationAndType.m_name, filePath,
|
||||||
locationAndType.m_type);
|
locationAndType.m_type);
|
||||||
|
treeItemChild->setState(locationAndType.m_state);
|
||||||
treeItemChild->setLine(locationAndType.m_line);
|
treeItemChild->setLine(locationAndType.m_line);
|
||||||
treeItemChild->setColumn(locationAndType.m_column);
|
treeItemChild->setColumn(locationAndType.m_column);
|
||||||
treeItemChild->setMainFile(proFile);
|
treeItemChild->setMainFile(proFile);
|
||||||
@@ -1032,7 +1035,7 @@ void TestCodeParser::updateGTests(const CPlusPlus::Document::Ptr &doc,
|
|||||||
info.setProFile(proFile);
|
info.setProFile(proFile);
|
||||||
foreach (const TestCodeLocationAndType &testSet, tests.value(testSpec)) {
|
foreach (const TestCodeLocationAndType &testSet, tests.value(testSpec)) {
|
||||||
GTestInfo gtestInfo(testSpec.testCaseName, testSet.m_name, fileName);
|
GTestInfo gtestInfo(testSpec.testCaseName, testSet.m_name, fileName);
|
||||||
if (testSet.m_type == TestTreeItem::GTestNameDisabled)
|
if (testSet.m_state & TestTreeItem::Disabled)
|
||||||
gtestInfo.setEnabled(false);
|
gtestInfo.setEnabled(false);
|
||||||
m_gtestDocList.append(gtestInfo);
|
m_gtestDocList.append(gtestInfo);
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,8 @@ TestTreeItem::TestTreeItem(const QString &name, const QString &filePath, Type ty
|
|||||||
m_name(name),
|
m_name(name),
|
||||||
m_filePath(filePath),
|
m_filePath(filePath),
|
||||||
m_type(type),
|
m_type(type),
|
||||||
m_line(0)
|
m_line(0),
|
||||||
|
m_state(Enabled)
|
||||||
{
|
{
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
case TestClass:
|
case TestClass:
|
||||||
@@ -42,7 +43,6 @@ TestTreeItem::TestTreeItem(const QString &name, const QString &filePath, Type ty
|
|||||||
case GTestCase:
|
case GTestCase:
|
||||||
case GTestCaseParameterized:
|
case GTestCaseParameterized:
|
||||||
case GTestName:
|
case GTestName:
|
||||||
case GTestNameDisabled:
|
|
||||||
m_checked = Qt::Checked;
|
m_checked = Qt::Checked;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -63,7 +63,8 @@ TestTreeItem::TestTreeItem(const TestTreeItem &other)
|
|||||||
m_type(other.m_type),
|
m_type(other.m_type),
|
||||||
m_line(other.m_line),
|
m_line(other.m_line),
|
||||||
m_column(other.m_column),
|
m_column(other.m_column),
|
||||||
m_mainFile(other.m_mainFile)
|
m_mainFile(other.m_mainFile),
|
||||||
|
m_state(other.m_state)
|
||||||
{
|
{
|
||||||
for (int row = 0, count = other.childCount(); row < count; ++row)
|
for (int row = 0, count = other.childCount(); row < count; ++row)
|
||||||
appendChild(new TestTreeItem(*childItem(row)));
|
appendChild(new TestTreeItem(*childItem(row)));
|
||||||
@@ -118,7 +119,6 @@ QVariant TestTreeItem::data(int /*column*/, int role) const
|
|||||||
return m_name.isEmpty() ? QVariant() : checked();
|
return m_name.isEmpty() ? QVariant() : checked();
|
||||||
case TestFunction:
|
case TestFunction:
|
||||||
case GTestName:
|
case GTestName:
|
||||||
case GTestNameDisabled:
|
|
||||||
if (parentItem() && parentItem()->name().isEmpty())
|
if (parentItem() && parentItem()->name().isEmpty())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
return checked();
|
return checked();
|
||||||
@@ -144,6 +144,8 @@ QVariant TestTreeItem::data(int /*column*/, int role) const
|
|||||||
}
|
}
|
||||||
case TypeRole:
|
case TypeRole:
|
||||||
return m_type;
|
return m_type;
|
||||||
|
case StateRole:
|
||||||
|
return (int)m_state;
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@@ -181,6 +183,10 @@ bool TestTreeItem::modifyContent(const TestTreeItem *modified)
|
|||||||
m_type = modified->m_type;
|
m_type = modified->m_type;
|
||||||
hasBeenModified = true;
|
hasBeenModified = true;
|
||||||
}
|
}
|
||||||
|
if (m_state != modified->m_state) {
|
||||||
|
m_state = modified->m_state;
|
||||||
|
hasBeenModified = true;
|
||||||
|
}
|
||||||
return hasBeenModified;
|
return hasBeenModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,8 +194,7 @@ void TestTreeItem::setChecked(const Qt::CheckState checkState)
|
|||||||
{
|
{
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
case TestFunction:
|
case TestFunction:
|
||||||
case GTestName:
|
case GTestName: {
|
||||||
case GTestNameDisabled: {
|
|
||||||
m_checked = (checkState == Qt::Unchecked ? Qt::Unchecked : Qt::Checked);
|
m_checked = (checkState == Qt::Unchecked ? Qt::Unchecked : Qt::Checked);
|
||||||
parentItem()->revalidateCheckState();
|
parentItem()->revalidateCheckState();
|
||||||
break;
|
break;
|
||||||
@@ -215,7 +220,6 @@ Qt::CheckState TestTreeItem::checked() const
|
|||||||
case GTestCase:
|
case GTestCase:
|
||||||
case GTestCaseParameterized:
|
case GTestCaseParameterized:
|
||||||
case GTestName:
|
case GTestName:
|
||||||
case GTestNameDisabled:
|
|
||||||
return m_checked;
|
return m_checked;
|
||||||
case TestDataFunction:
|
case TestDataFunction:
|
||||||
case TestSpecialFunction:
|
case TestSpecialFunction:
|
||||||
|
@@ -30,7 +30,8 @@ namespace {
|
|||||||
enum ItemRole {
|
enum ItemRole {
|
||||||
LinkRole = Qt::UserRole + 2, // can be removed if AnnotationRole comes back
|
LinkRole = Qt::UserRole + 2, // can be removed if AnnotationRole comes back
|
||||||
ItalicRole, // used only inside the delegate
|
ItalicRole, // used only inside the delegate
|
||||||
TypeRole
|
TypeRole,
|
||||||
|
StateRole
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +42,8 @@ class TestTreeItem : public Utils::TreeItem
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type
|
||||||
|
{
|
||||||
Root,
|
Root,
|
||||||
TestClass,
|
TestClass,
|
||||||
TestFunction,
|
TestFunction,
|
||||||
@@ -50,10 +52,18 @@ public:
|
|||||||
TestSpecialFunction,
|
TestSpecialFunction,
|
||||||
GTestCase,
|
GTestCase,
|
||||||
GTestCaseParameterized,
|
GTestCaseParameterized,
|
||||||
GTestName,
|
GTestName
|
||||||
GTestNameDisabled
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum TestState
|
||||||
|
{
|
||||||
|
Enabled = 0x00,
|
||||||
|
Disabled = 0x01,
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_FLAGS(TestState)
|
||||||
|
Q_DECLARE_FLAGS(TestStates, TestState)
|
||||||
|
|
||||||
TestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
|
TestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
|
||||||
Type type = Root);
|
Type type = Root);
|
||||||
virtual ~TestTreeItem();
|
virtual ~TestTreeItem();
|
||||||
@@ -74,6 +84,8 @@ public:
|
|||||||
void setChecked(const Qt::CheckState checked);
|
void setChecked(const Qt::CheckState checked);
|
||||||
Qt::CheckState checked() const;
|
Qt::CheckState checked() const;
|
||||||
Type type() const { return m_type; }
|
Type type() const { return m_type; }
|
||||||
|
void setState(TestStates states) { m_state = states; }
|
||||||
|
TestStates state() const { return m_state; }
|
||||||
QList<QString> getChildNames() const;
|
QList<QString> getChildNames() const;
|
||||||
TestTreeItem *parentItem() const;
|
TestTreeItem *parentItem() const;
|
||||||
TestTreeItem *childItem(int row) const;
|
TestTreeItem *childItem(int row) const;
|
||||||
@@ -88,6 +100,7 @@ private:
|
|||||||
unsigned m_line;
|
unsigned m_line;
|
||||||
unsigned m_column;
|
unsigned m_column;
|
||||||
QString m_mainFile; // main for Quick tests, project file for gtest
|
QString m_mainFile; // main for Quick tests, project file for gtest
|
||||||
|
TestStates m_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TestCodeLocationAndType {
|
struct TestCodeLocationAndType {
|
||||||
@@ -95,6 +108,7 @@ struct TestCodeLocationAndType {
|
|||||||
unsigned m_line;
|
unsigned m_line;
|
||||||
unsigned m_column;
|
unsigned m_column;
|
||||||
TestTreeItem::Type m_type;
|
TestTreeItem::Type m_type;
|
||||||
|
TestTreeItem::TestStates m_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QVector<TestCodeLocationAndType> TestCodeLocationList;
|
typedef QVector<TestCodeLocationAndType> TestCodeLocationList;
|
||||||
|
@@ -65,7 +65,7 @@ void TestTreeItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
}
|
}
|
||||||
|
|
||||||
// paint disabled googletests in gray
|
// paint disabled googletests in gray
|
||||||
if (index.data(TypeRole).toInt() == TestTreeItem::GTestNameDisabled)
|
if (index.data(StateRole).toInt() & TestTreeItem::Disabled)
|
||||||
opt.palette.setColor(QPalette::Text, QColor(0xa0, 0xa0, 0xa0));
|
opt.palette.setColor(QPalette::Text, QColor(0xa0, 0xa0, 0xa0));
|
||||||
|
|
||||||
QStyledItemDelegate::paint(painter, opt, index);
|
QStyledItemDelegate::paint(painter, opt, index);
|
||||||
|
@@ -146,7 +146,6 @@ bool TestTreeModel::setData(const QModelIndex &index, const QVariant &value, int
|
|||||||
break;
|
break;
|
||||||
case TestTreeItem::TestFunction:
|
case TestTreeItem::TestFunction:
|
||||||
case TestTreeItem::GTestName:
|
case TestTreeItem::GTestName:
|
||||||
case TestTreeItem::GTestNameDisabled:
|
|
||||||
emit dataChanged(index.parent(), index.parent());
|
emit dataChanged(index.parent(), index.parent());
|
||||||
break;
|
break;
|
||||||
default: // avoid warning regarding unhandled enum member
|
default: // avoid warning regarding unhandled enum member
|
||||||
@@ -173,7 +172,6 @@ Qt::ItemFlags TestTreeModel::flags(const QModelIndex &index) const
|
|||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsTristate | Qt::ItemIsUserCheckable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsTristate | Qt::ItemIsUserCheckable;
|
||||||
case TestTreeItem::TestFunction:
|
case TestTreeItem::TestFunction:
|
||||||
case TestTreeItem::GTestName:
|
case TestTreeItem::GTestName:
|
||||||
case TestTreeItem::GTestNameDisabled:
|
|
||||||
if (item->parentItem()->name().isEmpty())
|
if (item->parentItem()->name().isEmpty())
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
|
||||||
|
@@ -89,6 +89,7 @@ bool TestVisitor::visit(CPlusPlus::Class *symbol)
|
|||||||
locationAndType.m_type = TestTreeItem::TestDataFunction;
|
locationAndType.m_type = TestTreeItem::TestDataFunction;
|
||||||
else
|
else
|
||||||
locationAndType.m_type = TestTreeItem::TestFunction;
|
locationAndType.m_type = TestTreeItem::TestFunction;
|
||||||
|
locationAndType.m_state = TestTreeItem::Enabled;
|
||||||
m_privSlots.insert(name, locationAndType);
|
m_privSlots.insert(name, locationAndType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -218,6 +219,7 @@ bool TestDataFunctionVisitor::visit(CPlusPlus::CallAST *ast)
|
|||||||
locationAndType.m_column = column - 1;
|
locationAndType.m_column = column - 1;
|
||||||
locationAndType.m_line = line;
|
locationAndType.m_line = line;
|
||||||
locationAndType.m_type = TestTreeItem::TestDataTag;
|
locationAndType.m_type = TestTreeItem::TestDataTag;
|
||||||
|
locationAndType.m_state = TestTreeItem::Enabled;
|
||||||
m_currentTags.append(locationAndType);
|
m_currentTags.append(locationAndType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -329,6 +331,7 @@ bool TestQmlVisitor::visit(QmlJS::AST::FunctionDeclaration *ast)
|
|||||||
else
|
else
|
||||||
locationAndType.m_type = TestTreeItem::TestFunction;
|
locationAndType.m_type = TestTreeItem::TestFunction;
|
||||||
|
|
||||||
|
locationAndType.m_state = TestTreeItem::Enabled;
|
||||||
m_testFunctions.insert(name.toString(), locationAndType);
|
m_testFunctions.insert(name.toString(), locationAndType);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -378,8 +381,8 @@ bool GTestVisitor::visit(CPlusPlus::FunctionDefinitionAST *ast)
|
|||||||
locationAndType.m_name = disabled ? testName.mid(9) : testName;
|
locationAndType.m_name = disabled ? testName.mid(9) : testName;
|
||||||
locationAndType.m_line = line;
|
locationAndType.m_line = line;
|
||||||
locationAndType.m_column = column - 1;
|
locationAndType.m_column = column - 1;
|
||||||
locationAndType.m_type = disabled ? TestTreeItem::GTestNameDisabled
|
locationAndType.m_type = TestTreeItem::GTestName;
|
||||||
: TestTreeItem::GTestName;
|
locationAndType.m_state = disabled ? TestTreeItem::Disabled : TestTreeItem::Enabled;
|
||||||
GTestCaseSpec spec;
|
GTestCaseSpec spec;
|
||||||
spec.testCaseName = testCaseName;
|
spec.testCaseName = testCaseName;
|
||||||
spec.parameterized = TestUtils::isGTestParameterized(prettyName);
|
spec.parameterized = TestUtils::isGTestParameterized(prettyName);
|
||||||
|
Reference in New Issue
Block a user