diff options
author | hjk <hjk@qt.io> | 2019-05-28 13:49:26 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2019-05-28 12:23:26 +0000 |
commit | 473a741c9fcf09febba312464fab8385e2351181 (patch) | |
tree | 2d328a090993cb5c5fd34b43e9468bcbf7e4d4d0 /tests/auto | |
parent | 4704f49fbb1201ebf10ab9dbaed0275ff25faba8 (diff) |
Utils: Rename FileName to FilePath
More in line with QFileInfo terminonlogy which appears to be
best-of-breed within Qt.
Change-Id: I1d051ff1c8363ebd4ee56376451df45216c4c9ab
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'tests/auto')
8 files changed, 39 insertions, 39 deletions
diff --git a/tests/auto/languageserverprotocol/tst_languageserverprotocol.cpp b/tests/auto/languageserverprotocol/tst_languageserverprotocol.cpp index f4c94a36b9..daa013b744 100644 --- a/tests/auto/languageserverprotocol/tst_languageserverprotocol.cpp +++ b/tests/auto/languageserverprotocol/tst_languageserverprotocol.cpp @@ -595,7 +595,7 @@ void tst_LanguageServerProtocol::documentUri_data() { QTest::addColumn<DocumentUri>("uri"); QTest::addColumn<bool>("isValid"); - QTest::addColumn<Utils::FileName>("fileName"); + QTest::addColumn<Utils::FilePath>("fileName"); QTest::addColumn<QString>("string"); // '/' (fs root) is part of the file path @@ -605,18 +605,18 @@ void tst_LanguageServerProtocol::documentUri_data() QTest::newRow("empty uri") << DocumentUri() << false - << Utils::FileName() + << Utils::FilePath() << QString(); QTest::newRow("home dir") - << DocumentUri::fromFileName(Utils::FileName::fromString(QDir::homePath())) + << DocumentUri::fromFileName(Utils::FilePath::fromString(QDir::homePath())) << true - << Utils::FileName::fromUserInput(QDir::homePath()) + << Utils::FilePath::fromUserInput(QDir::homePath()) << QString(filePrefix + QDir::homePath()); const QString argv0 = QFileInfo(qApp->arguments().first()).absoluteFilePath(); - const auto argv0FileName = Utils::FileName::fromUserInput(argv0); + const auto argv0FileName = Utils::FilePath::fromUserInput(argv0); QTest::newRow("argv0 file name") << DocumentUri::fromFileName(argv0FileName) << true @@ -626,7 +626,7 @@ void tst_LanguageServerProtocol::documentUri_data() QTest::newRow("http") << DocumentUri::fromProtocol("https://www.qt.io/") << true - << Utils::FileName() + << Utils::FilePath() << "https://www.qt.io/"; // depending on the OS the resulting path is different (made suitable for the file system) @@ -636,7 +636,7 @@ void tst_LanguageServerProtocol::documentUri_data() QTest::newRow("percent encoding") << DocumentUri::fromProtocol(winUserPercent) << true - << Utils::FileName::fromUserInput(winUser) + << Utils::FilePath::fromUserInput(winUser) << QString(filePrefix + QDir::fromNativeSeparators(winUser)); } @@ -644,7 +644,7 @@ void tst_LanguageServerProtocol::documentUri() { QFETCH(DocumentUri, uri); QFETCH(bool, isValid); - QFETCH(Utils::FileName, fileName); + QFETCH(Utils::FilePath, fileName); QFETCH(QString, string); QCOMPARE(uri.isValid(), isValid); diff --git a/tests/auto/qml/codemodel/dependencies/tst_dependencies.cpp b/tests/auto/qml/codemodel/dependencies/tst_dependencies.cpp index 842cec7e4e..71e5d50735 100644 --- a/tests/auto/qml/codemodel/dependencies/tst_dependencies.cpp +++ b/tests/auto/qml/codemodel/dependencies/tst_dependencies.cpp @@ -148,7 +148,7 @@ void tst_Dependencies::test() QStringList paths(m_basePaths); paths << m_path; for (auto p: paths) - lPaths.maybeInsert(Utils::FileName::fromString(p), Dialect::Qml); + lPaths.maybeInsert(Utils::FilePath::fromString(p), Dialect::Qml); ModelManagerInterface::importScan(result, ModelManagerInterface::workingCopy(), lPaths, ModelManagerInterface::instance(), false); diff --git a/tests/auto/qml/codemodel/ecmascript7/tst_ecmascript7.cpp b/tests/auto/qml/codemodel/ecmascript7/tst_ecmascript7.cpp index 886a920ed4..f178338bd1 100644 --- a/tests/auto/qml/codemodel/ecmascript7/tst_ecmascript7.cpp +++ b/tests/auto/qml/codemodel/ecmascript7/tst_ecmascript7.cpp @@ -174,7 +174,7 @@ void tst_Ecmascript::test() PathsAndLanguages lPaths; QStringList paths(m_basePaths); for (auto p: paths) - lPaths.maybeInsert(Utils::FileName::fromString(p), Dialect::Qml); + lPaths.maybeInsert(Utils::FilePath::fromString(p), Dialect::Qml); ModelManagerInterface::importScan(result, ModelManagerInterface::workingCopy(), lPaths, ModelManagerInterface::instance(), false); diff --git a/tests/auto/qml/codemodel/importscheck/tst_importscheck.cpp b/tests/auto/qml/codemodel/importscheck/tst_importscheck.cpp index dcedd6df69..0c11438e12 100644 --- a/tests/auto/qml/codemodel/importscheck/tst_importscheck.cpp +++ b/tests/auto/qml/codemodel/importscheck/tst_importscheck.cpp @@ -67,7 +67,7 @@ void scanDir(const QString &dir) { QFutureInterface<void> result; PathsAndLanguages paths; - paths.maybeInsert(Utils::FileName::fromString(dir), Dialect::Qml); + paths.maybeInsert(Utils::FilePath::fromString(dir), Dialect::Qml); ModelManagerInterface::importScan(result, ModelManagerInterface::workingCopy(), paths, ModelManagerInterface::instance(), false); ViewerContext vCtx = ViewerContext(QStringList(), QStringList(dir)); @@ -178,7 +178,7 @@ void tst_ImportCheck::test() QFutureInterface<void> result; PathsAndLanguages lPaths; foreach (const QString &path, paths) - lPaths.maybeInsert(Utils::FileName::fromString(path), Dialect::Qml); + lPaths.maybeInsert(Utils::FilePath::fromString(path), Dialect::Qml); ModelManagerInterface::importScan(result, ModelManagerInterface::workingCopy(), lPaths, ModelManagerInterface::instance(), false); ViewerContext vCtx(QStringList(), paths); diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp index e818c27c66..31ea4e5914 100644 --- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp +++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp @@ -185,7 +185,7 @@ void tst_TestCore::initTestCase() QFutureInterface<void> result; QmlJS::PathsAndLanguages lPaths; - lPaths.maybeInsert(Utils::FileName::fromString(basePaths.first()), QmlJS::Dialect::Qml); + lPaths.maybeInsert(Utils::FilePath::fromString(basePaths.first()), QmlJS::Dialect::Qml); QmlJS::ModelManagerInterface::importScan(result, QmlJS::ModelManagerInterface::workingCopy(), lPaths, QmlJS::ModelManagerInterface::instance(), false); diff --git a/tests/auto/qml/qmlprojectmanager/fileformat/tst_fileformat.cpp b/tests/auto/qml/qmlprojectmanager/fileformat/tst_fileformat.cpp index ea02a11102..fe61dd0ea5 100644 --- a/tests/auto/qml/qmlprojectmanager/fileformat/tst_fileformat.cpp +++ b/tests/auto/qml/qmlprojectmanager/fileformat/tst_fileformat.cpp @@ -54,7 +54,7 @@ QString testDataDir = QLatin1String(SRCDIR "/data"); static QmlProjectItem *loadQmlProject(QString name, QString *error) { return QmlProjectFileFormat::parseProjectFile( - Utils::FileName::fromString(testDataDir).pathAppended(name + ".qmlproject"), error); + Utils::FilePath::fromString(testDataDir).pathAppended(name + ".qmlproject"), error); } void tst_FileFormat::testFileFilter() diff --git a/tests/auto/utils/fileutils/tst_fileutils.cpp b/tests/auto/utils/fileutils/tst_fileutils.cpp index 2b588c533e..2102bd0f06 100644 --- a/tests/auto/utils/fileutils/tst_fileutils.cpp +++ b/tests/auto/utils/fileutils/tst_fileutils.cpp @@ -80,7 +80,7 @@ void tst_fileutils::parentDir() QFETCH(QString, parentPath); QFETCH(QString, expectFailMessage); - FileName result = FileName::fromString(path).parentDir(); + FilePath result = FilePath::fromString(path).parentDir(); if (!expectFailMessage.isEmpty()) QEXPECT_FAIL("", expectFailMessage.toUtf8().constData(), Continue); QCOMPARE(result.toString(), parentPath); @@ -120,7 +120,7 @@ void tst_fileutils::isChildOf() QFETCH(QString, childPath); QFETCH(bool, result); - bool res = FileName::fromString(childPath).isChildOf(FileName::fromString(path)); + bool res = FilePath::fromString(childPath).isChildOf(FilePath::fromString(path)); QCOMPARE(res, result); } @@ -161,7 +161,7 @@ void tst_fileutils::fileName() QFETCH(QString, path); QFETCH(int, components); QFETCH(QString, result); - QCOMPARE(FileName::fromString(path).fileName(components), result); + QCOMPARE(FilePath::fromString(path).fileName(components), result); } QTEST_APPLESS_MAIN(tst_fileutils) diff --git a/tests/auto/utils/settings/tst_settings.cpp b/tests/auto/utils/settings/tst_settings.cpp index 867f9bbe91..931c601a6e 100644 --- a/tests/auto/utils/settings/tst_settings.cpp +++ b/tests/auto/utils/settings/tst_settings.cpp @@ -70,18 +70,18 @@ public: class BasicTestSettingsAccessor : public Utils::MergingSettingsAccessor { public: - BasicTestSettingsAccessor(const Utils::FileName &baseName = Utils::FileName::fromString("/foo/bar"), + BasicTestSettingsAccessor(const Utils::FilePath &baseName = Utils::FilePath::fromString("/foo/bar"), const QByteArray &id = QByteArray(TESTACCESSOR_DEFAULT_ID)); using Utils::MergingSettingsAccessor::addVersionUpgrader; - QHash<Utils::FileName, QVariantMap> files() const { return m_files; } - void addFile(const Utils::FileName &path, const QVariantMap &data) const { m_files.insert(path, data); } - Utils::FileNameList fileNames() const { return m_files.keys(); } - QVariantMap fileContents(const Utils::FileName &path) const { return m_files.value(path); } + QHash<Utils::FilePath, QVariantMap> files() const { return m_files; } + void addFile(const Utils::FilePath &path, const QVariantMap &data) const { m_files.insert(path, data); } + Utils::FilePathList fileNames() const { return m_files.keys(); } + QVariantMap fileContents(const Utils::FilePath &path) const { return m_files.value(path); } protected: - RestoreData readFile(const Utils::FileName &path) const override + RestoreData readFile(const Utils::FilePath &path) const override { if (!m_files.contains(path)) return RestoreData("File not found.", "File not found.", Issue::Type::ERROR); @@ -108,7 +108,7 @@ protected: return qMakePair(key, secondary); } - Utils::optional<Issue> writeFile(const Utils::FileName &path, const QVariantMap &data) const override + Utils::optional<Issue> writeFile(const Utils::FilePath &path, const QVariantMap &data) const override { if (data.isEmpty()) { return Issue(QCoreApplication::translate("Utils::SettingsAccessor", "Failed to Write File"), @@ -121,7 +121,7 @@ protected: } private: - mutable QHash<Utils::FileName, QVariantMap> m_files; + mutable QHash<Utils::FilePath, QVariantMap> m_files; }; // -------------------------------------------------------------------- @@ -137,10 +137,10 @@ public: VersionedBackUpStrategy(accessor) { } - FileNameList readFileCandidates(const Utils::FileName &baseFileName) const + FilePathList readFileCandidates(const Utils::FilePath &baseFileName) const { return Utils::filtered(static_cast<const BasicTestSettingsAccessor *>(accessor())->fileNames(), - [&baseFileName](const Utils::FileName &f) { + [&baseFileName](const Utils::FilePath &f) { return f.parentDir() == baseFileName.parentDir() && f.toString().startsWith(baseFileName.toString()); }); } @@ -153,7 +153,7 @@ public: class TestSettingsAccessor : public BasicTestSettingsAccessor { public: - TestSettingsAccessor(const Utils::FileName &baseName = Utils::FileName::fromString("/foo/baz"), + TestSettingsAccessor(const Utils::FilePath &baseName = Utils::FilePath::fromString("/foo/baz"), const QByteArray &id = QByteArray(TESTACCESSOR_DEFAULT_ID)) : BasicTestSettingsAccessor(baseName, id) { @@ -166,7 +166,7 @@ public: using Utils::MergingSettingsAccessor::upgradeSettings; }; -BasicTestSettingsAccessor::BasicTestSettingsAccessor(const FileName &baseName, const QByteArray &id) : +BasicTestSettingsAccessor::BasicTestSettingsAccessor(const FilePath &baseName, const QByteArray &id) : Utils::MergingSettingsAccessor(std::make_unique<TestBackUpStrategy>(this), "TestData", TESTACCESSOR_DN, TESTACCESSOR_APPLICATION_DN) { @@ -235,7 +235,7 @@ static QVariantMap versionedMap(int version, const QByteArray &id = QByteArray() return result; } -static Utils::SettingsAccessor::RestoreData restoreData(const Utils::FileName &path, +static Utils::SettingsAccessor::RestoreData restoreData(const Utils::FilePath &path, const QVariantMap &data) { return Utils::SettingsAccessor::RestoreData(path, data); @@ -244,7 +244,7 @@ static Utils::SettingsAccessor::RestoreData restoreData(const Utils::FileName &p static Utils::SettingsAccessor::RestoreData restoreData(const QByteArray &path, const QVariantMap &data) { - return restoreData(Utils::FileName::fromUtf8(path), data); + return restoreData(Utils::FilePath::fromUtf8(path), data); } void tst_SettingsAccessor::addVersionUpgrader() @@ -365,7 +365,7 @@ void tst_SettingsAccessor::RestoreDataCompare_idMismatch() void tst_SettingsAccessor::RestoreDataCompare_noId() { - const TestSettingsAccessor accessor(Utils::FileName::fromString("/foo/baz"), QByteArray()); + const TestSettingsAccessor accessor(Utils::FilePath::fromString("/foo/baz"), QByteArray()); Utils::SettingsAccessor::RestoreData a = restoreData("/foo/bar", versionedMap(5, TESTACCESSOR_DEFAULT_ID)); Utils::SettingsAccessor::RestoreData b = restoreData("/foo/baz", versionedMap(6, "foo")); @@ -667,7 +667,7 @@ void tst_SettingsAccessor::findIssues_nonDefaultPath() void tst_SettingsAccessor::saveSettings() { - const Utils::FileName baseFile = Utils::FileName::fromString("/tmp/foo/saveSettings"); + const Utils::FilePath baseFile = Utils::FilePath::fromString("/tmp/foo/saveSettings"); const TestSettingsAccessor accessor(baseFile); const QVariantMap data = versionedMap(6, TESTACCESSOR_DEFAULT_ID); @@ -691,7 +691,7 @@ void tst_SettingsAccessor::saveSettings() void tst_SettingsAccessor::loadSettings() { const QVariantMap data = versionedMap(6, "loadSettings", generateExtraData()); - const Utils::FileName path = Utils::FileName::fromString("/tmp/foo/loadSettings"); + const Utils::FilePath path = Utils::FilePath::fromString("/tmp/foo/loadSettings"); const TestSettingsAccessor accessor(path, "loadSettings"); accessor.addFile(path, data); QCOMPARE(accessor.files().count(), 1); // Catch changes early:-) @@ -719,17 +719,17 @@ void tst_SettingsAccessor::loadSettings() void tst_SettingsAccessor::loadSettings_pickBest() { - const Utils::FileName path = Utils::FileName::fromString("/tmp/foo/loadSettings"); + const Utils::FilePath path = Utils::FilePath::fromString("/tmp/foo/loadSettings"); const TestSettingsAccessor accessor(path, "loadSettings"); accessor.addFile(path, versionedMap(10, "loadSettings", generateExtraData())); // too new const QVariantMap data = versionedMap(7, "loadSettings", generateExtraData()); - accessor.addFile(Utils::FileName::fromString("/tmp/foo/loadSettings.foo"), data); // pick this! - accessor.addFile(Utils::FileName::fromString("/tmp/foo/loadSettings.foo1"), + accessor.addFile(Utils::FilePath::fromString("/tmp/foo/loadSettings.foo"), data); // pick this! + accessor.addFile(Utils::FilePath::fromString("/tmp/foo/loadSettings.foo1"), versionedMap(8, "fooSettings", generateExtraData())); // wrong environment - accessor.addFile(Utils::FileName::fromString("/tmp/foo/loadSettings.bar"), + accessor.addFile(Utils::FilePath::fromString("/tmp/foo/loadSettings.bar"), versionedMap(6, "loadSettings", generateExtraData())); // too old - accessor.addFile(Utils::FileName::fromString("/tmp/foo/loadSettings.baz"), + accessor.addFile(Utils::FilePath::fromString("/tmp/foo/loadSettings.baz"), versionedMap(1, "loadSettings", generateExtraData())); // much too old QCOMPARE(accessor.files().count(), 5); // Catch changes early:-) |