FilePathify some testing code

Change-Id: I3739a6eb3c2172078e9519e8186daf94ec74d99a
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2023-01-12 15:30:01 +01:00
parent 2ce413112b
commit 33cdb052ba
13 changed files with 63 additions and 68 deletions

View File

@@ -64,9 +64,9 @@ namespace Tests {
const Usage::Tags Initialization{Usage::Tag::Declaration, Usage::Tag::Write};
static QString qrcPath(const QByteArray &relativeFilePath)
static QString qrcPath(const QString &relativeFilePath)
{
return QLatin1String(":/unittests/ClangCodeModel/") + QString::fromUtf8(relativeFilePath);
return ":/unittests/ClangCodeModel/" + relativeFilePath;
}
ClangdTest::~ClangdTest()
@@ -79,7 +79,7 @@ ClangdTest::~ClangdTest()
Utils::FilePath ClangdTest::filePath(const QString &fileName) const
{
return Utils::FilePath::fromString(m_projectDir->absolutePath(fileName.toLocal8Bit()));
return m_projectDir->absolutePath(fileName);
}
void ClangdTest::waitForNewClient(bool withIndex)
@@ -133,11 +133,10 @@ void ClangdTest::initTestCase()
QSKIP("The test requires at least one valid kit with a valid Qt");
// Copy project out of qrc file, open it, and set up target.
m_projectDir = new TemporaryCopiedDir(qrcPath(QFileInfo(m_projectFileName)
.baseName().toLocal8Bit()));
m_projectDir = new TemporaryCopiedDir(qrcPath(QFileInfo(m_projectFileName).baseName()));
QVERIFY(m_projectDir->isValid());
const auto openProjectResult = ProjectExplorerPlugin::openProject(
Utils::FilePath::fromString(m_projectDir->absolutePath(m_projectFileName.toUtf8())));
m_projectDir->absolutePath(m_projectFileName));
QVERIFY2(openProjectResult, qPrintable(openProjectResult.errorMessage()));
m_project = openProjectResult.project();
m_project->configureAsExampleProject(m_kit);
@@ -147,8 +146,7 @@ void ClangdTest::initTestCase()
// Open cpp documents.
for (const QString &sourceFileName : std::as_const(m_sourceFileNames)) {
const auto sourceFilePath = Utils::FilePath::fromString(
m_projectDir->absolutePath(sourceFileName.toLocal8Bit()));
const auto sourceFilePath = m_projectDir->absolutePath(sourceFileName);
QVERIFY2(sourceFilePath.exists(), qPrintable(sourceFilePath.toUserOutput()));
IEditor * const editor = EditorManager::openEditor(sourceFilePath);
QVERIFY(editor);