forked from qt-creator/qt-creator
AutoTest: Make data tags checkable
Change-Id: I9a1e8c9524a3f8beb3851646fb7b6bf7c8cac557 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -34,6 +34,13 @@
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
QtTestTreeItem::QtTestTreeItem(const QString &name, const QString &filePath, TestTreeItem::Type type)
|
||||
: TestTreeItem(name, filePath, type)
|
||||
{
|
||||
if (type == TestDataTag)
|
||||
setChecked(Qt::Checked);
|
||||
}
|
||||
|
||||
QtTestTreeItem *QtTestTreeItem::createTestItem(const TestParseResult *result)
|
||||
{
|
||||
QtTestTreeItem *item = new QtTestTreeItem(result->displayName, result->fileName,
|
||||
@@ -55,7 +62,6 @@ QVariant QtTestTreeItem::data(int column, int role) const
|
||||
case Root:
|
||||
case TestDataFunction:
|
||||
case TestSpecialFunction:
|
||||
case TestDataTag:
|
||||
return QVariant();
|
||||
default:
|
||||
return checked();
|
||||
@@ -72,6 +78,19 @@ QVariant QtTestTreeItem::data(int column, int role) const
|
||||
return TestTreeItem::data(column, role);
|
||||
}
|
||||
|
||||
Qt::ItemFlags QtTestTreeItem::flags(int column) const
|
||||
{
|
||||
static const Qt::ItemFlags defaultFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
switch (type()) {
|
||||
case TestDataTag:
|
||||
return defaultFlags | Qt::ItemIsUserCheckable;
|
||||
case TestFunctionOrSet:
|
||||
return defaultFlags | Qt::ItemIsAutoTristate | Qt::ItemIsUserCheckable;
|
||||
default:
|
||||
return TestTreeItem::flags(column);
|
||||
}
|
||||
}
|
||||
|
||||
bool QtTestTreeItem::canProvideTestConfiguration() const
|
||||
{
|
||||
switch (type()) {
|
||||
@@ -193,8 +212,17 @@ QList<TestConfiguration *> QtTestTreeItem::getSelectedTestConfigurations() const
|
||||
QStringList testCases;
|
||||
for (int grandChildRow = 0; grandChildRow < grandChildCount; ++grandChildRow) {
|
||||
const TestTreeItem *grandChild = child->childItem(grandChildRow);
|
||||
if (grandChild->checked() == Qt::Checked)
|
||||
if (grandChild->checked() == Qt::Checked) {
|
||||
testCases << grandChild->name();
|
||||
} else if (grandChild->checked() == Qt::PartiallyChecked) {
|
||||
const int dtCount = grandChild->childCount();
|
||||
const QString funcName = grandChild->name();
|
||||
for (int dtRow = 0; dtRow < dtCount; ++dtRow) {
|
||||
const TestTreeItem *dataTag = grandChild->childItem(dtRow);
|
||||
if (dataTag->checked() == Qt::Checked)
|
||||
testCases << funcName + ':' + dataTag->name();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
testConfiguration = new QtTestConfiguration();
|
||||
|
@@ -34,11 +34,12 @@ class QtTestTreeItem : public TestTreeItem
|
||||
{
|
||||
public:
|
||||
explicit QtTestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
|
||||
Type type = Root) : TestTreeItem(name, filePath, type) {}
|
||||
Type type = Root);
|
||||
|
||||
static QtTestTreeItem *createTestItem(const TestParseResult *result);
|
||||
|
||||
QVariant data(int column, int role) const override;
|
||||
Qt::ItemFlags flags(int column) const override;
|
||||
bool canProvideTestConfiguration() const override;
|
||||
bool canProvideDebugConfiguration() const override;
|
||||
TestConfiguration *testConfiguration() const override;
|
||||
|
@@ -157,16 +157,23 @@ bool TestTreeItem::modifyLineAndColumn(unsigned line, unsigned column)
|
||||
void TestTreeItem::setChecked(const Qt::CheckState checkState)
|
||||
{
|
||||
switch (m_type) {
|
||||
case TestFunctionOrSet: {
|
||||
case TestDataTag: {
|
||||
m_checked = (checkState == Qt::Unchecked ? Qt::Unchecked : Qt::Checked);
|
||||
parentItem()->revalidateCheckState();
|
||||
if (auto parent = parentItem())
|
||||
parent->revalidateCheckState();
|
||||
break;
|
||||
}
|
||||
case TestFunctionOrSet:
|
||||
case TestCase: {
|
||||
Qt::CheckState usedState = (checkState == Qt::Unchecked ? Qt::Unchecked : Qt::Checked);
|
||||
for (int row = 0, count = childCount(); row < count; ++row)
|
||||
childItem(row)->setChecked(usedState);
|
||||
m_checked = usedState;
|
||||
if (m_type == TestFunctionOrSet) {
|
||||
if (auto parent = parentItem())
|
||||
parent->revalidateCheckState();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
@@ -178,6 +185,7 @@ Qt::CheckState TestTreeItem::checked() const
|
||||
switch (m_type) {
|
||||
case TestCase:
|
||||
case TestFunctionOrSet:
|
||||
case TestDataTag:
|
||||
return m_checked;
|
||||
default:
|
||||
return Qt::Unchecked;
|
||||
@@ -278,10 +286,14 @@ bool TestTreeItem::lessThan(const TestTreeItem *other, SortMode mode) const
|
||||
|
||||
void TestTreeItem::revalidateCheckState()
|
||||
{
|
||||
if (childCount() == 0)
|
||||
const Type ttiType = type();
|
||||
if (ttiType != TestCase && ttiType != TestFunctionOrSet)
|
||||
return;
|
||||
if (childCount() == 0) // can this happen? (we're calling revalidateCS() on parentItem()
|
||||
return;
|
||||
bool foundChecked = false;
|
||||
bool foundUnchecked = false;
|
||||
bool foundPartiallyChecked = false;
|
||||
for (int row = 0, count = childCount(); row < count; ++row) {
|
||||
TestTreeItem *child = childItem(row);
|
||||
switch (child->type()) {
|
||||
@@ -292,14 +304,19 @@ void TestTreeItem::revalidateCheckState()
|
||||
break;
|
||||
}
|
||||
|
||||
foundChecked |= (child->checked() != Qt::Unchecked);
|
||||
foundChecked |= (child->checked() == Qt::Checked);
|
||||
foundUnchecked |= (child->checked() == Qt::Unchecked);
|
||||
if (foundChecked && foundUnchecked) {
|
||||
foundPartiallyChecked |= (child->checked() == Qt::PartiallyChecked);
|
||||
if (foundPartiallyChecked || (foundChecked && foundUnchecked)) {
|
||||
m_checked = Qt::PartiallyChecked;
|
||||
if (ttiType == TestFunctionOrSet)
|
||||
parentItem()->revalidateCheckState();
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_checked = (foundUnchecked ? Qt::Unchecked : Qt::Checked);
|
||||
if (ttiType == TestFunctionOrSet)
|
||||
parentItem()->revalidateCheckState();
|
||||
}
|
||||
|
||||
inline bool TestTreeItem::modifyFilePath(const QString &filePath)
|
||||
|
Reference in New Issue
Block a user