forked from qt-creator/qt-creator
AutoTest: Unify TestTreeItem::modify*() functions
Change-Id: Ia234fb6a8a8466c039060f6f00b1a5e3dea2af9e Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -239,7 +239,7 @@ bool GTestTreeItem::modify(const TestParseResult *result)
|
||||
|
||||
bool GTestTreeItem::modifyTestSetContent(const GTestParseResult *result)
|
||||
{
|
||||
bool hasBeenModified = modifyLineAndColumn(result->line, result->column);
|
||||
bool hasBeenModified = modifyLineAndColumn(result);
|
||||
GTestTreeItem::TestStates states = result->disabled ? GTestTreeItem::Disabled
|
||||
: GTestTreeItem::Enabled;
|
||||
if (m_state != states) {
|
||||
|
||||
@@ -62,13 +62,13 @@ public:
|
||||
void setStates(TestStates states) { m_state = states; }
|
||||
void setState(TestState state) { m_state |= state; }
|
||||
TestStates state() const { return m_state; }
|
||||
bool modifyTestSetContent(const GTestParseResult *result);
|
||||
TestTreeItem *findChildByNameStateAndFile(const QString &name,
|
||||
GTestTreeItem::TestStates state,
|
||||
const QString &proFile) const;
|
||||
QString nameSuffix() const;
|
||||
|
||||
private:
|
||||
bool modifyTestSetContent(const GTestParseResult *result);
|
||||
GTestTreeItem::TestStates m_state;
|
||||
};
|
||||
|
||||
|
||||
@@ -243,13 +243,13 @@ bool QtTestTreeItem::modify(const TestParseResult *result)
|
||||
|
||||
switch (type()) {
|
||||
case TestCase:
|
||||
return modifyTestCaseContent(result->name, result->line, result->column);
|
||||
return modifyTestCaseContent(result);
|
||||
case TestFunctionOrSet:
|
||||
case TestDataFunction:
|
||||
case TestSpecialFunction:
|
||||
return modifyTestFunctionContent(result);
|
||||
case TestDataTag:
|
||||
return modifyDataTagContent(result->name, result->fileName, result->line, result->column);
|
||||
return modifyDataTagContent(result);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -285,12 +285,11 @@ bool QuickTestTreeItem::modify(const TestParseResult *result)
|
||||
|
||||
switch (type()) {
|
||||
case TestCase:
|
||||
return result->name.isEmpty() ? false : modifyTestCaseContent(result->name, result->line,
|
||||
result->column);
|
||||
return result->name.isEmpty() ? false : modifyTestCaseContent(result);
|
||||
case TestFunctionOrSet:
|
||||
case TestDataFunction:
|
||||
case TestSpecialFunction:
|
||||
return name().isEmpty() ? modifyLineAndColumn(result->line, result->column)
|
||||
return name().isEmpty() ? modifyLineAndColumn(result)
|
||||
: modifyTestFunctionContent(result);
|
||||
default:
|
||||
return false;
|
||||
|
||||
@@ -115,39 +115,37 @@ Qt::ItemFlags TestTreeItem::flags(int /*column*/) const
|
||||
}
|
||||
}
|
||||
|
||||
bool TestTreeItem::modifyTestCaseContent(const QString &name, unsigned line, unsigned column)
|
||||
bool TestTreeItem::modifyTestCaseContent(const TestParseResult *result)
|
||||
{
|
||||
bool hasBeenModified = modifyName(name);
|
||||
hasBeenModified |= modifyLineAndColumn(line, column);
|
||||
bool hasBeenModified = modifyName(result->name);
|
||||
hasBeenModified |= modifyLineAndColumn(result);
|
||||
return hasBeenModified;
|
||||
}
|
||||
|
||||
bool TestTreeItem::modifyTestFunctionContent(const TestParseResult *result)
|
||||
{
|
||||
bool hasBeenModified = modifyFilePath(result->fileName);
|
||||
hasBeenModified |= modifyLineAndColumn(result->line, result->column);
|
||||
hasBeenModified |= modifyLineAndColumn(result);
|
||||
return hasBeenModified;
|
||||
}
|
||||
|
||||
// TODO pass TestParseResult * to all modifyXYZ() OR remove completely if possible
|
||||
bool TestTreeItem::modifyDataTagContent(const QString &name, const QString &fileName,
|
||||
unsigned line, unsigned column)
|
||||
bool TestTreeItem::modifyDataTagContent(const TestParseResult *result)
|
||||
{
|
||||
bool hasBeenModified = modifyFilePath(fileName);
|
||||
hasBeenModified |= modifyName(name);
|
||||
hasBeenModified |= modifyLineAndColumn(line, column);
|
||||
|
||||
bool hasBeenModified = modifyTestFunctionContent(result);
|
||||
hasBeenModified |= modifyName(result->name);
|
||||
return hasBeenModified;
|
||||
}
|
||||
|
||||
bool TestTreeItem::modifyLineAndColumn(unsigned line, unsigned column)
|
||||
bool TestTreeItem::modifyLineAndColumn(const TestParseResult *result)
|
||||
{
|
||||
bool hasBeenModified = false;
|
||||
if (m_line != line) {
|
||||
m_line = line;
|
||||
if (m_line != result->line) {
|
||||
m_line = result->line;
|
||||
hasBeenModified = true;
|
||||
}
|
||||
if (m_column != column) {
|
||||
m_column = column;
|
||||
if (m_column != result->column) {
|
||||
m_column = result->column;
|
||||
hasBeenModified = true;
|
||||
}
|
||||
return hasBeenModified;
|
||||
|
||||
@@ -70,11 +70,10 @@ public:
|
||||
virtual QVariant data(int column, int role) const override;
|
||||
virtual bool setData(int column, const QVariant &data, int role) override;
|
||||
virtual Qt::ItemFlags flags(int column) const override;
|
||||
bool modifyTestCaseContent(const QString &name, unsigned line, unsigned column);
|
||||
bool modifyTestCaseContent(const TestParseResult *result);
|
||||
bool modifyTestFunctionContent(const TestParseResult *result);
|
||||
bool modifyDataTagContent(const QString &name, const QString &fileName, unsigned line,
|
||||
unsigned column);
|
||||
bool modifyLineAndColumn(unsigned line, unsigned column);
|
||||
bool modifyDataTagContent(const TestParseResult *result);
|
||||
bool modifyLineAndColumn(const TestParseResult *result);
|
||||
|
||||
const QString name() const { return m_name; }
|
||||
void setName(const QString &name) { m_name = name; }
|
||||
@@ -112,12 +111,12 @@ public:
|
||||
virtual bool modify(const TestParseResult *result) = 0;
|
||||
|
||||
protected:
|
||||
bool modifyFilePath(const QString &filePath);
|
||||
typedef std::function<bool(const TestTreeItem *)> CompareFunction;
|
||||
TestTreeItem *findChildBy(CompareFunction compare) const;
|
||||
|
||||
private:
|
||||
void revalidateCheckState();
|
||||
bool modifyFilePath(const QString &filePath);
|
||||
bool modifyName(const QString &name);
|
||||
|
||||
enum Status
|
||||
|
||||
Reference in New Issue
Block a user