forked from qt-creator/qt-creator
AutoTest: Remove not needed code
As this functionality had been simplified GTest* classes had been ignored. Continue the simplification and finally remove now useless code and file. Change-Id: I89170cd5f05bb93bf30a05fdbf5370012bc9741a Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -59,7 +59,6 @@ HEADERS += \
|
||||
testcodeparser.h \
|
||||
autotestplugin.h \
|
||||
autotest_global.h \
|
||||
autotest_utils.h \
|
||||
autotestconstants.h \
|
||||
testrunner.h \
|
||||
testconfiguration.h \
|
||||
|
||||
@@ -33,7 +33,6 @@ QtcPlugin {
|
||||
"autotest.qrc",
|
||||
"autotesticons.h",
|
||||
"autotest_global.h",
|
||||
"autotest_utils.h",
|
||||
"autotestconstants.h",
|
||||
"autotestplugin.cpp",
|
||||
"autotestplugin.h",
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <cpptools/projectpart.h>
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
class TestUtils
|
||||
{
|
||||
public:
|
||||
static QString getCMakeDisplayNameIfNecessary(const QString &filePath, const QString &proFile)
|
||||
{
|
||||
static const QString CMAKE_LISTS("CMakeLists.txt");
|
||||
if (!proFile.endsWith(CMAKE_LISTS))
|
||||
return QString();
|
||||
|
||||
const QList<CppTools::ProjectPart::Ptr> &projectParts
|
||||
= CppTools::CppModelManager::instance()->projectPart(filePath);
|
||||
if (projectParts.size())
|
||||
return projectParts.first()->displayName;
|
||||
|
||||
return QString();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
@@ -27,7 +27,9 @@
|
||||
#include "gtesttreeitem.h"
|
||||
#include "gtestvisitors.h"
|
||||
#include "gtest_utils.h"
|
||||
#include "../autotest_utils.h"
|
||||
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <cpptools/projectpart.h>
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "gtesttreeitem.h"
|
||||
#include "gtestconfiguration.h"
|
||||
#include "gtestparser.h"
|
||||
#include "../autotest_utils.h"
|
||||
|
||||
#include <projectexplorer/session.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -116,34 +115,6 @@ TestConfiguration *GTestTreeItem::debugConfiguration() const
|
||||
return config;
|
||||
}
|
||||
|
||||
// used as key inside getAllTestCases()/getSelectedTestCases() for Google Tests
|
||||
class ProFileWithDisplayName
|
||||
{
|
||||
public:
|
||||
ProFileWithDisplayName(const QString &file, const QString &name)
|
||||
: proFile(file), displayName(name) {}
|
||||
QString proFile;
|
||||
QString displayName;
|
||||
|
||||
bool operator==(const ProFileWithDisplayName &rhs) const
|
||||
{
|
||||
return proFile == rhs.proFile && displayName == rhs.displayName;
|
||||
}
|
||||
};
|
||||
|
||||
// needed as ProFileWithDisplayName is used as key inside a QHash
|
||||
bool operator<(const ProFileWithDisplayName &lhs, const ProFileWithDisplayName &rhs)
|
||||
{
|
||||
return lhs.proFile == rhs.proFile ? lhs.displayName < rhs.displayName
|
||||
: lhs.proFile < rhs.proFile;
|
||||
}
|
||||
|
||||
// needed as ProFileWithDisplayName is used as a key inside a QHash
|
||||
uint qHash(const ProFileWithDisplayName &lhs)
|
||||
{
|
||||
return ::qHash(lhs.proFile) ^ ::qHash(lhs.displayName);
|
||||
}
|
||||
|
||||
QList<TestConfiguration *> GTestTreeItem::getAllTestConfigurations() const
|
||||
{
|
||||
QList<TestConfiguration *> result;
|
||||
@@ -152,28 +123,24 @@ QList<TestConfiguration *> GTestTreeItem::getAllTestConfigurations() const
|
||||
if (!project || type() != Root)
|
||||
return result;
|
||||
|
||||
QHash<ProFileWithDisplayName, int> proFilesWithTestSets;
|
||||
QHash<QString, int> proFilesWithTestSets;
|
||||
for (int row = 0, count = childCount(); row < count; ++row) {
|
||||
const GTestTreeItem *child = static_cast<const GTestTreeItem *>(childItem(row));
|
||||
|
||||
const int grandChildCount = child->childCount();
|
||||
for (int grandChildRow = 0; grandChildRow < grandChildCount; ++grandChildRow) {
|
||||
const TestTreeItem *grandChild = child->childItem(grandChildRow);
|
||||
ProFileWithDisplayName key(grandChild->proFile(),
|
||||
TestUtils::getCMakeDisplayNameIfNecessary(grandChild->filePath(),
|
||||
grandChild->proFile()));
|
||||
|
||||
const QString &key = grandChild->proFile();
|
||||
proFilesWithTestSets.insert(key, proFilesWithTestSets[key] + 1);
|
||||
}
|
||||
}
|
||||
|
||||
QHash<ProFileWithDisplayName, int>::ConstIterator it = proFilesWithTestSets.begin();
|
||||
QHash<ProFileWithDisplayName, int>::ConstIterator end = proFilesWithTestSets.end();
|
||||
QHash<QString, int>::ConstIterator it = proFilesWithTestSets.begin();
|
||||
QHash<QString, int>::ConstIterator end = proFilesWithTestSets.end();
|
||||
for ( ; it != end; ++it) {
|
||||
const ProFileWithDisplayName &key = it.key();
|
||||
GTestConfiguration *tc = new GTestConfiguration;
|
||||
tc->setTestCaseCount(it.value());
|
||||
tc->setProjectFile(key.proFile);
|
||||
tc->setProjectFile(it.key());
|
||||
tc->setProject(project);
|
||||
result << tc;
|
||||
}
|
||||
@@ -187,13 +154,6 @@ struct TestCases
|
||||
int additionalTestCaseCount = 0;
|
||||
};
|
||||
|
||||
static const ProFileWithDisplayName createProfile(const TestTreeItem *item)
|
||||
{
|
||||
return ProFileWithDisplayName(
|
||||
item->proFile(),
|
||||
TestUtils::getCMakeDisplayNameIfNecessary(item->filePath(), item->proFile()));
|
||||
}
|
||||
|
||||
QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const
|
||||
{
|
||||
QList<TestConfiguration *> result;
|
||||
@@ -201,7 +161,7 @@ QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const
|
||||
if (!project || type() != Root)
|
||||
return result;
|
||||
|
||||
QHash<ProFileWithDisplayName, TestCases> proFilesWithCheckedTestSets;
|
||||
QHash<QString, TestCases> proFilesWithCheckedTestSets;
|
||||
for (int row = 0, count = childCount(); row < count; ++row) {
|
||||
const GTestTreeItem *child = static_cast<const GTestTreeItem *>(childItem(row));
|
||||
|
||||
@@ -212,7 +172,7 @@ QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const
|
||||
case Qt::Unchecked:
|
||||
continue;
|
||||
case Qt::Checked: {
|
||||
auto &testCases = proFilesWithCheckedTestSets[createProfile(child->childItem(0))];
|
||||
auto &testCases = proFilesWithCheckedTestSets[child->childItem(0)->proFile()];
|
||||
testCases.filters.append(gtestFilter(child->state()).arg(child->name()).arg('*'));
|
||||
testCases.additionalTestCaseCount += grandChildCount - 1;
|
||||
break;
|
||||
@@ -221,7 +181,7 @@ QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const
|
||||
for (int grandChildRow = 0; grandChildRow < grandChildCount; ++grandChildRow) {
|
||||
const TestTreeItem *grandChild = child->childItem(grandChildRow);
|
||||
if (grandChild->checked() == Qt::Checked) {
|
||||
proFilesWithCheckedTestSets[createProfile(grandChild)].filters.append(
|
||||
proFilesWithCheckedTestSets[grandChild->proFile()].filters.append(
|
||||
gtestFilter(child->state()).arg(child->name()).arg(grandChild->name()));
|
||||
}
|
||||
}
|
||||
@@ -230,14 +190,13 @@ QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const
|
||||
}
|
||||
}
|
||||
|
||||
QHash<ProFileWithDisplayName, TestCases>::ConstIterator it = proFilesWithCheckedTestSets.begin();
|
||||
QHash<ProFileWithDisplayName, TestCases>::ConstIterator end = proFilesWithCheckedTestSets.end();
|
||||
QHash<QString, TestCases>::ConstIterator it = proFilesWithCheckedTestSets.begin();
|
||||
QHash<QString, TestCases>::ConstIterator end = proFilesWithCheckedTestSets.end();
|
||||
for ( ; it != end; ++it) {
|
||||
const ProFileWithDisplayName &proFileWithDisplayName = it.key();
|
||||
GTestConfiguration *tc = new GTestConfiguration;
|
||||
tc->setTestCases(it.value().filters);
|
||||
tc->setTestCaseCount(tc->testCaseCount() + it.value().additionalTestCaseCount);
|
||||
tc->setProjectFile(proFileWithDisplayName.proFile);
|
||||
tc->setProjectFile(it.key());
|
||||
tc->setProject(project);
|
||||
result << tc;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,9 @@
|
||||
#include "qttesttreeitem.h"
|
||||
#include "qttestvisitors.h"
|
||||
#include "qttest_utils.h"
|
||||
#include "../autotest_utils.h"
|
||||
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <cpptools/projectpart.h>
|
||||
#include <cplusplus/TypeOfExpression.h>
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "qttesttreeitem.h"
|
||||
#include "qttestconfiguration.h"
|
||||
#include "qttestparser.h"
|
||||
#include "../autotest_utils.h"
|
||||
|
||||
#include <projectexplorer/session.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -27,9 +27,10 @@
|
||||
#include "quicktesttreeitem.h"
|
||||
#include "quicktestvisitors.h"
|
||||
#include "quicktest_utils.h"
|
||||
#include "../autotest_utils.h"
|
||||
#include "../testcodeparser.h"
|
||||
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <cpptools/projectpart.h>
|
||||
#include <projectexplorer/session.h>
|
||||
#include <qmljs/parser/qmljsast_p.h>
|
||||
#include <qmljs/qmljsdialect.h>
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "autotestconstants.h"
|
||||
#include "autotest_utils.h"
|
||||
#include "autotestplugin.h"
|
||||
#include "testcodeparser.h"
|
||||
#include "testframeworkmanager.h"
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "autotestconstants.h"
|
||||
#include "autotest_utils.h"
|
||||
#include "itestparser.h"
|
||||
#include "testconfiguration.h"
|
||||
#include "testtreeitem.h"
|
||||
|
||||
Reference in New Issue
Block a user