From 9c1336d49bfd8a5ab3d1847b2ef9b79115018f00 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Fri, 21 Mar 2025 13:28:43 +0100 Subject: [PATCH] UnitTests: Refactor ProjectStorageUpdater test part one Change-Id: I1c4416b301e47f58247426284da7173f386b69cc Reviewed-by: Thomas Hartmann --- .../projectstorageerrornotifierinterface.h | 2 + .../projectstorage/projectstorageupdater.cpp | 5 +- .../project/projectstorageerrornotifier.cpp | 18 + .../project/projectstorageerrornotifier.h | 1 + .../mocks/projectstorageerrornotifiermock.h | 1 + .../unit/tests/printers/gtest-qt-printing.cpp | 7 + tests/unit/tests/printers/gtest-qt-printing.h | 1 + .../projectstorageupdater-test.cpp | 444 ++++++++++-------- 8 files changed, 291 insertions(+), 188 deletions(-) diff --git a/src/plugins/qmldesigner/libs/designercore/projectstorage/projectstorageerrornotifierinterface.h b/src/plugins/qmldesigner/libs/designercore/projectstorage/projectstorageerrornotifierinterface.h index 34cb1638d66..df4efdc89b6 100644 --- a/src/plugins/qmldesigner/libs/designercore/projectstorage/projectstorageerrornotifierinterface.h +++ b/src/plugins/qmldesigner/libs/designercore/projectstorage/projectstorageerrornotifierinterface.h @@ -31,6 +31,8 @@ public: SourceId qmldirSourceId) = 0; + virtual void qmltypesFileMissing(QStringView qmltypesPath) = 0; + protected: ~ProjectStorageErrorNotifierInterface() = default; }; diff --git a/src/plugins/qmldesigner/libs/designercore/projectstorage/projectstorageupdater.cpp b/src/plugins/qmldesigner/libs/designercore/projectstorage/projectstorageupdater.cpp index e9a26edd133..b0de72c73c1 100644 --- a/src/plugins/qmldesigner/libs/designercore/projectstorage/projectstorageupdater.cpp +++ b/src/plugins/qmldesigner/libs/designercore/projectstorage/projectstorageupdater.cpp @@ -1235,7 +1235,10 @@ auto ProjectStorageUpdater::parseTypeInfo(const Storage::Synchronization::Direct case FileState::Removed: case FileState::NotExists: case FileState::NotExistsUnchanged: - throw CannotParseQmlTypesFile{}; + tracer.tick("append updated source ids", keyValue("source id", directoryInfo.sourceId)); + package.updatedSourceIds.push_back(directoryInfo.sourceId); + + m_errorNotifier.qmltypesFileMissing(qmltypesPath); } tracer.end(keyValue("state", state)); diff --git a/src/plugins/qmldesigner/project/projectstorageerrornotifier.cpp b/src/plugins/qmldesigner/project/projectstorageerrornotifier.cpp index f6fefe2b297..25646c21a35 100644 --- a/src/plugins/qmldesigner/project/projectstorageerrornotifier.cpp +++ b/src/plugins/qmldesigner/project/projectstorageerrornotifier.cpp @@ -24,6 +24,17 @@ void logIssue(ProjectExplorer::Task::TaskType type, const QString &message, cons ProjectExplorer::TaskHub::addTask(task); ProjectExplorer::TaskHub::requestPopup(); } + +void logIssue(ProjectExplorer::Task::TaskType type, const QString &message, QStringView sourcePath) +{ + const Utils::Id category = ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM; + + Utils::FilePath filePath = Utils::FilePath::fromPathPart(sourcePath); + ProjectExplorer::Task task(type, message, filePath, -1, category); + ProjectExplorer::TaskHub::addTask(task); + ProjectExplorer::TaskHub::requestPopup(); +} + } // namespace void ProjectStorageErrorNotifier::typeNameCannotBeResolved(Utils::SmallStringView typeName, @@ -71,4 +82,11 @@ void ProjectStorageErrorNotifier::qmlDocumentDoesNotExistsForQmldirEntry(Utils:: m_pathCache.sourcePath(qmldirSourceId)); } +void ProjectStorageErrorNotifier::qmltypesFileMissing(QStringView qmltypesPath) +{ + logIssue(ProjectExplorer::Task::Warning, + Tr::tr("Not existing Qmltypes File %1.").arg(qmltypesPath), + qmltypesPath); +} + } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/project/projectstorageerrornotifier.h b/src/plugins/qmldesigner/project/projectstorageerrornotifier.h index ae720bac693..03606259d43 100644 --- a/src/plugins/qmldesigner/project/projectstorageerrornotifier.h +++ b/src/plugins/qmldesigner/project/projectstorageerrornotifier.h @@ -27,6 +27,7 @@ public: Storage::Version version, SourceId qmlDocumentSourceId, SourceId qmldirSourceId) override; + void qmltypesFileMissing(QStringView qmltypesPath) override; private: PathCacheType &m_pathCache; diff --git a/tests/unit/tests/mocks/projectstorageerrornotifiermock.h b/tests/unit/tests/mocks/projectstorageerrornotifiermock.h index 17281682974..e58b27d1a33 100644 --- a/tests/unit/tests/mocks/projectstorageerrornotifiermock.h +++ b/tests/unit/tests/mocks/projectstorageerrornotifiermock.h @@ -32,4 +32,5 @@ public: QmlDesigner::SourceId qmlDocumentSourceId, QmlDesigner::SourceId qmldirSourceId), (override)); + MOCK_METHOD(void, qmltypesFileMissing, (QStringView qmltypesPath), (override)); }; diff --git a/tests/unit/tests/printers/gtest-qt-printing.cpp b/tests/unit/tests/printers/gtest-qt-printing.cpp index ef4425e1eb7..9b0e166be5f 100644 --- a/tests/unit/tests/printers/gtest-qt-printing.cpp +++ b/tests/unit/tests/printers/gtest-qt-printing.cpp @@ -1,6 +1,8 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +#include "gtest-qt-printing.h" + #include #include #include @@ -89,6 +91,11 @@ std::ostream &operator<<(std::ostream &out, const QIcon &icon) out << icon.cacheKey() << ")"; } +void PrintTo(QStringView text, std::ostream *os) +{ + *os << text; +} + void PrintTo(const QString &text, std::ostream *os) { *os << text; diff --git a/tests/unit/tests/printers/gtest-qt-printing.h b/tests/unit/tests/printers/gtest-qt-printing.h index a81994be167..2711f633198 100644 --- a/tests/unit/tests/printers/gtest-qt-printing.h +++ b/tests/unit/tests/printers/gtest-qt-printing.h @@ -45,6 +45,7 @@ std::ostream &operator<<(std::ostream &out, const QImage &image); std::ostream &operator<<(std::ostream &out, const QIcon &icon); void PrintTo(const QString &text, std::ostream *os); +void PrintTo(QStringView text, std::ostream *os); void PrintTo(const QVariant &variant, std::ostream *os); void PrintTo(const QByteArray &text, std::ostream *os); QT_END_NAMESPACE diff --git a/tests/unit/tests/unittests/projectstorage/projectstorageupdater-test.cpp b/tests/unit/tests/unittests/projectstorage/projectstorageupdater-test.cpp index ed063b5291e..ecc5081074b 100644 --- a/tests/unit/tests/unittests/projectstorage/projectstorageupdater-test.cpp +++ b/tests/unit/tests/unittests/projectstorage/projectstorageupdater-test.cpp @@ -21,6 +21,8 @@ namespace { +using namespace Qt::StringLiterals; + namespace Storage = QmlDesigner::Storage; using QmlDesigner::FileStatus; @@ -28,7 +30,6 @@ using QmlDesigner::ModuleId; using QmlDesigner::SourceContextId; using QmlDesigner::SourceId; using QmlDesigner::SourceNameId; -namespace Storage = QmlDesigner::Storage; using QmlDesigner::IdPaths; using Storage::Import; using Storage::IsInsideProject; @@ -153,7 +154,7 @@ auto IsPropertyEditorQmlPath(const ModuleIdMatcher &moduleIdMatcher, directoryIdMatcher)); } -class ProjectStorageUpdater : public testing::Test +class BaseProjectStorageUpdater : public testing::Test { public: struct StaticData @@ -170,85 +171,16 @@ public: static void TearDownTestSuite() { staticData.reset(); } - ProjectStorageUpdater() + BaseProjectStorageUpdater() { - setFilesChanged({qmltypesPathSourceId, qmlDirPathSourceId, qmlDocumentSourceId1}); - setFilesAdded({qmltypes2PathSourceId, qmlDocumentSourceId2, qmlDocumentSourceId3}); - - setFilesDontChanged({directoryPathSourceId, - path1SourceId, - path2SourceId, - path3SourceId, - firstSourceId, - secondSourceId, - thirdSourceId, - qmltypes1SourceId, - qmltypes2SourceId, - itemLibraryPathSourceId}); - setFilesDontExistsUnchanged({createDirectorySourceId("/path/designer"), - createDirectorySourceId("/root/designer"), - createDirectorySourceId("/path/one/designer"), - createDirectorySourceId("/path/two/designer"), - createDirectorySourceId("/path/three/designer")}); - - setFilesAdded({qmldir1SourceId, qmldir2SourceId, qmldir3SourceId}); - - setContent(u"/path/qmldir", qmldirContent); - - setQmlFileNames(u"/path", {"First.qml", "First2.qml", "Second.qml"}); - ON_CALL(projectStorageMock, moduleId(_, _)).WillByDefault([&](const auto &name, const auto &kind) { return storage.moduleId(name, kind); }); - - firstType.prototype = ImportedType{"Object"}; - firstType.traits = TypeTraitsKind::Reference; - secondType.prototype = ImportedType{"Object2"}; - secondType.traits = TypeTraitsKind::Reference; - thirdType.prototype = ImportedType{"Object3"}; - thirdType.traits = TypeTraitsKind::Reference; - - setContent(u"/path/First.qml", qmlDocument1); - setContent(u"/path/First2.qml", qmlDocument2); - setContent(u"/path/Second.qml", qmlDocument3); - setContent(u"/path/example.qmltypes", qmltypes1); - setContent(u"/path/example2.qmltypes", qmltypes2); - setContent(u"/path/one/First.qml", qmlDocument1); - setContent(u"/path/one/Second.qml", qmlDocument2); - setContent(u"/path/two/Third.qml", qmlDocument3); - setContent(u"/path/one/example.qmltypes", qmltypes1); - setContent(u"/path/two/example2.qmltypes", qmltypes2); - - ON_CALL(qmlDocumentParserMock, parse(qmlDocument1, _, _, _, _)) - .WillByDefault([&](auto, auto &imports, auto, auto, auto) { - imports.push_back(import1); - return firstType; - }); - ON_CALL(qmlDocumentParserMock, parse(qmlDocument2, _, _, _, _)) - .WillByDefault([&](auto, auto &imports, auto, auto, auto) { - imports.push_back(import2); - return secondType; - }); - ON_CALL(qmlDocumentParserMock, parse(qmlDocument3, _, _, _, _)) - .WillByDefault([&](auto, auto &imports, auto, auto, auto) { - imports.push_back(import3); - return thirdType; - }); - ON_CALL(qmlTypesParserMock, parse(Eq(qmltypes1), _, _, _, _)) - .WillByDefault([&](auto, auto &imports, auto &types, auto, auto) { - types.push_back(objectType); - imports.push_back(import4); - }); - ON_CALL(qmlTypesParserMock, parse(Eq(qmltypes2), _, _, _, _)) - .WillByDefault([&](auto, auto &imports, auto &types, auto, auto) { - types.push_back(itemType); - imports.push_back(import5); - }); } - ~ProjectStorageUpdater() { storage.resetForTestsOnly(); } + ~BaseProjectStorageUpdater() { storage.resetForTestsOnly(); } - void setFilesDontChanged(const QmlDesigner::SourceIds &sourceIds) + void setFilesUnchanged(const QmlDesigner::SourceIds &sourceIds) { for (auto sourceId : sourceIds) { ON_CALL(fileSystemMock, fileStatus(Eq(sourceId))) @@ -288,7 +220,7 @@ public: } } - void setFilesDontExists(const QmlDesigner::SourceIds &sourceIds) + void setFilesNotExists(const QmlDesigner::SourceIds &sourceIds) { for (auto sourceId : sourceIds) { ON_CALL(fileSystemMock, fileStatus(Eq(sourceId))) @@ -298,7 +230,7 @@ public: } } - void setFilesDontExistsUnchanged(const QmlDesigner::SourceIds &sourceIds) + void setFilesNotExistsUnchanged(const QmlDesigner::SourceIds &sourceIds) { for (auto sourceId : sourceIds) { ON_CALL(fileSystemMock, fileStatus(Eq(sourceId))) @@ -395,6 +327,84 @@ protected: errorNotifierMock, projectPartId, qtPartId}; +}; + +class ProjectStorageUpdater : public BaseProjectStorageUpdater +{ +public: + ProjectStorageUpdater() + { + setFilesChanged({qmltypesPathSourceId, qmlDirPathSourceId, qmlDocumentSourceId1}); + setFilesAdded({qmltypes2PathSourceId, qmlDocumentSourceId2, qmlDocumentSourceId3}); + + setFilesUnchanged({directoryPathSourceId, + path1SourceId, + path2SourceId, + path3SourceId, + firstSourceId, + secondSourceId, + thirdSourceId, + qmltypes1SourceId, + qmltypes2SourceId, + itemLibraryPathSourceId}); + setFilesNotExistsUnchanged({createDirectorySourceId("/path/designer"), + createDirectorySourceId("/root/designer"), + createDirectorySourceId("/path/one/designer"), + createDirectorySourceId("/path/two/designer"), + createDirectorySourceId("/path/three/designer")}); + + setFilesAdded({qmldir1SourceId, qmldir2SourceId, qmldir3SourceId}); + + setContent(u"/path/qmldir", qmldirContent); + + setQmlFileNames(u"/path", {"First.qml", "First2.qml", "Second.qml"}); + + firstType.prototype = ImportedType{"Object"}; + firstType.traits = TypeTraitsKind::Reference; + secondType.prototype = ImportedType{"Object2"}; + secondType.traits = TypeTraitsKind::Reference; + thirdType.prototype = ImportedType{"Object3"}; + thirdType.traits = TypeTraitsKind::Reference; + + setContent(u"/path/First.qml", qmlDocument1); + setContent(u"/path/First2.qml", qmlDocument2); + setContent(u"/path/Second.qml", qmlDocument3); + setContent(u"/path/example.qmltypes", qmltypes1); + setContent(u"/path/example2.qmltypes", qmltypes2); + setContent(u"/path/one/First.qml", qmlDocument1); + setContent(u"/path/one/Second.qml", qmlDocument2); + setContent(u"/path/two/Third.qml", qmlDocument3); + setContent(u"/path/one/example.qmltypes", qmltypes1); + setContent(u"/path/two/example2.qmltypes", qmltypes2); + + ON_CALL(qmlDocumentParserMock, parse(qmlDocument1, _, _, _, _)) + .WillByDefault([&](auto, auto &imports, auto, auto, auto) { + imports.push_back(import1); + return firstType; + }); + ON_CALL(qmlDocumentParserMock, parse(qmlDocument2, _, _, _, _)) + .WillByDefault([&](auto, auto &imports, auto, auto, auto) { + imports.push_back(import2); + return secondType; + }); + ON_CALL(qmlDocumentParserMock, parse(qmlDocument3, _, _, _, _)) + .WillByDefault([&](auto, auto &imports, auto, auto, auto) { + imports.push_back(import3); + return thirdType; + }); + ON_CALL(qmlTypesParserMock, parse(Eq(qmltypes1), _, _, _, _)) + .WillByDefault([&](auto, auto &imports, auto &types, auto, auto) { + types.push_back(objectType); + imports.push_back(import4); + }); + ON_CALL(qmlTypesParserMock, parse(Eq(qmltypes2), _, _, _, _)) + .WillByDefault([&](auto, auto &imports, auto &types, auto, auto) { + types.push_back(itemType); + imports.push_back(import5); + }); + } + +protected: SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/path/example.qmltypes"); SourceId qmltypes2PathSourceId = sourcePathCache.sourceId("/path/example2.qmltypes"); SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/path/qmldir"); @@ -481,16 +491,25 @@ protected: SourceId qmltypes2SourceId = sourcePathCache.sourceId("/path/two/example2.qmltypes"); }; -TEST_F(ProjectStorageUpdater, get_content_for_qml_dir_paths_if_file_status_is_different) +class ProjectStorageUpdater_get_content_for_qml_dir_paths : public ProjectStorageUpdater { +public: + ProjectStorageUpdater_get_content_for_qml_dir_paths() + { + setFilesChanged({qmlDir1PathSourceId}); + setFilesAdded({qmlDir2PathSourceId}); + setFilesUnchanged({qmlDir3PathSourceId, path3SourceId}); + } + SourceId qmlDir1PathSourceId = sourcePathCache.sourceId("/path/one/qmldir"); SourceId qmlDir2PathSourceId = sourcePathCache.sourceId("/path/two/qmldir"); SourceId qmlDir3PathSourceId = sourcePathCache.sourceId("/path/three/qmldir"); SourceId path3SourceId = createDirectorySourceId("/path/three"); +}; + +TEST_F(ProjectStorageUpdater_get_content_for_qml_dir_paths, file_status_is_different) +{ QStringList directories = {"/path/one", "/path/two", "/path/three"}; - setFilesChanged({qmlDir1PathSourceId}); - setFilesAdded({qmlDir2PathSourceId}); - setFilesDontChanged({qmlDir3PathSourceId, path3SourceId}); EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/one/qmldir")))); EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/two/qmldir")))); @@ -498,18 +517,10 @@ TEST_F(ProjectStorageUpdater, get_content_for_qml_dir_paths_if_file_status_is_di updater.update({.qtDirectories = directories}); } -TEST_F(ProjectStorageUpdater, - get_content_for_qml_dir_paths_if_file_status_is_different_for_subdirectories) +TEST_F(ProjectStorageUpdater_get_content_for_qml_dir_paths, file_status_is_different_for_subdirectories) { - SourceId qmlDir1PathSourceId = sourcePathCache.sourceId("/path/one/qmldir"); - SourceId qmlDir2PathSourceId = sourcePathCache.sourceId("/path/two/qmldir"); - SourceId qmlDir3PathSourceId = sourcePathCache.sourceId("/path/three/qmldir"); - SourceId path3SourceId = createDirectorySourceId("/path/three"); QStringList directories = {"/path/one"}; setSubdirectoryPaths(u"/path/one", {"/path/two", "/path/three"}); - setFilesChanged({qmlDir1PathSourceId}); - setFilesAdded({qmlDir2PathSourceId}); - setFilesDontChanged({qmlDir3PathSourceId, path3SourceId}); EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/one/qmldir")))); EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/two/qmldir")))); @@ -540,31 +551,66 @@ TEST_F(ProjectStorageUpdater, request_file_status_from_file_system_for_subdirect updater.update({.qtDirectories = directories}); } -TEST_F(ProjectStorageUpdater, get_content_for_qml_types) +class ProjectStorageUpdater_get_content_for_qml_types : public BaseProjectStorageUpdater { +public: + ProjectStorageUpdater_get_content_for_qml_types() + { + setQmlFileNames(u"/path", {}); + setExpectedContent(u"/path/qmldir", qmldir); + setContent(u"/path/example.qmltypes", qmltypes); + setFilesUnchanged({directoryPathSourceId}); + setFilesChanged({qmlDirPathSourceId}); + } + +public: QString qmldir{R"(module Example typeinfo example.qmltypes)"}; - setQmlFileNames(u"/path", {}); - setExpectedContent(u"/path/qmldir", qmldir); + QString qmltypes{"Module {\ndependencies: [module1]}"}; + QStringList directories = {"/path"}; + SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/path/example.qmltypes"); + SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/path/qmldir"); + SourceContextId directoryPathId = qmlDirPathSourceId.contextId(); + SourceId directoryPathSourceId = SourceId::create(QmlDesigner::SourceNameId{}, directoryPathId); +}; + +TEST_F(ProjectStorageUpdater_get_content_for_qml_types, added_qml_types_file_provides_content) +{ + setFilesAdded({qmltypesPathSourceId}); EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes")))); updater.update({.qtDirectories = directories}); } -TEST_F(ProjectStorageUpdater, get_content_for_qml_types_if_project_storage_file_status_is_invalid) +TEST_F(ProjectStorageUpdater_get_content_for_qml_types, changed_qml_types_file_provides_content) { - QString qmldir{R"(module Example - typeinfo example.qmltypes)"}; - setQmlFileNames(u"/path", {}); - setExpectedContent(u"/path/qmldir", qmldir); - setFilesAdded({qmltypesPathSourceId}); + setFilesChanged({qmltypesPathSourceId}); EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes")))); updater.update({.qtDirectories = directories}); } +TEST_F(ProjectStorageUpdater_get_content_for_qml_types, removed_qml_types_file_does_not_provide_content) +{ + EXPECT_CALL(fileSystemMock, contentAsQString(_)).Times(AnyNumber()); + setFilesRemoved({qmltypesPathSourceId}); + + EXPECT_CALL(fileSystemMock, contentAsQString(Eq("/path/example.qmltypes"_L1))).Times(0); + + updater.update({.qtDirectories = directories}); +} + +TEST_F(ProjectStorageUpdater_get_content_for_qml_types, removed_qml_types_file_notifies_about_error) +{ + setFilesRemoved({qmltypesPathSourceId}); + + EXPECT_CALL(errorNotifierMock, qmltypesFileMissing(Eq("/path/example.qmltypes"_L1))); + + updater.update({.qtDirectories = directories}); +} + TEST_F(ProjectStorageUpdater, parse_qml_types) { QString qmldir{R"(module Example @@ -696,7 +742,7 @@ TEST_F(ProjectStorageUpdater, parse_qml_types_in_subdirectories) TEST_F(ProjectStorageUpdater, synchronize_is_empty_for_no_change) { - setFilesDontChanged({qmltypesPathSourceId, qmltypes2PathSourceId, qmlDirPathSourceId}); + setFilesUnchanged({qmltypesPathSourceId, qmltypes2PathSourceId, qmlDirPathSourceId}); EXPECT_CALL(projectStorageMock, synchronize(PackageIsEmpty())); @@ -707,11 +753,11 @@ TEST_F(ProjectStorageUpdater, synchronize_is_empty_for_no_change_in_subdirectory { SourceId qmlDirRootPathSourceId = sourcePathCache.sourceId("/root/qmldir"); SourceId rootPathSourceId = createDirectorySourceId("/root"); - setFilesDontChanged({qmltypesPathSourceId, - qmltypes2PathSourceId, - qmlDirPathSourceId, - qmlDirRootPathSourceId, - rootPathSourceId}); + setFilesUnchanged({qmltypesPathSourceId, + qmltypes2PathSourceId, + qmlDirPathSourceId, + qmlDirRootPathSourceId, + rootPathSourceId}); QStringList directories = {"/root"}; setSubdirectoryPaths(u"/root", {"/path"}); @@ -726,7 +772,7 @@ TEST_F(ProjectStorageUpdater, synchronize_is_empty_for_ignored_subdirectory) SourceId ignoreInQdsSourceId = sourcePathCache.sourceId("/path/ignore-in-qds"); SourceId rootPathSourceId = createDirectorySourceId("/root"); setFilesChanged({qmltypesPathSourceId, qmltypes2PathSourceId, qmlDirPathSourceId}); - setFilesDontChanged({rootPathSourceId, qmlDirRootPathSourceId, ignoreInQdsSourceId}); + setFilesUnchanged({rootPathSourceId, qmlDirRootPathSourceId, ignoreInQdsSourceId}); setSubdirectoryPaths(u"/root", {"/path"}); EXPECT_CALL(projectStorageMock, synchronize(PackageIsEmpty())); @@ -741,7 +787,7 @@ TEST_F(ProjectStorageUpdater, synchronize_is_empty_for_added_ignored_subdirector SourceId rootPathSourceId = createDirectorySourceId("/root"); setFilesChanged({qmltypesPathSourceId, qmltypes2PathSourceId, qmlDirPathSourceId}); setFilesAdded({ignoreInQdsSourceId}); - setFilesDontChanged({rootPathSourceId, qmlDirRootPathSourceId}); + setFilesUnchanged({rootPathSourceId, qmlDirRootPathSourceId}); setSubdirectoryPaths(u"/root", {"/path"}); EXPECT_CALL( @@ -841,7 +887,7 @@ TEST_F(ProjectStorageUpdater, synchronize_subdircectories_even_for_no_changes) setSubdirectoryPaths(u"/path/one", {"/path/three"}); auto rootDirectoryPathSourceId = createDirectorySourceId("/root"); setFilesChanged({path1SourceId, path2SourceId, path3SourceId}); - setFilesDontChanged({rootDirectoryPathSourceId}); + setFilesUnchanged({rootDirectoryPathSourceId}); EXPECT_CALL(projectStorageMock, synchronize(AllOf(Field("SynchronizationPackage::directoryInfos", @@ -867,7 +913,7 @@ TEST_F(ProjectStorageUpdater, synchronize_subdircectories_for_deleted_subdirecti SourceId rootDirectoryPathSourceId = SourceId::create(QmlDesigner::SourceNameId{}, rootDirectoryPathId); setFilesChanged({rootDirectoryPathSourceId}); - setFilesDontExists({ + setFilesNotExists({ path1SourceId, path3SourceId, }); @@ -891,12 +937,34 @@ TEST_F(ProjectStorageUpdater, synchronize_subdircectories_for_deleted_subdirecti updater.update({.qtDirectories = directories}); } -TEST_F(ProjectStorageUpdater, synchronize_qml_types_throws_if_qmltpes_does_not_exists) +TEST_F(ProjectStorageUpdater, synchronize_qml_types_notfies_error_if_qmltypes_does_not_exists) { Storage::Import import{qmlModuleId, Storage::Version{2, 3}, qmltypesPathSourceId}; - setFilesDontExists({qmltypesPathSourceId}); + setFilesNotExists({qmltypesPathSourceId}); - ASSERT_THROW(updater.update({.qtDirectories = directories}), QmlDesigner::CannotParseQmlTypesFile); + EXPECT_CALL(errorNotifierMock, qmltypesFileMissing(Eq("/path/example.qmltypes"_L1))); + + updater.update({.qtDirectories = directories}); +} + +TEST_F(ProjectStorageUpdater, + synchronize_qml_types_adds_updated_source_id_and_directory_info_for_missing_qmltypes_file) +{ + Storage::Import import{qmlModuleId, Storage::Version{2, 3}, qmltypesPathSourceId}; + setFilesNotExists({qmltypesPathSourceId}); + + EXPECT_CALL(projectStorageMock, + synchronize(AllOf(Field("SynchronizationPackage::updatedSourceIds", + &SynchronizationPackage::updatedSourceIds, + Contains(qmltypesPathSourceId)), + Field("SynchronizationPackage::directoryInfos", + &SynchronizationPackage::directoryInfos, + Contains(IsDirectoryInfo(directoryPathId, + qmltypesPathSourceId, + exampleCppNativeModuleId, + FileType::QmlTypes)))))); + + updater.update({.qtDirectories = directories}); } TEST_F(ProjectStorageUpdater, synchronize_qml_types_are_empty_if_file_does_not_changed) @@ -905,7 +973,7 @@ TEST_F(ProjectStorageUpdater, synchronize_qml_types_are_empty_if_file_does_not_c setContent(u"/path/example.qmltypes", qmltypes); ON_CALL(qmlTypesParserMock, parse(qmltypes, _, _, _, _)) .WillByDefault([&](auto, auto &, auto &types, auto, auto) { types.push_back(objectType); }); - setFilesDontChanged({qmltypesPathSourceId, qmltypes2PathSourceId, qmlDirPathSourceId}); + setFilesUnchanged({qmltypesPathSourceId, qmltypes2PathSourceId, qmlDirPathSourceId}); EXPECT_CALL(projectStorageMock, synchronize(PackageIsEmpty())); @@ -1252,7 +1320,7 @@ TEST_F(ProjectStorageUpdater, synchronize_add_only_qml_document_in_directory) FirstType 1.0 First.qml)"}; setContent(u"/path/qmldir", qmldir); setFilesChanged({directoryPathSourceId}); - setFilesDontChanged({qmlDirPathSourceId, qmlDocumentSourceId1}); + setFilesUnchanged({qmlDirPathSourceId, qmlDocumentSourceId1}); setFilesAdded({qmlDocumentSourceId2}); setDirectoryInfos(directoryPathId, {{directoryPathId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument}}); @@ -1320,7 +1388,7 @@ TEST_F(ProjectStorageUpdater, synchronize_removes_qml_document) )"}; setContent(u"/path/qmldir", qmldir); setFilesChanged({qmlDirPathSourceId}); - setFilesDontChanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); + setFilesUnchanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); setFilesRemoved({qmlDocumentSourceId3}); setDirectoryInfos(directoryPathId, {{directoryPathId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument}, @@ -1390,7 +1458,7 @@ TEST_F(ProjectStorageUpdater, synchronize_removes_qml_document_in_qmldir_only) )"}; setContent(u"/path/qmldir", qmldir); setFilesChanged({qmlDirPathSourceId}); - setFilesDontChanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); + setFilesUnchanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); setDirectoryInfos(directoryPathId, {{directoryPathId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument}, {directoryPathId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument}}); @@ -1454,7 +1522,7 @@ TEST_F(ProjectStorageUpdater, synchronize_add_qml_document_to_qmldir) )"}; setContent(u"/path/qmldir", qmldir); setFilesChanged({qmlDirPathSourceId}); - setFilesDontChanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); + setFilesUnchanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); setDirectoryInfos(directoryPathId, {{directoryPathId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument}, {directoryPathId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument}}); @@ -1517,7 +1585,7 @@ TEST_F(ProjectStorageUpdater, synchronize_remove_qml_document_from_qmldir) FirstType 1.0 First.qml )"}; setContent(u"/path/qmldir", qmldir); - setFilesDontChanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); + setFilesUnchanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); setFilesChanged({qmlDirPathSourceId}); setDirectoryInfos(directoryPathId, {{directoryPathId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument}, @@ -1581,7 +1649,7 @@ TEST_F(ProjectStorageUpdater, synchronize_qml_documents_dont_update_if_up_to_dat FirstType 2.2 First2.qml SecondType 2.2 Second.qml)"}; setContent(u"/path/qmldir", qmldir); - setFilesDontChanged({qmlDocumentSourceId3}); + setFilesUnchanged({qmlDocumentSourceId3}); EXPECT_CALL( projectStorageMock, @@ -1654,7 +1722,7 @@ TEST_F(ProjectStorageUpdater, synchroniz_if_qmldir_file_has_not_changed) {directoryPathId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathId, qmlDocumentSourceId1, exampleModuleId, FileType::QmlDocument}, {directoryPathId, qmlDocumentSourceId2, exampleModuleId, FileType::QmlDocument}}); - setFilesDontChanged({qmlDirPathSourceId}); + setFilesUnchanged({qmlDirPathSourceId}); EXPECT_CALL(projectStorageMock, synchronize(AllOf( @@ -1710,7 +1778,7 @@ TEST_F(ProjectStorageUpdater, synchroniz_if_qmldir_file_has_not_changed_and_some {directoryPathId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathId, qmlDocumentSourceId1, exampleModuleId, FileType::QmlDocument}, {directoryPathId, qmlDocumentSourceId2, exampleModuleId, FileType::QmlDocument}}); - setFilesDontChanged({qmlDirPathSourceId, qmltypes2PathSourceId, qmlDocumentSourceId2}); + setFilesUnchanged({qmlDirPathSourceId, qmltypes2PathSourceId, qmlDocumentSourceId2}); EXPECT_CALL(projectStorageMock, synchronize(AllOf( @@ -1752,10 +1820,12 @@ TEST_F(ProjectStorageUpdater, synchroniz_if_qmldir_file_not_changed_and_some_rem {directoryPathId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathId, qmlDocumentSourceId1, exampleModuleId, FileType::QmlDocument}, {directoryPathId, qmlDocumentSourceId2, exampleModuleId, FileType::QmlDocument}}); - setFilesDontChanged({qmlDirPathSourceId, qmltypes2PathSourceId, qmlDocumentSourceId2}); + setFilesUnchanged({qmlDirPathSourceId, qmltypes2PathSourceId, qmlDocumentSourceId2}); setFilesRemoved({qmltypesPathSourceId, qmlDocumentSourceId1}); - ASSERT_THROW(updater.update({.qtDirectories = directories}), QmlDesigner::CannotParseQmlTypesFile); + EXPECT_CALL(errorNotifierMock, qmltypesFileMissing(Eq(u"/path/example.qmltypes"_s))); + + updater.update({.qtDirectories = directories}); } TEST_F(ProjectStorageUpdater, synchroniz_if_qmldir_file_has_changed_and_some_removed_files) @@ -1770,7 +1840,7 @@ TEST_F(ProjectStorageUpdater, synchroniz_if_qmldir_file_has_changed_and_some_rem {directoryPathId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathId, qmlDocumentSourceId1, exampleModuleId, FileType::QmlDocument}, {directoryPathId, qmlDocumentSourceId2, exampleModuleId, FileType::QmlDocument}}); - setFilesDontChanged({qmltypes2PathSourceId, qmlDocumentSourceId2}); + setFilesUnchanged({qmltypes2PathSourceId, qmlDocumentSourceId2}); setFilesRemoved({qmltypesPathSourceId, qmlDocumentSourceId1}); EXPECT_CALL( @@ -2259,7 +2329,7 @@ TEST_F(ProjectStorageUpdater, update_path_watcher_directories) TEST_F(ProjectStorageUpdater, update_path_watcher_directory_does_not_exists) { - setFilesDontExists({path2SourceId}); + setFilesNotExists({path2SourceId}); EXPECT_CALL(patchWatcherMock, updateIdPaths(Contains(IdPaths{qtPartId, @@ -2271,7 +2341,7 @@ TEST_F(ProjectStorageUpdater, update_path_watcher_directory_does_not_exists) TEST_F(ProjectStorageUpdater, update_path_watcher_directory_does_not_changed) { - setFilesDontChanged({qmldir1SourceId, qmldir2SourceId, path1SourceId, path2SourceId}); + setFilesUnchanged({qmldir1SourceId, qmldir2SourceId, path1SourceId, path2SourceId}); EXPECT_CALL(patchWatcherMock, updateIdPaths(Contains(IdPaths{qtPartId, @@ -2304,7 +2374,7 @@ TEST_F(ProjectStorageUpdater, update_path_watcher_qmldirs) TEST_F(ProjectStorageUpdater, update_path_watcher_qmldir_does_not_exists) { - setFilesDontExists({qmldir2SourceId}); + setFilesNotExists({qmldir2SourceId}); EXPECT_CALL(patchWatcherMock, updateIdPaths(Contains(IdPaths{qtPartId, @@ -2316,7 +2386,7 @@ TEST_F(ProjectStorageUpdater, update_path_watcher_qmldir_does_not_exists) TEST_F(ProjectStorageUpdater, update_path_watcher_qmldir_does_not_changed) { - setFilesDontChanged({qmldir1SourceId, qmldir2SourceId, path1SourceId, path2SourceId}); + setFilesUnchanged({qmldir1SourceId, qmldir2SourceId, path1SourceId, path2SourceId}); EXPECT_CALL(patchWatcherMock, updateIdPaths(Contains(IdPaths{qtPartId, @@ -2362,7 +2432,7 @@ TEST_F(ProjectStorageUpdater, update_path_watcher_only_qml_files_dont_changed) setQmlFileNames(u"/path/one", {"First.qml", "Second.qml"}); setQmlFileNames(u"/path/two", {"Third.qml"}); setContent(u"/path/one/qmldir", qmldir1); - setFilesDontChanged({firstSourceId, secondSourceId, thirdSourceId}); + setFilesUnchanged({firstSourceId, secondSourceId, thirdSourceId}); EXPECT_CALL(patchWatcherMock, updateIdPaths(Contains(IdPaths{qtPartId, @@ -2374,7 +2444,7 @@ TEST_F(ProjectStorageUpdater, update_path_watcher_only_qml_files_dont_changed) TEST_F(ProjectStorageUpdater, update_path_watcher_only_qml_files_changed) { - setFilesDontChanged({qmldir1SourceId, qmldir2SourceId, path1SourceId, path2SourceId}); + setFilesUnchanged({qmldir1SourceId, qmldir2SourceId, path1SourceId, path2SourceId}); setFilesChanged({firstSourceId, secondSourceId, thirdSourceId}); setDirectoryInfos(path1SourceContextId, {{path1SourceContextId, firstSourceId, exampleModuleId, FileType::QmlDocument}, @@ -2392,13 +2462,13 @@ TEST_F(ProjectStorageUpdater, update_path_watcher_only_qml_files_changed) TEST_F(ProjectStorageUpdater, update_path_watcher_qml_files_and_directories_dont_changed) { - setFilesDontChanged({qmldir1SourceId, - qmldir2SourceId, - path1SourceId, - path2SourceId, - firstSourceId, - secondSourceId, - thirdSourceId}); + setFilesUnchanged({qmldir1SourceId, + qmldir2SourceId, + path1SourceId, + path2SourceId, + firstSourceId, + secondSourceId, + thirdSourceId}); setDirectoryInfos(path1SourceContextId, {{path1SourceContextId, firstSourceId, exampleModuleId, FileType::QmlDocument}, {path1SourceContextId, secondSourceId, exampleModuleId, FileType::QmlDocument}}); @@ -2422,7 +2492,7 @@ TEST_F(ProjectStorageUpdater, update_path_watcher_qmltypes_files_in_qmldir) setContent(u"/path/one/qmldir", qmldir1); setContent(u"/path/two/qmldir", qmldir2); - setFilesDontChanged({firstSourceId, secondSourceId, thirdSourceId}); + setFilesUnchanged({firstSourceId, secondSourceId, thirdSourceId}); EXPECT_CALL(patchWatcherMock, updateIdPaths(Contains(IdPaths{qtPartId, @@ -2440,7 +2510,7 @@ TEST_F(ProjectStorageUpdater, update_path_watcher_only_qmltypes_files_in_qmldir_ typeinfo example2.qmltypes)"}; setContent(u"/path/one/qmldir", qmldir1); setContent(u"/path/two/qmldir", qmldir2); - setFilesDontChanged({qmltypes1SourceId, qmltypes2SourceId}); + setFilesUnchanged({qmltypes1SourceId, qmltypes2SourceId}); EXPECT_CALL(patchWatcherMock, updateIdPaths(Contains(IdPaths{qtPartId, @@ -2452,7 +2522,7 @@ TEST_F(ProjectStorageUpdater, update_path_watcher_only_qmltypes_files_in_qmldir_ TEST_F(ProjectStorageUpdater, update_path_watcher_only_qmltypes_files_changed) { - setFilesDontChanged({qmldir1SourceId, qmldir2SourceId, path1SourceId, path2SourceId}); + setFilesUnchanged({qmldir1SourceId, qmldir2SourceId, path1SourceId, path2SourceId}); setFilesChanged({qmltypes1SourceId, qmltypes2SourceId}); setDirectoryInfos(path1SourceContextId, {{path1SourceContextId, qmltypes1SourceId, exampleModuleId, FileType::QmlTypes}}); @@ -2469,12 +2539,12 @@ TEST_F(ProjectStorageUpdater, update_path_watcher_only_qmltypes_files_changed) TEST_F(ProjectStorageUpdater, update_path_watcher_qmltypes_files_and_directories_dont_changed) { - setFilesDontChanged({qmldir1SourceId, - qmldir2SourceId, - path1SourceId, - path2SourceId, - qmltypes1SourceId, - qmltypes2SourceId}); + setFilesUnchanged({qmldir1SourceId, + qmldir2SourceId, + path1SourceId, + path2SourceId, + qmltypes1SourceId, + qmltypes2SourceId}); setDirectoryInfos(path1SourceContextId, {{path1SourceContextId, qmltypes1SourceId, exampleModuleId, FileType::QmlTypes}}); setDirectoryInfos(path2SourceContextId, @@ -2490,7 +2560,7 @@ TEST_F(ProjectStorageUpdater, update_path_watcher_qmltypes_files_and_directories TEST_F(ProjectStorageUpdater, synchronize_qml_documents_without_qmldir) { - setFilesDontExists({qmlDirPathSourceId}); + setFilesNotExists({qmlDirPathSourceId}); setFilesChanged({directoryPathSourceId}); EXPECT_CALL( @@ -2559,7 +2629,7 @@ TEST_F(ProjectStorageUpdater, synchronize_qml_documents_without_qmldir) TEST_F(ProjectStorageUpdater, warn_about_non_existing_qml_document) { - setFilesDontExists({qmlDocumentSourceId1}); + setFilesNotExists({qmlDocumentSourceId1}); setFilesAdded({directoryPathSourceId}); QString qmldir{R"(module Example FirstType 1.0 First.qml @@ -2579,7 +2649,7 @@ TEST_F(ProjectStorageUpdater, warn_about_non_existing_qml_document) TEST_F(ProjectStorageUpdater, synchronize_qml_documents_without_parsed_type_if_qml_document_does_not_exists) { - setFilesDontExists({qmlDocumentSourceId1}); + setFilesNotExists({qmlDocumentSourceId1}); setFilesAdded({directoryPathSourceId, qmlDirPathSourceId, qmlDocumentSourceId2}); QString qmldir{R"(module Example FirstType 1.0 First.qml @@ -2694,10 +2764,10 @@ TEST_F(ProjectStorageUpdater, synchronize_qml_documents_without_qmldir_if_direct TEST_F(ProjectStorageUpdater, synchronize_qml_documents_without_qmldir_add_qml_document) { - setFilesDontExistsUnchanged({qmlDirPathSourceId}); + setFilesNotExistsUnchanged({qmlDirPathSourceId}); setFilesChanged({directoryPathSourceId}); setFilesAdded({qmlDocumentSourceId3}); - setFilesDontChanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); + setFilesUnchanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); setDirectoryInfos(directoryPathId, {{directoryPathId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument}, {directoryPathId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument}}); @@ -2752,10 +2822,10 @@ TEST_F(ProjectStorageUpdater, synchronize_qml_documents_without_qmldir_add_qml_d TEST_F(ProjectStorageUpdater, synchronize_qml_documents_without_qmldir_removes_qml_document) { - setFilesDontExists({qmlDirPathSourceId}); + setFilesNotExists({qmlDirPathSourceId}); setFilesChanged({directoryPathSourceId}); setFilesRemoved({qmlDocumentSourceId3}); - setFilesDontChanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); + setFilesUnchanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); setQmlFileNames(u"/path", {"First.qml", "First2.qml"}); setDirectoryInfos(directoryPathId, {{directoryPathId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument}, @@ -2802,7 +2872,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories) SecondType 2.2 Second.qml)"}; setContent(u"/path/qmldir", qmldir); setFilesChanged({directoryPathSourceId}); - setFilesDontChanged({qmlDirPathSourceId}); + setFilesUnchanged({qmlDirPathSourceId}); EXPECT_CALL( projectStorageMock, @@ -2880,7 +2950,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_subdirectories) SourceId rootPathSourceId = SourceId::create(QmlDesigner::SourceNameId{}, rootPathId); SourceId rootQmldirPathSourceId = sourcePathCache.sourceId("/root/qmldir"); setFilesChanged({directoryPathSourceId, rootPathSourceId}); - setFilesDontChanged({qmlDirPathSourceId, rootQmldirPathSourceId}); + setFilesUnchanged({qmlDirPathSourceId, rootQmldirPathSourceId}); setSubdirectoryPaths(u"/root", {"/path"}); setSubdirectorySourceIds(rootPathId, {directoryPathId}); @@ -2988,7 +3058,7 @@ TEST_F(ProjectStorageUpdater, watcher_watches_directories_after_directory_change SecondType 2.2 Second.qml)"}; setContent(u"/path/qmldir", qmldir); setFilesChanged({directoryPathSourceId}); - setFilesDontChanged({qmlDirPathSourceId}); + setFilesUnchanged({qmlDirPathSourceId}); auto directorySourceContextId = directoryPathSourceId.contextId(); EXPECT_CALL(patchWatcherMock, @@ -3138,7 +3208,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_add_only_qml_document_in_directory FirstType 1.0 First.qml)"}; setContent(u"/path/qmldir", qmldir); setFilesChanged({directoryPathSourceId}); - setFilesDontChanged({qmlDirPathSourceId, qmlDocumentSourceId1}); + setFilesUnchanged({qmlDirPathSourceId, qmlDocumentSourceId1}); setFilesAdded({qmlDocumentSourceId2}); setDirectoryInfos(directoryPathId, {{directoryPathId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument}}); @@ -3206,7 +3276,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_removes_qml_document) )"}; setContent(u"/path/qmldir", qmldir); setFilesChanged({qmlDirPathSourceId}); - setFilesDontChanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); + setFilesUnchanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); setFilesRemoved({qmlDocumentSourceId3}); setDirectoryInfos(directoryPathId, {{directoryPathId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument}, @@ -3276,7 +3346,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_removes_qml_document_in_qmldir_onl )"}; setContent(u"/path/qmldir", qmldir); setFilesChanged({qmlDirPathSourceId}); - setFilesDontChanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); + setFilesUnchanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); setDirectoryInfos(directoryPathId, {{directoryPathId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument}, {directoryPathId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument}}); @@ -3340,7 +3410,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories_add_qml_document_to_qm )"}; setContent(u"/path/qmldir", qmldir); setFilesChanged({qmlDirPathSourceId}); - setFilesDontChanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); + setFilesUnchanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); setDirectoryInfos(directoryPathId, {{directoryPathId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument}, {directoryPathId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument}}); @@ -3403,7 +3473,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories_remove_qml_document_fr FirstType 1.0 First.qml )"}; setContent(u"/path/qmldir", qmldir); - setFilesDontChanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); + setFilesUnchanged({qmlDocumentSourceId1, qmlDocumentSourceId2}); setFilesChanged({qmlDirPathSourceId}); setDirectoryInfos(directoryPathId, {{directoryPathId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument}, @@ -3467,7 +3537,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories_dont_update_qml_docume FirstType 2.2 First2.qml SecondType 2.2 Second.qml)"}; setContent(u"/path/qmldir", qmldir); - setFilesDontChanged({qmlDocumentSourceId3}); + setFilesUnchanged({qmlDocumentSourceId3}); EXPECT_CALL( projectStorageMock, @@ -3540,7 +3610,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_qmldirs_dont_update_qml_documents_ FirstType 2.2 First2.qml SecondType 2.2 Second.qml)"}; setContent(u"/path/qmldir", qmldir); - setFilesDontChanged({qmlDocumentSourceId3}); + setFilesUnchanged({qmlDocumentSourceId3}); EXPECT_CALL( projectStorageMock, @@ -3613,7 +3683,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directory_but_not_qmldir) {directoryPathId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathId, qmlDocumentSourceId1, exampleModuleId, FileType::QmlDocument}, {directoryPathId, qmlDocumentSourceId2, exampleModuleId, FileType::QmlDocument}}); - setFilesDontChanged({qmlDirPathSourceId}); + setFilesUnchanged({qmlDirPathSourceId}); EXPECT_CALL(projectStorageMock, synchronize(AllOf( @@ -3704,7 +3774,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_qml_documents) TEST_F(ProjectStorageUpdater, watcher_updates_removed_qml_documents) { - setFilesDontExistsUnchanged({annotationDirectorySourceId, qmlDirPathSourceId}); + setFilesNotExistsUnchanged({annotationDirectorySourceId, qmlDirPathSourceId}); setFilesRemoved({qmlDocumentSourceId2}); setFilesChanged({qmlDocumentSourceId1}); @@ -3761,7 +3831,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_qmltypes) setDirectoryInfos(directoryPathId, {{directoryPathId, qmltypesPathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}}); - setFilesDontChanged( + setFilesUnchanged( {directoryPathSourceId, qmlDirPathSourceId, qmlDocumentSourceId1, qmlDocumentSourceId2}); EXPECT_CALL(projectStorageMock, @@ -3790,12 +3860,12 @@ TEST_F(ProjectStorageUpdater, watcher_updates_qmltypes) {{qmltypesProjectChunkId, {qmltypesPathSourceId, qmltypes2PathSourceId}}}); } -TEST_F(ProjectStorageUpdater, watcher_updates_removed_qmltypes_without_updated_qmldir) +TEST_F(ProjectStorageUpdater, DISABLED_watcher_updates_removed_qmltypes_without_updated_qmldir) { setDirectoryInfos(directoryPathId, {{directoryPathId, qmltypesPathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}}); - setFilesDontChanged( + setFilesUnchanged( {directoryPathSourceId, qmlDirPathSourceId, qmlDocumentSourceId1, qmlDocumentSourceId2}); setFilesRemoved({qmltypesPathSourceId}); @@ -3810,7 +3880,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_removed_qmltypes_with_updated_qmld setDirectoryInfos(directoryPathId, {{directoryPathId, qmltypesPathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}}); - setFilesDontChanged( + setFilesUnchanged( {directoryPathSourceId, qmlDirPathSourceId, qmlDocumentSourceId1, qmlDocumentSourceId2}); setFilesRemoved({qmltypesPathSourceId}); updater.pathsWithIdsChanged( @@ -3858,7 +3928,7 @@ TEST_F(ProjectStorageUpdater, watcher_dont_watches_directories_after_qmltypes_ch setDirectoryInfos(directoryPathId, {{directoryPathId, qmltypesPathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}}); - setFilesDontChanged( + setFilesUnchanged( {directoryPathSourceId, qmlDirPathSourceId, qmlDocumentSourceId1, qmlDocumentSourceId2}); EXPECT_CALL(patchWatcherMock, updateContextIdPaths(_, _)).Times(0); @@ -3872,7 +3942,7 @@ TEST_F(ProjectStorageUpdater, watcher_dont_updates_qmltypes_for_other_projects) setDirectoryInfos(directoryPathId, {{directoryPathId, qmltypesPathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}}); - setFilesDontChanged( + setFilesUnchanged( {directoryPathSourceId, qmlDirPathSourceId, qmlDocumentSourceId1, qmlDocumentSourceId2}); EXPECT_CALL(projectStorageMock, synchronize(PackageIsEmpty())); @@ -3889,7 +3959,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_directories_and_but_not_included_q SecondType 2.2 Second.qml)"}; setContent(u"/path/qmldir", qmldir); setFilesChanged({directoryPathSourceId}); - setFilesDontChanged({qmlDirPathSourceId}); + setFilesUnchanged({qmlDirPathSourceId}); EXPECT_CALL( projectStorageMock, @@ -3965,7 +4035,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_qmldir_and_but_not_included_qml_do FirstType 2.2 First2.qml SecondType 2.2 Second.qml)"}; setContent(u"/path/qmldir", qmldir); - setFilesDontChanged({directoryPathSourceId}); + setFilesUnchanged({directoryPathSourceId}); setFilesChanged({qmlDirPathSourceId}); EXPECT_CALL( @@ -4052,7 +4122,7 @@ TEST_F(ProjectStorageUpdater, watcher_updates_qmldir_and_but_not_included_qmltyp typeinfo example.qmltypes typeinfo example2.qmltypes)"}; setContent(u"/path/qmldir", qmldir); - setFilesDontChanged({directoryPathSourceId}); + setFilesUnchanged({directoryPathSourceId}); setFilesChanged({qmlDirPathSourceId, qmltypesPathSourceId, qmltypes2PathSourceId, @@ -4170,7 +4240,7 @@ TEST_F(ProjectStorageUpdater, input_is_reused_next_call_if_an_error_happens) setDirectoryInfos(directoryPathId, {{directoryPathId, qmltypesPathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}}); - setFilesDontChanged({directoryPathSourceId, qmlDirPathSourceId}); + setFilesUnchanged({directoryPathSourceId, qmlDirPathSourceId}); ON_CALL(projectStorageMock, synchronize(_)) .WillByDefault(Throw(QmlDesigner::TypeHasInvalidSourceId{})); updater.pathsWithIdsChanged( @@ -4235,7 +4305,7 @@ TEST_F(ProjectStorageUpdater, input_is_reused_next_call_if_an_error_happens_and_ setDirectoryInfos(directoryPathId, {{directoryPathId, qmltypesPathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}}); - setFilesDontChanged({directoryPathSourceId, qmlDirPathSourceId}); + setFilesUnchanged({directoryPathSourceId, qmlDirPathSourceId}); ON_CALL(projectStorageMock, synchronize(_)) .WillByDefault(Throw(QmlDesigner::TypeHasInvalidSourceId{})); updater.pathsWithIdsChanged( @@ -4304,7 +4374,7 @@ TEST_F(ProjectStorageUpdater, input_is_reused_next_call_if_an_error_happens_and_ {directoryPathId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathId, qmlDocumentSourceId1, QmlDesigner::ModuleId{}, FileType::QmlDocument}, {directoryPathId, qmlDocumentSourceId1, QmlDesigner::ModuleId{}, FileType::QmlDocument}}); - setFilesDontChanged({directoryPathSourceId, qmlDirPathSourceId}); + setFilesUnchanged({directoryPathSourceId, qmlDirPathSourceId}); ON_CALL(projectStorageMock, synchronize(_)) .WillByDefault(Throw(QmlDesigner::TypeHasInvalidSourceId{})); updater.pathsWithIdsChanged( @@ -4370,7 +4440,7 @@ TEST_F(ProjectStorageUpdater, input_is_cleared_after_successful_update) setDirectoryInfos(directoryPathId, {{directoryPathId, qmltypesPathSourceId, exampleModuleId, FileType::QmlTypes}, {directoryPathId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes}}); - setFilesDontChanged({directoryPathSourceId, qmlDirPathSourceId}); + setFilesUnchanged({directoryPathSourceId, qmlDirPathSourceId}); updater.pathsWithIdsChanged( {{qmltypesProjectChunkId, {qmltypesPathSourceId, qmltypes2PathSourceId}}}); @@ -4548,7 +4618,7 @@ TEST_F(ProjectStorageUpdater, update_added_type_annotation) QmlDesigner::SourcePath{itemLibraryPath + "/quick.metainfo"}); auto qtQuickControlSourceId = sourcePathCache.sourceId( QmlDesigner::SourcePath{itemLibraryPath + "/qtquickcontrols2.metainfo"}); - setFilesDontChanged({itemLibraryPathSourceId}); + setFilesUnchanged({itemLibraryPathSourceId}); setFilesAdded({qtQuickSourceId, qtQuickControlSourceId}); auto qtQuickModuleId = moduleId("QtQuick", ModuleKind::QmlLibrary); auto qtQuickControlsModuleId = moduleId("QtQuick.Controls.Basic", ModuleKind::QmlLibrary); @@ -4587,7 +4657,7 @@ TEST_F(ProjectStorageUpdater, update_changed_type_annotation) QmlDesigner::SourcePath{itemLibraryPath + "/quick.metainfo"}); auto qtQuickControlSourceId = sourcePathCache.sourceId( QmlDesigner::SourcePath{itemLibraryPath + "/qtquickcontrols2.metainfo"}); - setFilesDontChanged({itemLibraryPathSourceId}); + setFilesUnchanged({itemLibraryPathSourceId}); setFilesChanged({qtQuickSourceId, qtQuickControlSourceId}); auto qtQuickModuleId = moduleId("QtQuick", ModuleKind::QmlLibrary); auto qtQuickControlsModuleId = moduleId("QtQuick.Controls.Basic", ModuleKind::QmlLibrary); @@ -4657,7 +4727,7 @@ TEST_F(ProjectStorageUpdater, update_type_annotations_removed_meta_info_file) .WillByDefault(Return(QmlDesigner::SmallSourceIds<4>{qtQuickSourceId, qtQuickControlSourceId})); setFilesChanged({itemLibraryPathSourceId}); setFilesRemoved({qtQuickSourceId}); - setFilesDontChanged({qtQuickControlSourceId}); + setFilesUnchanged({qtQuickControlSourceId}); EXPECT_CALL(projectStorageMock, synchronize(AllOf(Field("SynchronizationPackage::typeAnnotations", @@ -4707,7 +4777,7 @@ TEST_F(ProjectStorageUpdater, synchronize_added_property_editor_qml_paths_direct setSubdirectoryPaths(u"/path/one", {"/path/one/designer"}); SourceContextId designer1DirectoryId = sourcePathCache.sourceContextId("/path/one/designer"); SourceId designer1SourceId = SourceId::create(QmlDesigner::SourceNameId{}, designer1DirectoryId); - setFilesDontChanged({path1SourceId}); + setFilesUnchanged({path1SourceId}); setFilesAdded({designer1SourceId}); EXPECT_CALL(projectStorageMock, @@ -4741,7 +4811,7 @@ TEST_F(ProjectStorageUpdater, synchronize_changed_property_editor_qml_paths_dire setSubdirectoryPaths(u"/path/one", {"/path/one/designer"}); SourceContextId designer1DirectoryId = sourcePathCache.sourceContextId("/path/one/designer"); SourceId designer1SourceId = SourceId::create(QmlDesigner::SourceNameId{}, designer1DirectoryId); - setFilesDontChanged({path1SourceId}); + setFilesUnchanged({path1SourceId}); setFilesChanged({designer1SourceId}); EXPECT_CALL(projectStorageMock, @@ -4776,7 +4846,7 @@ TEST_F(ProjectStorageUpdater, dont_synchronize_empty_property_editor_qml_paths_d SourceContextId designer2DirectoryId = sourcePathCache.sourceContextId("/path/two/designer"); SourceId designer2SourceId = SourceId::create(QmlDesigner::SourceNameId{}, designer2DirectoryId); setFilesChanged({path2SourceId}); - setFilesDontExists({designer2SourceId}); + setFilesNotExists({designer2SourceId}); EXPECT_CALL(projectStorageMock, synchronize( @@ -4807,7 +4877,7 @@ TEST_F(ProjectStorageUpdater, remove_property_editor_qml_paths_if_designer_direc { SourceContextId designer1DirectoryId = sourcePathCache.sourceContextId("/path/one/designer"); SourceId designer1SourceId = SourceId::create(QmlDesigner::SourceNameId{}, designer1DirectoryId); - setFilesDontChanged({path1SourceId, qmldir1SourceId}); + setFilesUnchanged({path1SourceId, qmldir1SourceId}); setFilesRemoved({designer1SourceId}); EXPECT_CALL(projectStorageMock, @@ -4849,7 +4919,7 @@ TEST_F(ProjectStorageUpdater, "/path/one/designer/CaoPane.qml"); SourceId designer1SourceId = SourceId::create(QmlDesigner::SourceNameId{}, designer1DirectoryId); setFilesChanged({designer1SourceId}); - setFilesDontChanged({path1SourceId, qmldir1SourceId}); + setFilesUnchanged({path1SourceId, qmldir1SourceId}); auto barModuleId = storage.moduleId("Bar", ModuleKind::QmlLibrary); setFileNames(u"/path/one/designer", {"FooSpecifics.qml", "HuoSpecificsDynamic.qml", "CaoPane.qml"}, @@ -4893,7 +4963,7 @@ TEST_F(ProjectStorageUpdater, "/path/one/designer/CaoPane.qml"); SourceId designer1SourceId = SourceId::create(QmlDesigner::SourceNameId{}, designer1DirectoryId); setFilesChanged({path1SourceId}); - setFilesDontChanged({qmldir1SourceId, designer1SourceId}); + setFilesUnchanged({qmldir1SourceId, designer1SourceId}); auto barModuleId = storage.moduleId("Bar", ModuleKind::QmlLibrary); setFileNames(u"/path/one/designer", {"FooSpecifics.qml", "HuoSpecificsDynamic.qml", "CaoPane.qml"}, @@ -4936,7 +5006,7 @@ TEST_F(ProjectStorageUpdater, synchronize_property_editor_qml_paths_directory_if "/path/one/designer/CaoPane.qml"); SourceId designer1SourceId = SourceId::create(QmlDesigner::SourceNameId{}, designer1DirectoryId); setFilesChanged({qmldir1SourceId}); - setFilesDontChanged({path1SourceId, designer1SourceId}); + setFilesUnchanged({path1SourceId, designer1SourceId}); auto barModuleId = storage.moduleId("Bar", ModuleKind::QmlLibrary); setFileNames(u"/path/one/designer", {"FooSpecifics.qml", "HuoSpecificsDynamic.qml", "CaoPane.qml"},