forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/qmlprojectstorage'
Conflicts: src/plugins/qmldesigner/qmldesignerprojectmanager.cpp src/plugins/qmlprojectmanager/qmlproject.cpp src/plugins/qmlprojectmanager/qmlproject.h Change-Id: I0c0d59c8e3b8455b6ac575d34fdf49f39388db7a Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -26,7 +26,6 @@
|
||||
#include "googletest.h"
|
||||
|
||||
#include "filesystemmock.h"
|
||||
#include "projectmanagermock.h"
|
||||
#include "projectstoragemock.h"
|
||||
#include "qmldocumentparsermock.h"
|
||||
#include "qmltypesparsermock.h"
|
||||
@@ -48,6 +47,10 @@ using QmlDesigner::Storage::TypeAccessSemantics;
|
||||
namespace Storage = QmlDesigner::Storage;
|
||||
using QmlDesigner::IdPaths;
|
||||
using QmlDesigner::Storage::FileType;
|
||||
using QmlDesigner::Storage::Import;
|
||||
using QmlDesigner::Storage::IsAutoVersion;
|
||||
using QmlDesigner::Storage::ModuleExportedImport;
|
||||
using QmlDesigner::Storage::ProjectData;
|
||||
using QmlDesigner::Storage::SynchronizationPackage;
|
||||
using QmlDesigner::Storage::Version;
|
||||
|
||||
@@ -120,7 +123,7 @@ MATCHER_P4(IsProjectData,
|
||||
{
|
||||
const Storage::ProjectData &projectData = arg;
|
||||
|
||||
return projectData.projectSourceId == projectSourceId && projectData.sourceId == sourceId
|
||||
return &projectData.projectSourceId == &projectSourceId && projectData.sourceId == sourceId
|
||||
&& projectData.moduleId == moduleId && projectData.fileType == fileType;
|
||||
}
|
||||
|
||||
@@ -130,7 +133,9 @@ MATCHER(PackageIsEmpty, std::string(negation ? "isn't empty" : "is empty"))
|
||||
|
||||
return package.imports.empty() && package.types.empty() && package.fileStatuses.empty()
|
||||
&& package.updatedSourceIds.empty() && package.projectDatas.empty()
|
||||
&& package.updatedFileStatusSourceIds.empty() && package.updatedProjectSourceIds.empty();
|
||||
&& package.updatedFileStatusSourceIds.empty() && package.updatedProjectSourceIds.empty()
|
||||
&& package.moduleDependencies.empty() && package.updatedModuleDependencySourceIds.empty()
|
||||
&& package.moduleExportedImports.empty() && package.updatedModuleIds.empty();
|
||||
}
|
||||
|
||||
class ProjectStorageUpdater : public testing::Test
|
||||
@@ -153,7 +158,6 @@ public:
|
||||
ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmlDirPathSourceId)))
|
||||
.WillByDefault(Return(FileStatus{qmlDirPathSourceId, 2, 421}));
|
||||
|
||||
ON_CALL(projectManagerMock, qtQmlDirs()).WillByDefault(Return(QStringList{"/path/qmldir"}));
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir"))))
|
||||
.WillByDefault(Return(qmldirContent));
|
||||
|
||||
@@ -169,8 +173,9 @@ public:
|
||||
.WillByDefault(Return(FileStatus{qmlDocumentSourceId3, 22, 14}));
|
||||
ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmlDocumentSourceId3)))
|
||||
.WillByDefault(Return(FileStatus{qmlDocumentSourceId3, 22, 2}));
|
||||
ON_CALL(projectStorageMock, moduleId(Eq("Example"))).WillByDefault(Return(exampleModuleId));
|
||||
ON_CALL(projectStorageMock, moduleId(Eq("Qml"))).WillByDefault(Return(qmlModuleId));
|
||||
ON_CALL(projectStorageMock, moduleId(_)).WillByDefault([&](const auto &name) {
|
||||
return storage.moduleId(name);
|
||||
});
|
||||
|
||||
firstType.prototype = Storage::ImportedType{"Object"};
|
||||
secondType.prototype = Storage::ImportedType{"Object2"};
|
||||
@@ -178,27 +183,30 @@ public:
|
||||
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First.qml"))))
|
||||
.WillByDefault(Return(qmlDocument1));
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First.2.qml"))))
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First2.qml"))))
|
||||
.WillByDefault(Return(qmlDocument2));
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/Second.qml"))))
|
||||
.WillByDefault(Return(qmlDocument3));
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes"))))
|
||||
.WillByDefault(Return(qmltypes1));
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example2.qmltypes"))))
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/types/example2.qmltypes"))))
|
||||
.WillByDefault(Return(qmltypes2));
|
||||
|
||||
ON_CALL(qmlDocumentParserMock, parse(qmlDocument1, _)).WillByDefault([&](auto, auto &imports) {
|
||||
imports.push_back(import1);
|
||||
return firstType;
|
||||
});
|
||||
ON_CALL(qmlDocumentParserMock, parse(qmlDocument2, _)).WillByDefault([&](auto, auto &imports) {
|
||||
imports.push_back(import2);
|
||||
return secondType;
|
||||
});
|
||||
ON_CALL(qmlDocumentParserMock, parse(qmlDocument3, _)).WillByDefault([&](auto, auto &imports) {
|
||||
imports.push_back(import3);
|
||||
return thirdType;
|
||||
});
|
||||
ON_CALL(qmlDocumentParserMock, parse(qmlDocument1, _, _, _))
|
||||
.WillByDefault([&](auto, auto &imports, auto, auto) {
|
||||
imports.push_back(import1);
|
||||
return firstType;
|
||||
});
|
||||
ON_CALL(qmlDocumentParserMock, parse(qmlDocument2, _, _, _))
|
||||
.WillByDefault([&](auto, auto &imports, auto, auto) {
|
||||
imports.push_back(import2);
|
||||
return secondType;
|
||||
});
|
||||
ON_CALL(qmlDocumentParserMock, parse(qmlDocument3, _, _, _))
|
||||
.WillByDefault([&](auto, auto &imports, auto, auto) {
|
||||
imports.push_back(import3);
|
||||
return thirdType;
|
||||
});
|
||||
ON_CALL(qmlTypesParserMock, parse(Eq(qmltypes1), _, _, _))
|
||||
.WillByDefault([&](auto, auto &imports, auto &types, auto) {
|
||||
types.push_back(objectType);
|
||||
@@ -212,7 +220,6 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
NiceMock<ProjectManagerMock> projectManagerMock;
|
||||
NiceMock<FileSystemMock> fileSystemMock;
|
||||
NiceMock<ProjectStorageMock> projectStorageMock;
|
||||
NiceMock<QmlTypesParserMock> qmlTypesParserMock;
|
||||
@@ -222,29 +229,36 @@ protected:
|
||||
QmlDesigner::ProjectStorage<Sqlite::Database> storage{database, database.isInitialized()};
|
||||
QmlDesigner::SourcePathCache<QmlDesigner::ProjectStorage<Sqlite::Database>> sourcePathCache{
|
||||
storage};
|
||||
QmlDesigner::ProjectUpdater updater{projectManagerMock,
|
||||
fileSystemMock,
|
||||
projectStorageMock,
|
||||
fileStatusCache,
|
||||
sourcePathCache,
|
||||
qmlDocumentParserMock,
|
||||
qmlTypesParserMock};
|
||||
QmlDesigner::ProjectStorageUpdater updater{fileSystemMock,
|
||||
projectStorageMock,
|
||||
fileStatusCache,
|
||||
sourcePathCache,
|
||||
qmlDocumentParserMock,
|
||||
qmlTypesParserMock};
|
||||
SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/path/example.qmltypes");
|
||||
SourceId qmltypes2PathSourceId = sourcePathCache.sourceId("/path/example2.qmltypes");
|
||||
SourceId qmltypes2PathSourceId = sourcePathCache.sourceId("/path/types/example2.qmltypes");
|
||||
SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/path/qmldir");
|
||||
SourceId qmlDocumentSourceId1 = sourcePathCache.sourceId("/path/First.qml");
|
||||
SourceId qmlDocumentSourceId2 = sourcePathCache.sourceId("/path/First.2.qml");
|
||||
SourceId qmlDocumentSourceId2 = sourcePathCache.sourceId("/path/First2.qml");
|
||||
SourceId qmlDocumentSourceId3 = sourcePathCache.sourceId("/path/Second.qml");
|
||||
ModuleId qmlModuleId{storage.moduleId("Qml")};
|
||||
ModuleId qmlCppNativeModuleId{storage.moduleId("Qml-cppnative")};
|
||||
ModuleId exampleModuleId{storage.moduleId("Example")};
|
||||
ModuleId exampleCppNativeModuleId{storage.moduleId("Example-cppnative")};
|
||||
ModuleId builtinModuleId{storage.moduleId("QML")};
|
||||
ModuleId builtinCppNativeModuleId{storage.moduleId("QML-cppnative")};
|
||||
ModuleId quickModuleId{storage.moduleId("Quick")};
|
||||
ModuleId quickCppNativeModuleId{storage.moduleId("Quick-cppnative")};
|
||||
ModuleId pathModuleId{storage.moduleId("/path")};
|
||||
ModuleId subPathQmlModuleId{storage.moduleId("/path/qml")};
|
||||
Storage::Type objectType{"QObject",
|
||||
Storage::NativeType{},
|
||||
Storage::ImportedType{},
|
||||
Storage::TypeAccessSemantics::Reference,
|
||||
qmltypesPathSourceId,
|
||||
{Storage::ExportedType{exampleModuleId, "Object"},
|
||||
Storage::ExportedType{exampleModuleId, "Obj"}}};
|
||||
Storage::Type itemType{"QItem",
|
||||
Storage::NativeType{},
|
||||
Storage::ImportedType{},
|
||||
Storage::TypeAccessSemantics::Reference,
|
||||
qmltypes2PathSourceId,
|
||||
{Storage::ExportedType{exampleModuleId, "Item"}}};
|
||||
@@ -262,6 +276,7 @@ protected:
|
||||
QString qmldirContent{"module Example\ntypeinfo example.qmltypes\n"};
|
||||
QString qmltypes1{"Module {\ndependencies: [module1]}"};
|
||||
QString qmltypes2{"Module {\ndependencies: [module2]}"};
|
||||
QStringList qmlDirs = {"/path/qmldir"};
|
||||
};
|
||||
|
||||
TEST_F(ProjectStorageUpdater, GetContentForQmlDirPathsIfFileStatusIsDifferent)
|
||||
@@ -269,9 +284,7 @@ TEST_F(ProjectStorageUpdater, GetContentForQmlDirPathsIfFileStatusIsDifferent)
|
||||
SourceId qmlDir1PathSourceId = sourcePathCache.sourceId("/path/one/qmldir");
|
||||
SourceId qmlDir2PathSourceId = sourcePathCache.sourceId("/path/two/qmldir");
|
||||
SourceId qmlDir3PathSourceId = sourcePathCache.sourceId("/path/three/qmldir");
|
||||
ON_CALL(projectManagerMock, qtQmlDirs())
|
||||
.WillByDefault(
|
||||
Return(QStringList{"/path/one/qmldir", "/path/two/qmldir", "/path/three/qmldir"}));
|
||||
QStringList qmlDirs = {"/path/one/qmldir", "/path/two/qmldir", "/path/three/qmldir"};
|
||||
ON_CALL(fileSystemMock, fileStatus(_)).WillByDefault([](auto sourceId) {
|
||||
return FileStatus{sourceId, 21, 421};
|
||||
});
|
||||
@@ -286,7 +299,7 @@ TEST_F(ProjectStorageUpdater, GetContentForQmlDirPathsIfFileStatusIsDifferent)
|
||||
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/one/qmldir"))));
|
||||
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/two/qmldir"))));
|
||||
|
||||
updater.update();
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, RequestFileStatusFromFileSystem)
|
||||
@@ -295,7 +308,7 @@ TEST_F(ProjectStorageUpdater, RequestFileStatusFromFileSystem)
|
||||
|
||||
EXPECT_CALL(fileSystemMock, fileStatus(Eq(qmlDirPathSourceId)));
|
||||
|
||||
updater.update();
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, GetContentForQmlTypes)
|
||||
@@ -307,7 +320,7 @@ TEST_F(ProjectStorageUpdater, GetContentForQmlTypes)
|
||||
|
||||
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes"))));
|
||||
|
||||
updater.update();
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, GetContentForQmlTypesIfProjectStorageFileStatusIsInvalid)
|
||||
@@ -321,7 +334,7 @@ TEST_F(ProjectStorageUpdater, GetContentForQmlTypesIfProjectStorageFileStatusIsI
|
||||
|
||||
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes"))));
|
||||
|
||||
updater.update();
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, DontGetContentForQmlTypesIfFileSystemFileStatusIsInvalid)
|
||||
@@ -334,26 +347,28 @@ TEST_F(ProjectStorageUpdater, DontGetContentForQmlTypesIfFileSystemFileStatusIsI
|
||||
|
||||
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes")))).Times(0);
|
||||
|
||||
updater.update();
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, ParseQmlTypes)
|
||||
{
|
||||
QString qmldir{R"(module Example
|
||||
typeinfo example.qmltypes
|
||||
typeinfo example2.qmltypes)"};
|
||||
typeinfo types/example2.qmltypes)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
QString qmltypes{"Module {\ndependencies: []}"};
|
||||
QString qmltypes2{"Module {\ndependencies: [foo]}"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes"))))
|
||||
.WillByDefault(Return(qmltypes));
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example2.qmltypes"))))
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/types/example2.qmltypes"))))
|
||||
.WillByDefault(Return(qmltypes2));
|
||||
|
||||
EXPECT_CALL(qmlTypesParserMock, parse(qmltypes, _, _, _));
|
||||
EXPECT_CALL(qmlTypesParserMock, parse(qmltypes2, _, _, _));
|
||||
EXPECT_CALL(qmlTypesParserMock,
|
||||
parse(qmltypes, _, _, Field(&ProjectData::moduleId, exampleCppNativeModuleId)));
|
||||
EXPECT_CALL(qmlTypesParserMock,
|
||||
parse(qmltypes2, _, _, Field(&ProjectData::moduleId, exampleCppNativeModuleId)));
|
||||
|
||||
updater.update();
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizeIsEmptyForNoChange)
|
||||
@@ -367,7 +382,7 @@ TEST_F(ProjectStorageUpdater, SynchronizeIsEmptyForNoChange)
|
||||
|
||||
EXPECT_CALL(projectStorageMock, synchronize(PackageIsEmpty()));
|
||||
|
||||
updater.update();
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizeQmlTypes)
|
||||
@@ -383,6 +398,8 @@ TEST_F(ProjectStorageUpdater, SynchronizeQmlTypes)
|
||||
});
|
||||
|
||||
EXPECT_CALL(projectStorageMock, moduleId(Eq("Example")));
|
||||
EXPECT_CALL(projectStorageMock, moduleId(Eq("Example-cppnative")));
|
||||
EXPECT_CALL(projectStorageMock, moduleId(Eq("/path")));
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
synchronize(
|
||||
AllOf(Field(&SynchronizationPackage::imports, ElementsAre(import)),
|
||||
@@ -395,12 +412,12 @@ TEST_F(ProjectStorageUpdater, SynchronizeQmlTypes)
|
||||
Field(&SynchronizationPackage::projectDatas,
|
||||
UnorderedElementsAre(IsProjectData(qmlDirPathSourceId,
|
||||
qmltypesPathSourceId,
|
||||
exampleModuleId,
|
||||
exampleCppNativeModuleId,
|
||||
FileType::QmlTypes))),
|
||||
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
||||
UnorderedElementsAre(qmlDirPathSourceId)))));
|
||||
|
||||
updater.update();
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizeQmlTypesAreEmptyIfFileDoesNotChanged)
|
||||
@@ -419,28 +436,37 @@ TEST_F(ProjectStorageUpdater, SynchronizeQmlTypesAreEmptyIfFileDoesNotChanged)
|
||||
|
||||
EXPECT_CALL(projectStorageMock, synchronize(PackageIsEmpty()));
|
||||
|
||||
updater.update();
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, GetContentForQmlDocuments)
|
||||
{
|
||||
QString qmldir{"module Example\nFirstType 1.0 First.qml\nFirstTypeV2 2.2 "
|
||||
"First.2.qml\nSecondType 2.1 OldSecond.qml\nSecondType 2.2 Second.qml\n"};
|
||||
SourceId oldSecondSourceId3 = sourcePathCache.sourceId("/path/OldSecond.qml");
|
||||
ON_CALL(fileSystemMock, fileStatus(Eq(oldSecondSourceId3)))
|
||||
.WillByDefault(Return(FileStatus{oldSecondSourceId3, 22, 14}));
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/OldSecond.qml"))))
|
||||
.WillByDefault(Return(qmlDocument3));
|
||||
QString qmldir{R"(module Example
|
||||
FirstType 1.0 First.qml
|
||||
FirstTypeV2 2.2 First2.qml
|
||||
SecondType 2.1 OldSecond.qml
|
||||
SecondType 2.2 Second.qml)"};
|
||||
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir"))))
|
||||
.WillRepeatedly(Return(qmldir));
|
||||
|
||||
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First.qml"))));
|
||||
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First.2.qml"))));
|
||||
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First2.qml"))));
|
||||
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/OldSecond.qml"))));
|
||||
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/Second.qml"))));
|
||||
|
||||
updater.update();
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, ParseQmlDocuments)
|
||||
{
|
||||
QString qmldir{R"(module Example
|
||||
FirstType 1.0 First.qml
|
||||
FirstTypeV2 2.2 First.2.qml
|
||||
FirstTypeV2 2.2 First2.qml
|
||||
SecondType 2.2 Second.qml)"};
|
||||
QString qmlDocument1{"First{}"};
|
||||
QString qmlDocument2{"Second{}"};
|
||||
@@ -448,16 +474,16 @@ TEST_F(ProjectStorageUpdater, ParseQmlDocuments)
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First.qml"))))
|
||||
.WillByDefault(Return(qmlDocument1));
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First.2.qml"))))
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First2.qml"))))
|
||||
.WillByDefault(Return(qmlDocument2));
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/Second.qml"))))
|
||||
.WillByDefault(Return(qmlDocument3));
|
||||
|
||||
EXPECT_CALL(qmlDocumentParserMock, parse(qmlDocument1, _));
|
||||
EXPECT_CALL(qmlDocumentParserMock, parse(qmlDocument2, _));
|
||||
EXPECT_CALL(qmlDocumentParserMock, parse(qmlDocument3, _));
|
||||
EXPECT_CALL(qmlDocumentParserMock, parse(qmlDocument1, _, _, _));
|
||||
EXPECT_CALL(qmlDocumentParserMock, parse(qmlDocument2, _, _, _));
|
||||
EXPECT_CALL(qmlDocumentParserMock, parse(qmlDocument3, _, _, _));
|
||||
|
||||
updater.update();
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, ParseQmlDocumentsWithNonExistingQmlDocumentThrows)
|
||||
@@ -466,14 +492,14 @@ TEST_F(ProjectStorageUpdater, ParseQmlDocumentsWithNonExistingQmlDocumentThrows)
|
||||
NonexitingType 1.0 NonexitingType.qml)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
|
||||
ASSERT_THROW(updater.update(), QmlDesigner::CannotParseQmlDocumentFile);
|
||||
ASSERT_THROW(updater.update(qmlDirs, {}), QmlDesigner::CannotParseQmlDocumentFile);
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizeQmlDocuments)
|
||||
{
|
||||
QString qmldir{R"(module Example
|
||||
FirstType 1.0 First.qml
|
||||
FirstType 2.2 First.2.qml
|
||||
FirstType 2.2 First2.qml
|
||||
SecondType 2.2 Second.qml)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
|
||||
@@ -489,21 +515,24 @@ TEST_F(ProjectStorageUpdater, SynchronizeQmlDocuments)
|
||||
qmlDocumentSourceId1,
|
||||
Storage::ChangeLevel::Full),
|
||||
Field(&Storage::Type::exportedTypes,
|
||||
ElementsAre(IsExportedType(exampleModuleId, "FirstType", 1, 0)))),
|
||||
AllOf(IsStorageType("First.2.qml",
|
||||
ElementsAre(IsExportedType(exampleModuleId, "FirstType", 1, 0),
|
||||
IsExportedType(pathModuleId, "First", -1, -1)))),
|
||||
AllOf(IsStorageType("First2.qml",
|
||||
Storage::ImportedType{"Object2"},
|
||||
TypeAccessSemantics::Reference,
|
||||
qmlDocumentSourceId2,
|
||||
Storage::ChangeLevel::Full),
|
||||
Field(&Storage::Type::exportedTypes,
|
||||
ElementsAre(IsExportedType(exampleModuleId, "FirstType", 2, 2)))),
|
||||
ElementsAre(IsExportedType(exampleModuleId, "FirstType", 2, 2),
|
||||
IsExportedType(pathModuleId, "First2", -1, -1)))),
|
||||
AllOf(IsStorageType("Second.qml",
|
||||
Storage::ImportedType{"Object3"},
|
||||
TypeAccessSemantics::Reference,
|
||||
qmlDocumentSourceId3,
|
||||
Storage::ChangeLevel::Full),
|
||||
Field(&Storage::Type::exportedTypes,
|
||||
ElementsAre(IsExportedType(exampleModuleId, "SecondType", 2, 2)))))),
|
||||
ElementsAre(IsExportedType(exampleModuleId, "SecondType", 2, 2),
|
||||
IsExportedType(pathModuleId, "Second", -1, -1)))))),
|
||||
Field(&SynchronizationPackage::updatedSourceIds,
|
||||
UnorderedElementsAre(qmlDirPathSourceId,
|
||||
qmlDocumentSourceId1,
|
||||
@@ -535,16 +564,16 @@ TEST_F(ProjectStorageUpdater, SynchronizeQmlDocuments)
|
||||
exampleModuleId,
|
||||
FileType::QmlDocument))))));
|
||||
|
||||
updater.update();
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizeRemoved)
|
||||
{
|
||||
QString qmldir{R"(module Example
|
||||
FirstType 1.0 First.qml
|
||||
FirstType 2.2 First.2.qml
|
||||
FirstType 2.2 First2.qml
|
||||
typeinfo example.qmltypes
|
||||
typeinfo example2.qmltypes
|
||||
typeinfo types/example2.qmltypes
|
||||
)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmlDocumentSourceId2)))
|
||||
@@ -572,14 +601,16 @@ TEST_F(ProjectStorageUpdater, SynchronizeRemoved)
|
||||
qmlDocumentSourceId1,
|
||||
Storage::ChangeLevel::Full),
|
||||
Field(&Storage::Type::exportedTypes,
|
||||
ElementsAre(IsExportedType(exampleModuleId, "FirstType", 1, 0)))),
|
||||
AllOf(IsStorageType("First.2.qml",
|
||||
Storage::NativeType{},
|
||||
ElementsAre(IsExportedType(exampleModuleId, "FirstType", 1, 0),
|
||||
IsExportedType(pathModuleId, "First", -1, -1)))),
|
||||
AllOf(IsStorageType("First2.qml",
|
||||
Storage::ImportedType{},
|
||||
TypeAccessSemantics::Reference,
|
||||
qmlDocumentSourceId2,
|
||||
Storage::ChangeLevel::Minimal),
|
||||
Field(&Storage::Type::exportedTypes,
|
||||
ElementsAre(IsExportedType(exampleModuleId, "FirstType", 2, 2)))))),
|
||||
ElementsAre(IsExportedType(exampleModuleId, "FirstType", 2, 2),
|
||||
IsExportedType(pathModuleId, "First2", -1, -1)))))),
|
||||
Field(&SynchronizationPackage::updatedSourceIds,
|
||||
UnorderedElementsAre(qmlDirPathSourceId,
|
||||
qmltypesPathSourceId,
|
||||
@@ -608,21 +639,21 @@ TEST_F(ProjectStorageUpdater, SynchronizeRemoved)
|
||||
FileType::QmlDocument),
|
||||
IsProjectData(qmlDirPathSourceId,
|
||||
qmltypesPathSourceId,
|
||||
exampleModuleId,
|
||||
exampleCppNativeModuleId,
|
||||
FileType::QmlTypes),
|
||||
IsProjectData(qmlDirPathSourceId,
|
||||
qmltypes2PathSourceId,
|
||||
exampleModuleId,
|
||||
exampleCppNativeModuleId,
|
||||
FileType::QmlTypes))))));
|
||||
|
||||
updater.update();
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizeQmlDocumentsDontUpdateIfUpToDate)
|
||||
{
|
||||
QString qmldir{R"(module Example
|
||||
FirstType 1.0 First.qml
|
||||
FirstType 2.2 First.2.qml
|
||||
FirstType 2.2 First2.qml
|
||||
SecondType 2.2 Second.qml)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmlDocumentSourceId3)))
|
||||
@@ -640,21 +671,24 @@ TEST_F(ProjectStorageUpdater, SynchronizeQmlDocumentsDontUpdateIfUpToDate)
|
||||
qmlDocumentSourceId1,
|
||||
Storage::ChangeLevel::Full),
|
||||
Field(&Storage::Type::exportedTypes,
|
||||
ElementsAre(IsExportedType(exampleModuleId, "FirstType", 1, 0)))),
|
||||
AllOf(IsStorageType("First.2.qml",
|
||||
ElementsAre(IsExportedType(exampleModuleId, "FirstType", 1, 0),
|
||||
IsExportedType(pathModuleId, "First", -1, -1)))),
|
||||
AllOf(IsStorageType("First2.qml",
|
||||
Storage::ImportedType{"Object2"},
|
||||
TypeAccessSemantics::Reference,
|
||||
qmlDocumentSourceId2,
|
||||
Storage::ChangeLevel::Full),
|
||||
Field(&Storage::Type::exportedTypes,
|
||||
ElementsAre(IsExportedType(exampleModuleId, "FirstType", 2, 2)))),
|
||||
ElementsAre(IsExportedType(exampleModuleId, "FirstType", 2, 2),
|
||||
IsExportedType(pathModuleId, "First2", -1, -1)))),
|
||||
AllOf(IsStorageType("Second.qml",
|
||||
Storage::NativeType{},
|
||||
Storage::ImportedType{},
|
||||
TypeAccessSemantics::Reference,
|
||||
qmlDocumentSourceId3,
|
||||
Storage::ChangeLevel::Minimal),
|
||||
Field(&Storage::Type::exportedTypes,
|
||||
ElementsAre(IsExportedType(exampleModuleId, "SecondType", 2, 2)))))),
|
||||
ElementsAre(IsExportedType(exampleModuleId, "SecondType", 2, 2),
|
||||
IsExportedType(pathModuleId, "Second", -1, -1)))))),
|
||||
Field(&SynchronizationPackage::updatedSourceIds,
|
||||
UnorderedElementsAre(qmlDirPathSourceId,
|
||||
qmlDocumentSourceId1,
|
||||
@@ -682,14 +716,14 @@ TEST_F(ProjectStorageUpdater, SynchronizeQmlDocumentsDontUpdateIfUpToDate)
|
||||
exampleModuleId,
|
||||
FileType::QmlDocument))))));
|
||||
|
||||
updater.update();
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, UpdateQmldirDocuments)
|
||||
{
|
||||
QString qmldir{R"(module Example
|
||||
FirstType 1.1 First.qml
|
||||
FirstType 2.2 First.2.qml
|
||||
FirstType 2.2 First2.qml
|
||||
SecondType 2.2 Second.qml)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmlDocumentSourceId3)))
|
||||
@@ -716,7 +750,7 @@ TEST_F(ProjectStorageUpdater, AddSourceIdForForInvalidQmldirFileStatus)
|
||||
Field(&SynchronizationPackage::fileStatuses, IsEmpty()),
|
||||
Field(&SynchronizationPackage::updatedFileStatusSourceIds, IsEmpty()),
|
||||
Field(&SynchronizationPackage::projectDatas, IsEmpty()))));
|
||||
updater.update();
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizIfQmldirFileHasNotChanged)
|
||||
@@ -744,7 +778,7 @@ TEST_F(ProjectStorageUpdater, SynchronizIfQmldirFileHasNotChanged)
|
||||
qmlDocumentSourceId1,
|
||||
Storage::ChangeLevel::ExcludeExportedTypes),
|
||||
Field(&Storage::Type::exportedTypes, IsEmpty())),
|
||||
AllOf(IsStorageType("First.2.qml",
|
||||
AllOf(IsStorageType("First2.qml",
|
||||
Storage::ImportedType{"Object2"},
|
||||
TypeAccessSemantics::Reference,
|
||||
qmlDocumentSourceId2,
|
||||
@@ -767,7 +801,7 @@ TEST_F(ProjectStorageUpdater, SynchronizIfQmldirFileHasNotChanged)
|
||||
qmlDocumentSourceId2)),
|
||||
Field(&SynchronizationPackage::projectDatas, IsEmpty()))));
|
||||
|
||||
updater.update();
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizIfQmldirFileHasNotChangedAndSomeUpdatedFiles)
|
||||
@@ -806,7 +840,464 @@ TEST_F(ProjectStorageUpdater, SynchronizIfQmldirFileHasNotChangedAndSomeUpdatedF
|
||||
UnorderedElementsAre(qmltypesPathSourceId, qmlDocumentSourceId1)),
|
||||
Field(&SynchronizationPackage::projectDatas, IsEmpty()))));
|
||||
|
||||
updater.update();
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, UpdateQmlTypesFilesIsEmpty)
|
||||
{
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
synchronize(
|
||||
AllOf(Field(&SynchronizationPackage::imports, IsEmpty()),
|
||||
Field(&SynchronizationPackage::types, IsEmpty()),
|
||||
Field(&SynchronizationPackage::updatedSourceIds, IsEmpty()),
|
||||
Field(&SynchronizationPackage::fileStatuses, IsEmpty()),
|
||||
Field(&SynchronizationPackage::updatedFileStatusSourceIds, IsEmpty()),
|
||||
Field(&SynchronizationPackage::projectDatas, IsEmpty()),
|
||||
Field(&SynchronizationPackage::updatedProjectSourceIds, IsEmpty()))));
|
||||
|
||||
updater.update({}, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, UpdateQmlTypesFiles)
|
||||
{
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
synchronize(AllOf(
|
||||
Field(&SynchronizationPackage::imports, UnorderedElementsAre(import4, import5)),
|
||||
Field(&SynchronizationPackage::types, UnorderedElementsAre(objectType, itemType)),
|
||||
Field(&SynchronizationPackage::updatedSourceIds,
|
||||
UnorderedElementsAre(qmltypesPathSourceId, qmltypes2PathSourceId)),
|
||||
Field(&SynchronizationPackage::fileStatuses,
|
||||
UnorderedElementsAre(IsFileStatus(qmltypesPathSourceId, 21, 421),
|
||||
IsFileStatus(qmltypes2PathSourceId, 21, 421))),
|
||||
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
||||
UnorderedElementsAre(qmltypesPathSourceId, qmltypes2PathSourceId)),
|
||||
Field(&SynchronizationPackage::projectDatas,
|
||||
UnorderedElementsAre(IsProjectData(qmltypesPathSourceId,
|
||||
qmltypesPathSourceId,
|
||||
builtinCppNativeModuleId,
|
||||
FileType::QmlTypes),
|
||||
IsProjectData(qmltypes2PathSourceId,
|
||||
qmltypes2PathSourceId,
|
||||
builtinCppNativeModuleId,
|
||||
FileType::QmlTypes))),
|
||||
Field(&SynchronizationPackage::updatedProjectSourceIds, IsEmpty()))));
|
||||
|
||||
updater.update({}, {"/path/example.qmltypes", "/path/types/example2.qmltypes"});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, DontUpdateQmlTypesFilesIfUnchanged)
|
||||
{
|
||||
ON_CALL(projectStorageMock, fetchFileStatus(Eq(qmltypes2PathSourceId)))
|
||||
.WillByDefault(Return(FileStatus{qmltypes2PathSourceId, 21, 421}));
|
||||
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
synchronize(
|
||||
AllOf(Field(&SynchronizationPackage::imports, UnorderedElementsAre(import4)),
|
||||
Field(&SynchronizationPackage::types, UnorderedElementsAre(objectType)),
|
||||
Field(&SynchronizationPackage::updatedSourceIds,
|
||||
UnorderedElementsAre(qmltypesPathSourceId)),
|
||||
Field(&SynchronizationPackage::fileStatuses,
|
||||
UnorderedElementsAre(IsFileStatus(qmltypesPathSourceId, 21, 421))),
|
||||
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
||||
UnorderedElementsAre(qmltypesPathSourceId)),
|
||||
Field(&SynchronizationPackage::projectDatas,
|
||||
UnorderedElementsAre(IsProjectData(qmltypesPathSourceId,
|
||||
qmltypesPathSourceId,
|
||||
builtinCppNativeModuleId,
|
||||
FileType::QmlTypes))),
|
||||
Field(&SynchronizationPackage::updatedProjectSourceIds, IsEmpty()))));
|
||||
|
||||
updater.update({}, {"/path/example.qmltypes", "/path/types/example2.qmltypes"});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizeQmlDocumentsWithDifferentVersionButSameTypeNameAndFileName)
|
||||
{
|
||||
QString qmldir{R"(module Example
|
||||
FirstType 1.0 First.qml
|
||||
FirstType 1.1 First.qml
|
||||
FirstType 6.0 First.qml)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
synchronize(
|
||||
AllOf(Field(&SynchronizationPackage::imports, UnorderedElementsAre(import1)),
|
||||
Field(&SynchronizationPackage::types,
|
||||
UnorderedElementsAre(AllOf(
|
||||
IsStorageType("First.qml",
|
||||
Storage::ImportedType{"Object"},
|
||||
TypeAccessSemantics::Reference,
|
||||
qmlDocumentSourceId1,
|
||||
Storage::ChangeLevel::Full),
|
||||
Field(&Storage::Type::exportedTypes,
|
||||
UnorderedElementsAre(
|
||||
IsExportedType(exampleModuleId, "FirstType", 1, 0),
|
||||
IsExportedType(exampleModuleId, "FirstType", 1, 1),
|
||||
IsExportedType(exampleModuleId, "FirstType", 6, 0),
|
||||
IsExportedType(pathModuleId, "First", -1, -1)))))),
|
||||
Field(&SynchronizationPackage::updatedSourceIds,
|
||||
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1)),
|
||||
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
||||
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1)),
|
||||
Field(&SynchronizationPackage::fileStatuses,
|
||||
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 421),
|
||||
IsFileStatus(qmlDocumentSourceId1, 22, 12))),
|
||||
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
||||
UnorderedElementsAre(qmlDirPathSourceId)),
|
||||
Field(&SynchronizationPackage::projectDatas,
|
||||
UnorderedElementsAre(IsProjectData(qmlDirPathSourceId,
|
||||
qmlDocumentSourceId1,
|
||||
exampleModuleId,
|
||||
FileType::QmlDocument))))));
|
||||
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizeQmlDocumentsWithDifferentTypeNameButSameVersionAndFileName)
|
||||
{
|
||||
QString qmldir{R"(module Example
|
||||
FirstType 1.0 First.qml
|
||||
FirstType2 1.0 First.qml)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
synchronize(
|
||||
AllOf(Field(&SynchronizationPackage::imports, UnorderedElementsAre(import1)),
|
||||
Field(&SynchronizationPackage::types,
|
||||
UnorderedElementsAre(
|
||||
AllOf(IsStorageType("First.qml",
|
||||
Storage::ImportedType{"Object"},
|
||||
TypeAccessSemantics::Reference,
|
||||
qmlDocumentSourceId1,
|
||||
Storage::ChangeLevel::Full),
|
||||
Field(&Storage::Type::exportedTypes,
|
||||
UnorderedElementsAre(
|
||||
IsExportedType(exampleModuleId, "FirstType", 1, 0),
|
||||
IsExportedType(exampleModuleId, "FirstType2", 1, 0),
|
||||
IsExportedType(pathModuleId, "First", -1, -1)))))),
|
||||
Field(&SynchronizationPackage::updatedSourceIds,
|
||||
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1)),
|
||||
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
||||
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1)),
|
||||
Field(&SynchronizationPackage::fileStatuses,
|
||||
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 421),
|
||||
IsFileStatus(qmlDocumentSourceId1, 22, 12))),
|
||||
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
||||
UnorderedElementsAre(qmlDirPathSourceId)),
|
||||
Field(&SynchronizationPackage::projectDatas,
|
||||
UnorderedElementsAre(IsProjectData(qmlDirPathSourceId,
|
||||
qmlDocumentSourceId1,
|
||||
exampleModuleId,
|
||||
FileType::QmlDocument))))));
|
||||
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, DontSynchronizeSelectors)
|
||||
{
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/+First.qml"))))
|
||||
.WillByDefault(Return(qmlDocument1));
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qml/+First.qml"))))
|
||||
.WillByDefault(Return(qmlDocument1));
|
||||
QString qmldir{R"(module Example
|
||||
FirstType 1.0 +First.qml
|
||||
FirstType2 1.0 qml/+First.qml)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
synchronize(
|
||||
AllOf(Field(&SynchronizationPackage::imports, IsEmpty()),
|
||||
Field(&SynchronizationPackage::types, IsEmpty()),
|
||||
Field(&SynchronizationPackage::updatedSourceIds,
|
||||
UnorderedElementsAre(qmlDirPathSourceId)),
|
||||
Field(&SynchronizationPackage::fileStatuses,
|
||||
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 421))),
|
||||
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
||||
UnorderedElementsAre(qmlDirPathSourceId)),
|
||||
Field(&SynchronizationPackage::projectDatas, IsEmpty()),
|
||||
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
||||
UnorderedElementsAre(qmlDirPathSourceId)))));
|
||||
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizeQmlDocumentsWithRelativeFilePath)
|
||||
{
|
||||
SourceId qmlDocumentSourceId = sourcePathCache.sourceId("/path/First.qml");
|
||||
ON_CALL(fileSystemMock, fileStatus(Eq(qmlDocumentSourceId)))
|
||||
.WillByDefault(Return(FileStatus{qmlDocumentSourceId, 22, 12}));
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First.qml"))))
|
||||
.WillByDefault(Return(qmlDocument1));
|
||||
QString qmldir{R"(module Example
|
||||
FirstType 1.0 First.qml
|
||||
FirstType2 1.0 First.qml)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
synchronize(
|
||||
AllOf(Field(&SynchronizationPackage::imports, UnorderedElementsAre(import1)),
|
||||
Field(&SynchronizationPackage::types,
|
||||
UnorderedElementsAre(
|
||||
AllOf(IsStorageType("First.qml",
|
||||
Storage::ImportedType{"Object"},
|
||||
TypeAccessSemantics::Reference,
|
||||
qmlDocumentSourceId,
|
||||
Storage::ChangeLevel::Full),
|
||||
Field(&Storage::Type::exportedTypes,
|
||||
UnorderedElementsAre(
|
||||
IsExportedType(exampleModuleId, "FirstType", 1, 0),
|
||||
IsExportedType(exampleModuleId, "FirstType2", 1, 0),
|
||||
IsExportedType(pathModuleId, "First", -1, -1)))))),
|
||||
Field(&SynchronizationPackage::updatedSourceIds,
|
||||
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId)),
|
||||
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
||||
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId)),
|
||||
Field(&SynchronizationPackage::fileStatuses,
|
||||
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 21, 421),
|
||||
IsFileStatus(qmlDocumentSourceId, 22, 12))),
|
||||
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
||||
UnorderedElementsAre(qmlDirPathSourceId)),
|
||||
Field(&SynchronizationPackage::projectDatas,
|
||||
UnorderedElementsAre(IsProjectData(qmlDirPathSourceId,
|
||||
qmlDocumentSourceId,
|
||||
exampleModuleId,
|
||||
FileType::QmlDocument))))));
|
||||
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizeQmldirDependencies)
|
||||
{
|
||||
QString qmldir{R"(module Example
|
||||
depends Qml
|
||||
depends QML
|
||||
typeinfo example.qmltypes
|
||||
typeinfo types/example2.qmltypes
|
||||
)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
|
||||
EXPECT_CALL(
|
||||
projectStorageMock,
|
||||
synchronize(AllOf(
|
||||
Field(&SynchronizationPackage::moduleDependencies,
|
||||
UnorderedElementsAre(
|
||||
Import{qmlCppNativeModuleId, Storage::Version{}, qmltypesPathSourceId},
|
||||
Import{builtinCppNativeModuleId, Storage::Version{}, qmltypesPathSourceId},
|
||||
Import{qmlCppNativeModuleId, Storage::Version{}, qmltypes2PathSourceId},
|
||||
Import{builtinCppNativeModuleId, Storage::Version{}, qmltypes2PathSourceId})),
|
||||
Field(&SynchronizationPackage::updatedModuleDependencySourceIds,
|
||||
UnorderedElementsAre(qmltypesPathSourceId, qmltypes2PathSourceId)))));
|
||||
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizeQmldirDependenciesWithDoubleEntries)
|
||||
{
|
||||
QString qmldir{R"(module Example
|
||||
depends Qml
|
||||
depends QML
|
||||
depends Qml
|
||||
typeinfo example.qmltypes
|
||||
typeinfo types/example2.qmltypes
|
||||
)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
|
||||
EXPECT_CALL(
|
||||
projectStorageMock,
|
||||
synchronize(AllOf(
|
||||
Field(&SynchronizationPackage::moduleDependencies,
|
||||
UnorderedElementsAre(
|
||||
Import{qmlCppNativeModuleId, Storage::Version{}, qmltypesPathSourceId},
|
||||
Import{builtinCppNativeModuleId, Storage::Version{}, qmltypesPathSourceId},
|
||||
Import{qmlCppNativeModuleId, Storage::Version{}, qmltypes2PathSourceId},
|
||||
Import{builtinCppNativeModuleId, Storage::Version{}, qmltypes2PathSourceId})),
|
||||
Field(&SynchronizationPackage::updatedModuleDependencySourceIds,
|
||||
UnorderedElementsAre(qmltypesPathSourceId, qmltypes2PathSourceId)))));
|
||||
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizeQmldirDependenciesWithCollidingImports)
|
||||
{
|
||||
QString qmldir{R"(module Example
|
||||
depends Qml
|
||||
depends QML
|
||||
import Qml
|
||||
typeinfo example.qmltypes
|
||||
typeinfo types/example2.qmltypes
|
||||
)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
|
||||
EXPECT_CALL(
|
||||
projectStorageMock,
|
||||
synchronize(AllOf(
|
||||
Field(&SynchronizationPackage::moduleDependencies,
|
||||
UnorderedElementsAre(
|
||||
Import{qmlCppNativeModuleId, Storage::Version{}, qmltypesPathSourceId},
|
||||
Import{builtinCppNativeModuleId, Storage::Version{}, qmltypesPathSourceId},
|
||||
Import{qmlCppNativeModuleId, Storage::Version{}, qmltypes2PathSourceId},
|
||||
Import{builtinCppNativeModuleId, Storage::Version{}, qmltypes2PathSourceId})),
|
||||
Field(&SynchronizationPackage::updatedModuleDependencySourceIds,
|
||||
UnorderedElementsAre(qmltypesPathSourceId, qmltypes2PathSourceId)))));
|
||||
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizeQmldirWithNoDependencies)
|
||||
{
|
||||
QString qmldir{R"(module Example
|
||||
typeinfo example.qmltypes
|
||||
typeinfo types/example2.qmltypes
|
||||
)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
synchronize(
|
||||
AllOf(Field(&SynchronizationPackage::moduleDependencies, IsEmpty()),
|
||||
Field(&SynchronizationPackage::updatedModuleDependencySourceIds,
|
||||
UnorderedElementsAre(qmltypesPathSourceId, qmltypes2PathSourceId)))));
|
||||
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizeQmldirImports)
|
||||
{
|
||||
QString qmldir{R"(module Example
|
||||
import Qml auto
|
||||
import QML 2.1
|
||||
import Quick
|
||||
)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
synchronize(
|
||||
AllOf(Field(&SynchronizationPackage::moduleExportedImports,
|
||||
UnorderedElementsAre(ModuleExportedImport{exampleModuleId,
|
||||
qmlModuleId,
|
||||
Storage::Version{},
|
||||
IsAutoVersion::Yes},
|
||||
ModuleExportedImport{exampleCppNativeModuleId,
|
||||
qmlCppNativeModuleId,
|
||||
Storage::Version{},
|
||||
IsAutoVersion::No},
|
||||
ModuleExportedImport{exampleModuleId,
|
||||
builtinModuleId,
|
||||
Storage::Version{2, 1},
|
||||
IsAutoVersion::No},
|
||||
ModuleExportedImport{exampleCppNativeModuleId,
|
||||
builtinCppNativeModuleId,
|
||||
Storage::Version{},
|
||||
IsAutoVersion::No},
|
||||
ModuleExportedImport{exampleModuleId,
|
||||
quickModuleId,
|
||||
Storage::Version{},
|
||||
IsAutoVersion::No},
|
||||
ModuleExportedImport{exampleCppNativeModuleId,
|
||||
quickCppNativeModuleId,
|
||||
Storage::Version{},
|
||||
IsAutoVersion::No})),
|
||||
Field(&SynchronizationPackage::updatedModuleIds,
|
||||
ElementsAre(exampleModuleId)))));
|
||||
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizeQmldirWithNoImports)
|
||||
{
|
||||
QString qmldir{R"(module Example
|
||||
)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
synchronize(AllOf(Field(&SynchronizationPackage::moduleExportedImports, IsEmpty()),
|
||||
Field(&SynchronizationPackage::updatedModuleIds,
|
||||
ElementsAre(exampleModuleId)))));
|
||||
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizeQmldirImportsWithDoubleEntries)
|
||||
{
|
||||
QString qmldir{R"(module Example
|
||||
import Qml auto
|
||||
import QML 2.1
|
||||
import Quick
|
||||
import Qml
|
||||
)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
synchronize(
|
||||
AllOf(Field(&SynchronizationPackage::moduleExportedImports,
|
||||
UnorderedElementsAre(ModuleExportedImport{exampleModuleId,
|
||||
qmlModuleId,
|
||||
Storage::Version{},
|
||||
IsAutoVersion::Yes},
|
||||
ModuleExportedImport{exampleCppNativeModuleId,
|
||||
qmlCppNativeModuleId,
|
||||
Storage::Version{},
|
||||
IsAutoVersion::No},
|
||||
ModuleExportedImport{exampleModuleId,
|
||||
builtinModuleId,
|
||||
Storage::Version{2, 1},
|
||||
IsAutoVersion::No},
|
||||
ModuleExportedImport{exampleCppNativeModuleId,
|
||||
builtinCppNativeModuleId,
|
||||
Storage::Version{},
|
||||
IsAutoVersion::No},
|
||||
ModuleExportedImport{exampleModuleId,
|
||||
quickModuleId,
|
||||
Storage::Version{},
|
||||
IsAutoVersion::No},
|
||||
ModuleExportedImport{exampleCppNativeModuleId,
|
||||
quickCppNativeModuleId,
|
||||
Storage::Version{},
|
||||
IsAutoVersion::No})),
|
||||
Field(&SynchronizationPackage::updatedModuleIds,
|
||||
ElementsAre(exampleModuleId)))));
|
||||
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, SynchronizeQmldirOptionalImports)
|
||||
{
|
||||
QString qmldir{R"(module Example
|
||||
import Qml auto
|
||||
import QML 2.1
|
||||
optional import Quick
|
||||
)"};
|
||||
ON_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/qmldir")))).WillByDefault(Return(qmldir));
|
||||
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
synchronize(
|
||||
AllOf(Field(&SynchronizationPackage::moduleExportedImports,
|
||||
UnorderedElementsAre(ModuleExportedImport{exampleModuleId,
|
||||
qmlModuleId,
|
||||
Storage::Version{},
|
||||
IsAutoVersion::Yes},
|
||||
ModuleExportedImport{exampleCppNativeModuleId,
|
||||
qmlCppNativeModuleId,
|
||||
Storage::Version{},
|
||||
IsAutoVersion::No},
|
||||
ModuleExportedImport{exampleModuleId,
|
||||
builtinModuleId,
|
||||
Storage::Version{2, 1},
|
||||
IsAutoVersion::No},
|
||||
ModuleExportedImport{exampleCppNativeModuleId,
|
||||
builtinCppNativeModuleId,
|
||||
Storage::Version{},
|
||||
IsAutoVersion::No},
|
||||
ModuleExportedImport{exampleModuleId,
|
||||
quickModuleId,
|
||||
Storage::Version{},
|
||||
IsAutoVersion::No},
|
||||
ModuleExportedImport{exampleCppNativeModuleId,
|
||||
quickCppNativeModuleId,
|
||||
Storage::Version{},
|
||||
IsAutoVersion::No})),
|
||||
Field(&SynchronizationPackage::updatedModuleIds,
|
||||
ElementsAre(exampleModuleId)))));
|
||||
|
||||
updater.update(qmlDirs, {});
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user