forked from qt-creator/qt-creator
CppTools: Refactor ProjectPartBuilder
...and add some basic tests. Introduce the abstractions ProjectInterface and ToolChainInterface in order to break the dependency to the ProjectExplorer. Also, some simple logic can go there to simplify the (Base)ProjectPartBuilder. Change-Id: I6c50a1804ce62098b87109931eb171f5c2542937 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "googletest.h"
|
||||
#include "gtest-qt-printing.h"
|
||||
#include "mimedatabase-utilities.h"
|
||||
|
||||
#include <cpptools/cppprojectfilecategorizer.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
@@ -46,12 +47,6 @@ using testing::AllOf;
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
bool operator==(const ProjectFile &lhs, const ProjectFile &rhs)
|
||||
{
|
||||
return lhs.path == rhs.path
|
||||
&& lhs.kind == rhs.kind;
|
||||
}
|
||||
|
||||
void PrintTo(const ProjectFile &projectFile, std::ostream *os)
|
||||
{
|
||||
*os << "ProjectFile(";
|
||||
@@ -71,7 +66,6 @@ protected:
|
||||
void SetUp() override;
|
||||
|
||||
static ProjectFiles singleFile(const QString &filePath, ProjectFile::Kind kind);
|
||||
static void initMimeDataBaseIfNotYetDone();
|
||||
|
||||
protected:
|
||||
const QString dummyProjectPartName;
|
||||
@@ -192,7 +186,7 @@ TEST_F(ProjectFileCategorizer, AmbiguousHeaderOnly)
|
||||
|
||||
void ProjectFileCategorizer::SetUp()
|
||||
{
|
||||
initMimeDataBaseIfNotYetDone();
|
||||
ASSERT_TRUE(MimeDataBaseUtilities::addCppToolsMimeTypes());
|
||||
}
|
||||
|
||||
QVector<CppTools::ProjectFile>ProjectFileCategorizer::singleFile(const QString &filePath,
|
||||
@@ -201,16 +195,4 @@ QVector<CppTools::ProjectFile>ProjectFileCategorizer::singleFile(const QString &
|
||||
return { ProjectFile(filePath, kind) };
|
||||
}
|
||||
|
||||
void ProjectFileCategorizer::initMimeDataBaseIfNotYetDone()
|
||||
{
|
||||
static bool isInitialized = false;
|
||||
if (isInitialized)
|
||||
return;
|
||||
|
||||
const QString filePath = TESTDATA_DIR "/../../../../src/plugins/cpptools/CppTools.mimetypes.xml";
|
||||
ASSERT_TRUE(QFileInfo::exists(filePath));
|
||||
Utils::MimeDatabase::addMimeTypes(filePath);
|
||||
isInitialized = true;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
Reference in New Issue
Block a user