2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2021 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2021-09-16 17:19:56 +02:00
|
|
|
|
|
|
|
|
#include "googletest.h"
|
|
|
|
|
|
|
|
|
|
#include "filesystemmock.h"
|
|
|
|
|
#include "projectstoragemock.h"
|
2023-02-16 13:53:28 +01:00
|
|
|
#include "projectstoragepathwatchermock.h"
|
2021-09-16 17:19:56 +02:00
|
|
|
#include "qmldocumentparsermock.h"
|
|
|
|
|
#include "qmltypesparsermock.h"
|
|
|
|
|
|
|
|
|
|
#include <projectstorage/filestatuscache.h>
|
|
|
|
|
#include <projectstorage/projectstorage.h>
|
|
|
|
|
#include <projectstorage/projectstorageupdater.h>
|
|
|
|
|
#include <projectstorage/sourcepathcache.h>
|
|
|
|
|
#include <sqlitedatabase.h>
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
namespace Storage = QmlDesigner::Storage;
|
|
|
|
|
|
|
|
|
|
using QmlDesigner::FileStatus;
|
2021-10-11 11:15:47 +02:00
|
|
|
using QmlDesigner::ModuleId;
|
2021-09-16 17:19:56 +02:00
|
|
|
using QmlDesigner::SourceId;
|
2021-08-24 11:53:15 +02:00
|
|
|
namespace Storage = QmlDesigner::Storage;
|
2021-09-22 16:21:31 +02:00
|
|
|
using QmlDesigner::IdPaths;
|
2022-07-21 13:28:16 +02:00
|
|
|
using QmlDesigner::Storage::TypeTraits;
|
2022-07-12 15:01:24 +02:00
|
|
|
using QmlDesigner::Storage::Synchronization::FileType;
|
|
|
|
|
using QmlDesigner::Storage::Synchronization::Import;
|
|
|
|
|
using QmlDesigner::Storage::Synchronization::IsAutoVersion;
|
|
|
|
|
using QmlDesigner::Storage::Synchronization::ModuleExportedImport;
|
|
|
|
|
using QmlDesigner::Storage::Synchronization::ProjectData;
|
|
|
|
|
using QmlDesigner::Storage::Synchronization::SynchronizationPackage;
|
|
|
|
|
using QmlDesigner::Storage::Synchronization::Version;
|
2021-09-16 17:19:56 +02:00
|
|
|
|
2021-10-21 17:23:18 +02:00
|
|
|
MATCHER_P5(IsStorageType,
|
2021-09-16 17:19:56 +02:00
|
|
|
typeName,
|
|
|
|
|
prototype,
|
2022-07-21 13:28:16 +02:00
|
|
|
traits,
|
2021-09-16 17:19:56 +02:00
|
|
|
sourceId,
|
2021-10-21 17:23:18 +02:00
|
|
|
changeLevel,
|
2021-09-16 17:19:56 +02:00
|
|
|
std::string(negation ? "isn't " : "is ")
|
2022-07-12 15:01:24 +02:00
|
|
|
+ PrintToString(Storage::Synchronization::Type(
|
2022-07-21 13:28:16 +02:00
|
|
|
typeName, prototype, traits, sourceId, changeLevel)))
|
2021-09-16 17:19:56 +02:00
|
|
|
{
|
2022-07-12 15:01:24 +02:00
|
|
|
const Storage::Synchronization::Type &type = arg;
|
2021-09-16 17:19:56 +02:00
|
|
|
|
2022-07-21 13:28:16 +02:00
|
|
|
return type.typeName == typeName && type.traits == traits && type.sourceId == sourceId
|
2022-07-12 15:01:24 +02:00
|
|
|
&& Storage::Synchronization::ImportedTypeName{prototype} == type.prototype
|
2021-10-21 17:23:18 +02:00
|
|
|
&& type.changeLevel == changeLevel;
|
2021-09-16 17:19:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MATCHER_P3(IsPropertyDeclaration,
|
|
|
|
|
name,
|
|
|
|
|
typeName,
|
|
|
|
|
traits,
|
|
|
|
|
std::string(negation ? "isn't " : "is ")
|
2022-07-12 15:01:24 +02:00
|
|
|
+ PrintToString(Storage::Synchronization::PropertyDeclaration{name, typeName, traits}))
|
2021-09-16 17:19:56 +02:00
|
|
|
{
|
2022-07-12 15:01:24 +02:00
|
|
|
const Storage::Synchronization::PropertyDeclaration &propertyDeclaration = arg;
|
2021-09-16 17:19:56 +02:00
|
|
|
|
|
|
|
|
return propertyDeclaration.name == name
|
2022-07-12 15:01:24 +02:00
|
|
|
&& Storage::Synchronization::ImportedTypeName{typeName} == propertyDeclaration.typeName
|
2021-09-16 17:19:56 +02:00
|
|
|
&& propertyDeclaration.traits == traits;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 11:15:47 +02:00
|
|
|
MATCHER_P4(IsExportedType,
|
|
|
|
|
moduleId,
|
2021-09-20 14:12:57 +02:00
|
|
|
name,
|
|
|
|
|
majorVersion,
|
|
|
|
|
minorVersion,
|
|
|
|
|
std::string(negation ? "isn't " : "is ")
|
2022-07-12 15:01:24 +02:00
|
|
|
+ PrintToString(Storage::Synchronization::ExportedType{
|
|
|
|
|
moduleId, name, Storage::Synchronization::Version{majorVersion, minorVersion}}))
|
2021-09-16 17:19:56 +02:00
|
|
|
{
|
2022-07-12 15:01:24 +02:00
|
|
|
const Storage::Synchronization::ExportedType &type = arg;
|
2021-09-16 17:19:56 +02:00
|
|
|
|
2021-10-11 11:15:47 +02:00
|
|
|
return type.moduleId == moduleId && type.name == name
|
2022-07-12 15:01:24 +02:00
|
|
|
&& type.version == Storage::Synchronization::Version{majorVersion, minorVersion};
|
2021-09-20 14:12:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MATCHER_P3(IsFileStatus,
|
|
|
|
|
sourceId,
|
|
|
|
|
size,
|
|
|
|
|
lastModified,
|
|
|
|
|
std::string(negation ? "isn't " : "is ")
|
|
|
|
|
+ PrintToString(FileStatus{sourceId, size, lastModified}))
|
|
|
|
|
{
|
|
|
|
|
const FileStatus &fileStatus = arg;
|
|
|
|
|
|
|
|
|
|
return fileStatus.sourceId == sourceId && fileStatus.size == size
|
|
|
|
|
&& fileStatus.lastModified == lastModified;
|
2021-09-16 17:19:56 +02:00
|
|
|
}
|
|
|
|
|
|
2021-11-29 17:52:46 +01:00
|
|
|
MATCHER_P4(IsProjectData,
|
|
|
|
|
projectSourceId,
|
2021-10-21 17:23:18 +02:00
|
|
|
sourceId,
|
2021-11-29 17:52:46 +01:00
|
|
|
moduleId,
|
2021-10-21 17:23:18 +02:00
|
|
|
fileType,
|
|
|
|
|
std::string(negation ? "isn't " : "is ")
|
2022-07-12 15:01:24 +02:00
|
|
|
+ PrintToString(Storage::Synchronization::ProjectData{
|
|
|
|
|
projectSourceId, sourceId, moduleId, fileType}))
|
2021-10-21 17:23:18 +02:00
|
|
|
{
|
2022-07-12 15:01:24 +02:00
|
|
|
const Storage::Synchronization::ProjectData &projectData = arg;
|
2021-10-21 17:23:18 +02:00
|
|
|
|
2022-07-21 12:02:29 +02:00
|
|
|
return compareInvalidAreTrue(projectData.projectSourceId, projectSourceId)
|
2022-09-06 15:13:29 +02:00
|
|
|
&& projectData.sourceId == sourceId
|
|
|
|
|
&& compareInvalidAreTrue(projectData.moduleId, moduleId)
|
2022-07-21 12:02:29 +02:00
|
|
|
&& projectData.fileType == fileType;
|
2021-10-21 17:23:18 +02:00
|
|
|
}
|
|
|
|
|
|
2021-10-20 17:34:46 +02:00
|
|
|
MATCHER(PackageIsEmpty, std::string(negation ? "isn't empty" : "is empty"))
|
|
|
|
|
{
|
2022-07-12 15:01:24 +02:00
|
|
|
const Storage::Synchronization::SynchronizationPackage &package = arg;
|
2021-10-20 17:34:46 +02:00
|
|
|
|
|
|
|
|
return package.imports.empty() && package.types.empty() && package.fileStatuses.empty()
|
2021-10-21 17:23:18 +02:00
|
|
|
&& package.updatedSourceIds.empty() && package.projectDatas.empty()
|
2022-06-13 13:23:12 +02:00
|
|
|
&& package.updatedFileStatusSourceIds.empty() && package.updatedProjectSourceIds.empty()
|
|
|
|
|
&& package.moduleDependencies.empty() && package.updatedModuleDependencySourceIds.empty()
|
|
|
|
|
&& package.moduleExportedImports.empty() && package.updatedModuleIds.empty();
|
2021-10-20 17:34:46 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
class ProjectStorageUpdater : public testing::Test
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ProjectStorageUpdater()
|
|
|
|
|
{
|
2023-03-09 15:06:22 +01:00
|
|
|
setFilesChanged({qmltypesPathSourceId,
|
|
|
|
|
qmltypes2PathSourceId,
|
|
|
|
|
qmlDirPathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
qmlDocumentSourceId3});
|
2021-09-16 17:19:56 +02:00
|
|
|
|
2023-03-06 18:03:57 +01:00
|
|
|
setFilesDontChanged({directoryPathSourceId,
|
|
|
|
|
path1SourceId,
|
|
|
|
|
path2SourceId,
|
|
|
|
|
path3SourceId,
|
|
|
|
|
firstSourceId,
|
|
|
|
|
secondSourceId,
|
|
|
|
|
thirdSourceId,
|
|
|
|
|
qmltypes1SourceId,
|
|
|
|
|
qmltypes2SourceId});
|
2023-02-28 15:12:07 +01:00
|
|
|
|
2023-03-09 15:06:22 +01:00
|
|
|
setFilesAdded({qmldir1SourceId, qmldir2SourceId, qmldir3SourceId});
|
2022-09-06 15:13:29 +02:00
|
|
|
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldirContent);
|
2021-09-20 14:12:57 +02:00
|
|
|
|
2023-03-06 18:03:57 +01:00
|
|
|
setQmlFileNames(u"/path", {"First.qml", "First2.qml", "Second.qml"});
|
2022-09-06 15:13:29 +02:00
|
|
|
|
2022-06-13 13:23:12 +02:00
|
|
|
ON_CALL(projectStorageMock, moduleId(_)).WillByDefault([&](const auto &name) {
|
|
|
|
|
return storage.moduleId(name);
|
|
|
|
|
});
|
2021-09-22 16:21:31 +02:00
|
|
|
|
2022-07-12 15:01:24 +02:00
|
|
|
firstType.prototype = Storage::Synchronization::ImportedType{"Object"};
|
|
|
|
|
secondType.prototype = Storage::Synchronization::ImportedType{"Object2"};
|
|
|
|
|
thirdType.prototype = Storage::Synchronization::ImportedType{"Object3"};
|
2021-09-22 16:21:31 +02:00
|
|
|
|
2023-03-09 15:06:22 +01:00
|
|
|
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/types/example2.qmltypes", qmltypes2);
|
2021-09-22 16:21:31 +02:00
|
|
|
|
2022-06-13 13:23:12 +02:00
|
|
|
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;
|
|
|
|
|
});
|
2021-10-21 17:23:18 +02:00
|
|
|
ON_CALL(qmlTypesParserMock, parse(Eq(qmltypes1), _, _, _))
|
|
|
|
|
.WillByDefault([&](auto, auto &imports, auto &types, auto) {
|
|
|
|
|
types.push_back(objectType);
|
|
|
|
|
imports.push_back(import4);
|
|
|
|
|
});
|
|
|
|
|
ON_CALL(qmlTypesParserMock, parse(Eq(qmltypes2), _, _, _))
|
|
|
|
|
.WillByDefault([&](auto, auto &imports, auto &types, auto) {
|
|
|
|
|
types.push_back(itemType);
|
|
|
|
|
imports.push_back(import5);
|
|
|
|
|
});
|
2021-09-16 17:19:56 +02:00
|
|
|
}
|
|
|
|
|
|
2023-03-06 18:03:57 +01:00
|
|
|
void setFilesDontChanged(const QmlDesigner::SourceIds &sourceIds)
|
|
|
|
|
{
|
|
|
|
|
for (auto sourceId : sourceIds) {
|
|
|
|
|
ON_CALL(fileSystemMock, fileStatus(Eq(sourceId)))
|
|
|
|
|
.WillByDefault(Return(FileStatus{sourceId, 2, 421}));
|
|
|
|
|
ON_CALL(projectStorageMock, fetchFileStatus(Eq(sourceId)))
|
|
|
|
|
.WillByDefault(Return(FileStatus{sourceId, 2, 421}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setFilesChanged(const QmlDesigner::SourceIds &sourceIds)
|
|
|
|
|
{
|
|
|
|
|
for (auto sourceId : sourceIds) {
|
|
|
|
|
ON_CALL(fileSystemMock, fileStatus(Eq(sourceId)))
|
|
|
|
|
.WillByDefault(Return(FileStatus{sourceId, 1, 21}));
|
|
|
|
|
ON_CALL(projectStorageMock, fetchFileStatus(Eq(sourceId)))
|
|
|
|
|
.WillByDefault(Return(FileStatus{sourceId, 2, 421}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setFilesAdded(const QmlDesigner::SourceIds &sourceIds)
|
|
|
|
|
{
|
|
|
|
|
for (auto sourceId : sourceIds) {
|
|
|
|
|
ON_CALL(fileSystemMock, fileStatus(Eq(sourceId)))
|
|
|
|
|
.WillByDefault(Return(FileStatus{sourceId, 1, 21}));
|
|
|
|
|
ON_CALL(projectStorageMock, fetchFileStatus(Eq(sourceId)))
|
|
|
|
|
.WillByDefault(Return(FileStatus{}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setFilesRemoved(const QmlDesigner::SourceIds &sourceIds)
|
|
|
|
|
{
|
|
|
|
|
for (auto sourceId : sourceIds) {
|
|
|
|
|
ON_CALL(fileSystemMock, fileStatus(Eq(sourceId))).WillByDefault(Return(FileStatus{}));
|
|
|
|
|
ON_CALL(projectStorageMock, fetchFileStatus(Eq(sourceId)))
|
|
|
|
|
.WillByDefault(Return(FileStatus{sourceId, 1, 21}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setFilesDontExists(const QmlDesigner::SourceIds &sourceIds)
|
|
|
|
|
{
|
|
|
|
|
for (auto sourceId : sourceIds) {
|
|
|
|
|
ON_CALL(fileSystemMock, fileStatus(Eq(sourceId))).WillByDefault(Return(FileStatus{}));
|
2023-03-09 15:06:22 +01:00
|
|
|
ON_CALL(projectStorageMock, fetchFileStatus(Eq(sourceId)))
|
|
|
|
|
.WillByDefault(Return(FileStatus{}));
|
2023-03-06 18:03:57 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setQmlFileNames(QStringView directoryPath, const QStringList &qmlFileNames)
|
|
|
|
|
{
|
|
|
|
|
ON_CALL(fileSystemMock, qmlFileNames(Eq(directoryPath))).WillByDefault(Return(qmlFileNames));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setProjectDatas(SourceId directoryPathSourceId,
|
|
|
|
|
const QmlDesigner::Storage::Synchronization::ProjectDatas &projectDatas)
|
|
|
|
|
{
|
|
|
|
|
ON_CALL(projectStorageMock, fetchProjectDatas(Eq(directoryPathSourceId)))
|
|
|
|
|
.WillByDefault(Return(projectDatas));
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-09 15:06:22 +01:00
|
|
|
void setContent(QStringView path, const QString &content)
|
|
|
|
|
{
|
|
|
|
|
ON_CALL(fileSystemMock, contentAsQString(Eq(path))).WillByDefault(Return(content));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setExpectedContent(QStringView path, const QString &content)
|
|
|
|
|
{
|
|
|
|
|
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(path))).WillRepeatedly(Return(content));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
protected:
|
|
|
|
|
NiceMock<FileSystemMock> fileSystemMock;
|
|
|
|
|
NiceMock<ProjectStorageMock> projectStorageMock;
|
|
|
|
|
NiceMock<QmlTypesParserMock> qmlTypesParserMock;
|
|
|
|
|
NiceMock<QmlDocumentParserMock> qmlDocumentParserMock;
|
|
|
|
|
QmlDesigner::FileStatusCache fileStatusCache{fileSystemMock};
|
|
|
|
|
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
|
|
|
|
|
QmlDesigner::ProjectStorage<Sqlite::Database> storage{database, database.isInitialized()};
|
|
|
|
|
QmlDesigner::SourcePathCache<QmlDesigner::ProjectStorage<Sqlite::Database>> sourcePathCache{
|
|
|
|
|
storage};
|
2023-02-16 13:53:28 +01:00
|
|
|
NiceMock<ProjectStoragePathWatcherMock> patchWatcherMock;
|
2022-06-13 13:23:12 +02:00
|
|
|
QmlDesigner::ProjectStorageUpdater updater{fileSystemMock,
|
|
|
|
|
projectStorageMock,
|
|
|
|
|
fileStatusCache,
|
|
|
|
|
sourcePathCache,
|
|
|
|
|
qmlDocumentParserMock,
|
2023-02-16 13:53:28 +01:00
|
|
|
qmlTypesParserMock,
|
|
|
|
|
patchWatcherMock};
|
2021-09-16 17:19:56 +02:00
|
|
|
SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/path/example.qmltypes");
|
2022-06-13 13:23:12 +02:00
|
|
|
SourceId qmltypes2PathSourceId = sourcePathCache.sourceId("/path/types/example2.qmltypes");
|
2021-09-16 17:19:56 +02:00
|
|
|
SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/path/qmldir");
|
2022-09-06 15:13:29 +02:00
|
|
|
SourceId directoryPathSourceId = sourcePathCache.sourceId("/path/.");
|
2021-09-20 14:12:57 +02:00
|
|
|
SourceId qmlDocumentSourceId1 = sourcePathCache.sourceId("/path/First.qml");
|
2022-06-13 13:23:12 +02:00
|
|
|
SourceId qmlDocumentSourceId2 = sourcePathCache.sourceId("/path/First2.qml");
|
2021-09-20 14:12:57 +02:00
|
|
|
SourceId qmlDocumentSourceId3 = sourcePathCache.sourceId("/path/Second.qml");
|
2021-10-11 11:15:47 +02:00
|
|
|
ModuleId qmlModuleId{storage.moduleId("Qml")};
|
2022-06-13 13:23:12 +02:00
|
|
|
ModuleId qmlCppNativeModuleId{storage.moduleId("Qml-cppnative")};
|
2021-10-11 11:15:47 +02:00
|
|
|
ModuleId exampleModuleId{storage.moduleId("Example")};
|
2022-06-13 13:23:12 +02:00
|
|
|
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")};
|
2022-07-12 15:01:24 +02:00
|
|
|
Storage::Synchronization::Type objectType{
|
|
|
|
|
"QObject",
|
|
|
|
|
Storage::Synchronization::ImportedType{},
|
2022-08-23 16:55:43 +02:00
|
|
|
Storage::Synchronization::ImportedType{},
|
2022-07-21 13:28:16 +02:00
|
|
|
Storage::TypeTraits::Reference,
|
2022-07-12 15:01:24 +02:00
|
|
|
qmltypesPathSourceId,
|
|
|
|
|
{Storage::Synchronization::ExportedType{exampleModuleId, "Object"},
|
|
|
|
|
Storage::Synchronization::ExportedType{exampleModuleId, "Obj"}}};
|
|
|
|
|
Storage::Synchronization::Type itemType{"QItem",
|
2022-08-23 16:55:43 +02:00
|
|
|
Storage::Synchronization::ImportedType{},
|
2022-07-12 15:01:24 +02:00
|
|
|
Storage::Synchronization::ImportedType{},
|
2022-07-21 13:28:16 +02:00
|
|
|
Storage::TypeTraits::Reference,
|
2022-07-12 15:01:24 +02:00
|
|
|
qmltypes2PathSourceId,
|
|
|
|
|
{Storage::Synchronization::ExportedType{exampleModuleId,
|
|
|
|
|
"Item"}}};
|
2021-09-22 16:21:31 +02:00
|
|
|
QString qmlDocument1{"First{}"};
|
|
|
|
|
QString qmlDocument2{"Second{}"};
|
|
|
|
|
QString qmlDocument3{"Third{}"};
|
2022-07-12 15:01:24 +02:00
|
|
|
Storage::Synchronization::Type firstType;
|
|
|
|
|
Storage::Synchronization::Type secondType;
|
|
|
|
|
Storage::Synchronization::Type thirdType;
|
|
|
|
|
Storage::Synchronization::Import import1{qmlModuleId,
|
|
|
|
|
Storage::Synchronization::Version{2, 3},
|
|
|
|
|
qmlDocumentSourceId1};
|
|
|
|
|
Storage::Synchronization::Import import2{qmlModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
qmlDocumentSourceId2};
|
|
|
|
|
Storage::Synchronization::Import import3{qmlModuleId,
|
|
|
|
|
Storage::Synchronization::Version{2},
|
|
|
|
|
qmlDocumentSourceId3};
|
|
|
|
|
Storage::Synchronization::Import import4{qmlModuleId,
|
|
|
|
|
Storage::Synchronization::Version{2, 3},
|
|
|
|
|
qmltypesPathSourceId};
|
|
|
|
|
Storage::Synchronization::Import import5{qmlModuleId,
|
|
|
|
|
Storage::Synchronization::Version{2, 3},
|
|
|
|
|
qmltypes2PathSourceId};
|
2021-10-21 17:23:18 +02:00
|
|
|
QString qmldirContent{"module Example\ntypeinfo example.qmltypes\n"};
|
|
|
|
|
QString qmltypes1{"Module {\ndependencies: [module1]}"};
|
|
|
|
|
QString qmltypes2{"Module {\ndependencies: [module2]}"};
|
2022-09-06 15:13:29 +02:00
|
|
|
QStringList directories = {"/path"};
|
2023-02-28 15:12:07 +01:00
|
|
|
QStringList directories2 = {"/path/one", "/path/two"};
|
|
|
|
|
QStringList directories3 = {"/path/one", "/path/two", "/path/three"};
|
|
|
|
|
QmlDesigner::ProjectPartId projectPartId = QmlDesigner::ProjectPartId::create(1);
|
|
|
|
|
SourceId path1SourceId = sourcePathCache.sourceId("/path/one/.");
|
|
|
|
|
SourceId path2SourceId = sourcePathCache.sourceId("/path/two/.");
|
|
|
|
|
SourceId path3SourceId = sourcePathCache.sourceId("/path/three/.");
|
|
|
|
|
SourceId qmldir1SourceId = sourcePathCache.sourceId("/path/one/qmldir");
|
|
|
|
|
SourceId qmldir2SourceId = sourcePathCache.sourceId("/path/two/qmldir");
|
|
|
|
|
SourceId qmldir3SourceId = sourcePathCache.sourceId("/path/three/qmldir");
|
|
|
|
|
SourceId firstSourceId = sourcePathCache.sourceId("/path/one/First.qml");
|
|
|
|
|
SourceId secondSourceId = sourcePathCache.sourceId("/path/one/Second.qml");
|
|
|
|
|
SourceId thirdSourceId = sourcePathCache.sourceId("/path/two/Third.qml");
|
|
|
|
|
SourceId qmltypes1SourceId = sourcePathCache.sourceId("/path/one/example.qmltypes");
|
|
|
|
|
SourceId qmltypes2SourceId = sourcePathCache.sourceId("/path/two/example2.qmltypes");
|
2021-09-16 17:19:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, GetContentForQmlDirPathsIfFileStatusIsDifferent)
|
|
|
|
|
{
|
2023-03-09 15:06:22 +01:00
|
|
|
SourceId qmlDir1PathSourceId = sourcePathCache.sourceId("/path/one/qmldir");
|
|
|
|
|
SourceId qmlDir2PathSourceId = sourcePathCache.sourceId("/path/two/qmldir");
|
2021-09-16 17:19:56 +02:00
|
|
|
SourceId qmlDir3PathSourceId = sourcePathCache.sourceId("/path/three/qmldir");
|
2023-02-23 15:45:58 +01:00
|
|
|
SourceId path3SourceId = sourcePathCache.sourceId("/path/three/.");
|
2022-09-06 15:13:29 +02:00
|
|
|
QStringList directories = {"/path/one", "/path/two", "/path/three"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setFilesChanged({qmlDir1PathSourceId, qmlDir2PathSourceId});
|
|
|
|
|
setFilesDontChanged({qmlDir3PathSourceId, path3SourceId});
|
2021-09-16 17:19:56 +02:00
|
|
|
|
|
|
|
|
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/one/qmldir"))));
|
|
|
|
|
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/two/qmldir"))));
|
|
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2021-09-16 17:19:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, RequestFileStatusFromFileSystem)
|
|
|
|
|
{
|
2023-03-02 13:33:46 +01:00
|
|
|
EXPECT_CALL(fileSystemMock, fileStatus(Ne(directoryPathSourceId))).Times(AnyNumber());
|
2021-09-16 17:19:56 +02:00
|
|
|
|
2023-03-02 13:33:46 +01:00
|
|
|
EXPECT_CALL(fileSystemMock, fileStatus(Eq(directoryPathSourceId)));
|
2021-09-16 17:19:56 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2021-09-16 17:19:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, GetContentForQmlTypes)
|
|
|
|
|
{
|
2021-10-21 17:23:18 +02:00
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
typeinfo example.qmltypes)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setQmlFileNames(u"/path", {});
|
|
|
|
|
setExpectedContent(u"/path/qmldir", qmldir);
|
2021-09-16 17:19:56 +02:00
|
|
|
|
|
|
|
|
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes"))));
|
|
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2021-09-16 17:19:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, GetContentForQmlTypesIfProjectStorageFileStatusIsInvalid)
|
|
|
|
|
{
|
2021-10-21 17:23:18 +02:00
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
typeinfo example.qmltypes)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setQmlFileNames(u"/path", {});
|
|
|
|
|
setExpectedContent(u"/path/qmldir", qmldir);
|
|
|
|
|
setFilesAdded({qmltypesPathSourceId});
|
2021-09-16 17:19:56 +02:00
|
|
|
|
|
|
|
|
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/example.qmltypes"))));
|
|
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2021-09-16 17:19:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, ParseQmlTypes)
|
|
|
|
|
{
|
2021-10-21 17:23:18 +02:00
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
typeinfo example.qmltypes
|
2022-06-13 13:23:12 +02:00
|
|
|
typeinfo types/example2.qmltypes)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
2021-09-16 17:19:56 +02:00
|
|
|
QString qmltypes{"Module {\ndependencies: []}"};
|
|
|
|
|
QString qmltypes2{"Module {\ndependencies: [foo]}"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/example.qmltypes", qmltypes);
|
|
|
|
|
setContent(u"/path/types/example2.qmltypes", qmltypes2);
|
2021-09-16 17:19:56 +02:00
|
|
|
|
2022-06-13 13:23:12 +02:00
|
|
|
EXPECT_CALL(qmlTypesParserMock,
|
|
|
|
|
parse(qmltypes, _, _, Field(&ProjectData::moduleId, exampleCppNativeModuleId)));
|
|
|
|
|
EXPECT_CALL(qmlTypesParserMock,
|
|
|
|
|
parse(qmltypes2, _, _, Field(&ProjectData::moduleId, exampleCppNativeModuleId)));
|
2021-09-16 17:19:56 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2021-09-16 17:19:56 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-20 14:12:57 +02:00
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeIsEmptyForNoChange)
|
2021-09-16 17:19:56 +02:00
|
|
|
{
|
2023-03-09 15:06:22 +01:00
|
|
|
setFilesDontChanged({qmltypesPathSourceId, qmltypes2PathSourceId, qmlDirPathSourceId});
|
2021-09-20 14:12:57 +02:00
|
|
|
|
2021-10-20 17:34:46 +02:00
|
|
|
EXPECT_CALL(projectStorageMock, synchronize(PackageIsEmpty()));
|
2021-09-16 17:19:56 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2021-09-16 17:19:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmlTypes)
|
|
|
|
|
{
|
2022-07-12 15:01:24 +02:00
|
|
|
Storage::Synchronization::Import import{qmlModuleId,
|
|
|
|
|
Storage::Synchronization::Version{2, 3},
|
|
|
|
|
qmltypesPathSourceId};
|
2021-09-16 17:19:56 +02:00
|
|
|
QString qmltypes{"Module {\ndependencies: []}"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setQmlFileNames(u"/path", {});
|
|
|
|
|
setContent(u"/path/example.qmltypes", qmltypes);
|
2021-10-19 14:42:28 +02:00
|
|
|
ON_CALL(qmlTypesParserMock, parse(qmltypes, _, _, _))
|
|
|
|
|
.WillByDefault([&](auto, auto &imports, auto &types, auto) {
|
2021-09-16 17:19:56 +02:00
|
|
|
types.push_back(objectType);
|
2021-09-20 14:12:57 +02:00
|
|
|
imports.push_back(import);
|
2021-09-16 17:19:56 +02:00
|
|
|
});
|
|
|
|
|
|
2021-10-11 11:15:47 +02:00
|
|
|
EXPECT_CALL(projectStorageMock, moduleId(Eq("Example")));
|
2022-06-13 13:23:12 +02:00
|
|
|
EXPECT_CALL(projectStorageMock, moduleId(Eq("Example-cppnative")));
|
|
|
|
|
EXPECT_CALL(projectStorageMock, moduleId(Eq("/path")));
|
2021-09-16 17:19:56 +02:00
|
|
|
EXPECT_CALL(projectStorageMock,
|
2021-10-20 17:34:46 +02:00
|
|
|
synchronize(
|
|
|
|
|
AllOf(Field(&SynchronizationPackage::imports, ElementsAre(import)),
|
|
|
|
|
Field(&SynchronizationPackage::types, ElementsAre(Eq(objectType))),
|
2021-10-21 17:23:18 +02:00
|
|
|
Field(&SynchronizationPackage::updatedSourceIds,
|
2021-10-20 17:34:46 +02:00
|
|
|
UnorderedElementsAre(qmlDirPathSourceId, qmltypesPathSourceId)),
|
|
|
|
|
Field(&SynchronizationPackage::fileStatuses,
|
2023-03-09 15:06:22 +01:00
|
|
|
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 1, 21),
|
|
|
|
|
IsFileStatus(qmltypesPathSourceId, 1, 21))),
|
2021-10-21 17:23:18 +02:00
|
|
|
Field(&SynchronizationPackage::projectDatas,
|
2023-03-02 13:33:46 +01:00
|
|
|
UnorderedElementsAre(IsProjectData(directoryPathSourceId,
|
2021-10-21 17:23:18 +02:00
|
|
|
qmltypesPathSourceId,
|
2022-06-13 13:23:12 +02:00
|
|
|
exampleCppNativeModuleId,
|
2021-10-21 17:23:18 +02:00
|
|
|
FileType::QmlTypes))),
|
2021-11-29 17:52:46 +01:00
|
|
|
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
2023-03-02 13:33:46 +01:00
|
|
|
UnorderedElementsAre(directoryPathSourceId)))));
|
2021-09-16 17:19:56 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2021-09-16 17:19:56 +02:00
|
|
|
}
|
|
|
|
|
|
2023-02-28 15:12:07 +01:00
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmlTypesThrowsIfQmltpesDoesNotExists)
|
|
|
|
|
{
|
|
|
|
|
Storage::Synchronization::Import import{qmlModuleId,
|
|
|
|
|
Storage::Synchronization::Version{2, 3},
|
|
|
|
|
qmltypesPathSourceId};
|
2023-03-09 15:06:22 +01:00
|
|
|
setFilesDontExists({qmltypesPathSourceId});
|
2023-02-28 15:12:07 +01:00
|
|
|
|
|
|
|
|
ASSERT_THROW(updater.update(directories, {}), QmlDesigner::CannotParseQmlTypesFile);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmlTypesAreEmptyIfFileDoesNotChanged)
|
|
|
|
|
{
|
|
|
|
|
QString qmltypes{"Module {\ndependencies: []}"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/example.qmltypes", qmltypes);
|
2021-10-19 14:42:28 +02:00
|
|
|
ON_CALL(qmlTypesParserMock, parse(qmltypes, _, _, _))
|
|
|
|
|
.WillByDefault([&](auto, auto &, auto &types, auto) { types.push_back(objectType); });
|
2023-03-09 15:06:22 +01:00
|
|
|
setFilesDontChanged({qmltypesPathSourceId, qmltypes2PathSourceId, qmlDirPathSourceId});
|
2021-09-16 17:19:56 +02:00
|
|
|
|
2021-10-20 17:34:46 +02:00
|
|
|
EXPECT_CALL(projectStorageMock, synchronize(PackageIsEmpty()));
|
2021-09-16 17:19:56 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2021-09-16 17:19:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, GetContentForQmlDocuments)
|
|
|
|
|
{
|
2022-06-13 13:23:12 +02:00
|
|
|
SourceId oldSecondSourceId3 = sourcePathCache.sourceId("/path/OldSecond.qml");
|
2023-03-09 15:06:22 +01:00
|
|
|
setQmlFileNames(u"/path", {"First.qml", "First2.qml", "OldSecond.qml", "Second.qml"});
|
|
|
|
|
setFilesAdded({oldSecondSourceId3});
|
|
|
|
|
setContent(u"/path/OldSecond.qml", qmlDocument3);
|
2022-06-13 13:23:12 +02:00
|
|
|
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)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setExpectedContent(u"/path/qmldir", qmldir);
|
2021-09-16 17:19:56 +02:00
|
|
|
|
|
|
|
|
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First.qml"))));
|
2022-06-13 13:23:12 +02:00
|
|
|
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/First2.qml"))));
|
|
|
|
|
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/OldSecond.qml"))));
|
2021-09-16 17:19:56 +02:00
|
|
|
EXPECT_CALL(fileSystemMock, contentAsQString(Eq(QString("/path/Second.qml"))));
|
|
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2021-09-16 17:19:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, ParseQmlDocuments)
|
|
|
|
|
{
|
2021-10-21 17:23:18 +02:00
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
FirstType 1.0 First.qml
|
2022-06-13 13:23:12 +02:00
|
|
|
FirstTypeV2 2.2 First2.qml
|
2021-10-21 17:23:18 +02:00
|
|
|
SecondType 2.2 Second.qml)"};
|
2021-09-16 17:19:56 +02:00
|
|
|
QString qmlDocument1{"First{}"};
|
|
|
|
|
QString qmlDocument2{"Second{}"};
|
|
|
|
|
QString qmlDocument3{"Third{}"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
|
|
|
|
setContent(u"/path/First.qml", qmlDocument1);
|
|
|
|
|
setContent(u"/path/First2.qml", qmlDocument2);
|
|
|
|
|
setContent(u"/path/Second.qml", qmlDocument3);
|
2021-09-16 17:19:56 +02:00
|
|
|
|
2022-06-13 13:23:12 +02:00
|
|
|
EXPECT_CALL(qmlDocumentParserMock, parse(qmlDocument1, _, _, _));
|
|
|
|
|
EXPECT_CALL(qmlDocumentParserMock, parse(qmlDocument2, _, _, _));
|
|
|
|
|
EXPECT_CALL(qmlDocumentParserMock, parse(qmlDocument3, _, _, _));
|
2021-09-16 17:19:56 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2021-09-16 17:19:56 +02:00
|
|
|
}
|
|
|
|
|
|
2021-10-21 17:23:18 +02:00
|
|
|
TEST_F(ProjectStorageUpdater, ParseQmlDocumentsWithNonExistingQmlDocumentThrows)
|
|
|
|
|
{
|
|
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
NonexitingType 1.0 NonexitingType.qml)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
2021-10-21 17:23:18 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
ASSERT_THROW(updater.update(directories, {}), QmlDesigner::CannotParseQmlDocumentFile);
|
2021-10-21 17:23:18 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmlDocuments)
|
|
|
|
|
{
|
2021-10-21 17:23:18 +02:00
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
FirstType 1.0 First.qml
|
2022-06-13 13:23:12 +02:00
|
|
|
FirstType 2.2 First2.qml
|
2021-10-21 17:23:18 +02:00
|
|
|
SecondType 2.2 Second.qml)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
2021-09-16 17:19:56 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
EXPECT_CALL(
|
|
|
|
|
projectStorageMock,
|
|
|
|
|
synchronize(AllOf(
|
|
|
|
|
Field(&SynchronizationPackage::imports, UnorderedElementsAre(import1, import2, import3)),
|
|
|
|
|
Field(
|
|
|
|
|
&SynchronizationPackage::types,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
AllOf(IsStorageType("First.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{"Object"},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Full),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType(exampleModuleId, "FirstType", 1, 0),
|
|
|
|
|
IsExportedType(pathModuleId, "First", -1, -1)))),
|
|
|
|
|
AllOf(IsStorageType("First2.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{"Object2"},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Full),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType(exampleModuleId, "FirstType", 2, 2),
|
|
|
|
|
IsExportedType(pathModuleId, "First2", -1, -1)))),
|
|
|
|
|
AllOf(IsStorageType("Second.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{"Object3"},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId3,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Full),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType(exampleModuleId, "SecondType", 2, 2),
|
|
|
|
|
IsExportedType(pathModuleId, "Second", -1, -1)))))),
|
|
|
|
|
Field(&SynchronizationPackage::updatedSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmlDirPathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
qmlDocumentSourceId3)),
|
|
|
|
|
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmlDirPathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
qmlDocumentSourceId3)),
|
|
|
|
|
Field(&SynchronizationPackage::fileStatuses,
|
2023-03-09 15:06:22 +01:00
|
|
|
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 1, 21),
|
|
|
|
|
IsFileStatus(qmlDocumentSourceId1, 1, 21),
|
|
|
|
|
IsFileStatus(qmlDocumentSourceId2, 1, 21),
|
|
|
|
|
IsFileStatus(qmlDocumentSourceId3, 1, 21))),
|
2022-09-06 15:13:29 +02:00
|
|
|
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
2023-03-02 13:33:46 +01:00
|
|
|
UnorderedElementsAre(directoryPathSourceId)),
|
2022-09-06 15:13:29 +02:00
|
|
|
Field(&SynchronizationPackage::projectDatas,
|
2023-03-02 13:33:46 +01:00
|
|
|
UnorderedElementsAre(IsProjectData(directoryPathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument),
|
|
|
|
|
IsProjectData(directoryPathSourceId,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument),
|
|
|
|
|
IsProjectData(directoryPathSourceId,
|
|
|
|
|
qmlDocumentSourceId3,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument))))));
|
2022-09-06 15:13:29 +02:00
|
|
|
|
|
|
|
|
updater.update(directories, {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeAddOnlyQmlDocumentInDirectory)
|
|
|
|
|
{
|
|
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
FirstType 1.0 First.qml)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
|
|
|
|
setFilesChanged({directoryPathSourceId});
|
|
|
|
|
setFilesDontChanged({qmlDirPathSourceId, qmlDocumentSourceId1});
|
|
|
|
|
setFilesAdded({qmlDocumentSourceId2});
|
|
|
|
|
setProjectDatas(directoryPathSourceId,
|
|
|
|
|
{{directoryPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument}});
|
|
|
|
|
setQmlFileNames(u"/path", {"First.qml", "First2.qml"});
|
2022-09-06 15:13:29 +02:00
|
|
|
|
2023-02-23 15:45:58 +01:00
|
|
|
EXPECT_CALL(projectStorageMock,
|
|
|
|
|
synchronize(AllOf(
|
|
|
|
|
Field(&SynchronizationPackage::imports, UnorderedElementsAre(import2)),
|
|
|
|
|
Field(&SynchronizationPackage::types,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
AllOf(IsStorageType("First.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Minimal),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsExportedType(exampleModuleId, "FirstType", 1, 0),
|
|
|
|
|
IsExportedType(pathModuleId, "First", -1, -1)))),
|
|
|
|
|
AllOf(IsStorageType("First2.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{"Object2"},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Full),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(
|
2023-03-02 13:33:46 +01:00
|
|
|
IsExportedType(pathModuleId, "First2", -1, -1)))))),
|
2023-02-23 15:45:58 +01:00
|
|
|
Field(&SynchronizationPackage::updatedSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmlDocumentSourceId1, qmlDocumentSourceId2)),
|
|
|
|
|
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
2023-03-02 13:33:46 +01:00
|
|
|
UnorderedElementsAre(directoryPathSourceId, qmlDocumentSourceId2)),
|
2023-02-23 15:45:58 +01:00
|
|
|
Field(&SynchronizationPackage::fileStatuses,
|
2023-03-09 15:06:22 +01:00
|
|
|
UnorderedElementsAre(IsFileStatus(qmlDocumentSourceId2, 1, 21),
|
|
|
|
|
IsFileStatus(directoryPathSourceId, 1, 21))),
|
2023-02-23 15:45:58 +01:00
|
|
|
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
2023-03-02 13:33:46 +01:00
|
|
|
UnorderedElementsAre(directoryPathSourceId)),
|
2023-02-23 15:45:58 +01:00
|
|
|
Field(&SynchronizationPackage::projectDatas,
|
2023-03-02 13:33:46 +01:00
|
|
|
UnorderedElementsAre(IsProjectData(directoryPathSourceId,
|
2023-02-23 15:45:58 +01:00
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument),
|
2023-03-02 13:33:46 +01:00
|
|
|
IsProjectData(directoryPathSourceId,
|
2023-02-23 15:45:58 +01:00
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
ModuleId{},
|
2023-03-02 13:33:46 +01:00
|
|
|
FileType::QmlDocument))))));
|
2021-10-21 17:23:18 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2021-10-21 17:23:18 +02:00
|
|
|
}
|
|
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeRemovesQmlDocument)
|
2021-10-21 17:23:18 +02:00
|
|
|
{
|
|
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
FirstType 1.0 First.qml
|
2022-06-13 13:23:12 +02:00
|
|
|
FirstType 2.2 First2.qml
|
2021-10-21 17:23:18 +02:00
|
|
|
)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
|
|
|
|
setFilesChanged({qmlDirPathSourceId});
|
|
|
|
|
setFilesDontChanged({qmlDocumentSourceId1, qmlDocumentSourceId2});
|
|
|
|
|
setFilesRemoved({qmlDocumentSourceId3});
|
|
|
|
|
setProjectDatas(directoryPathSourceId,
|
|
|
|
|
{{directoryPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument},
|
|
|
|
|
{directoryPathSourceId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument},
|
|
|
|
|
{directoryPathSourceId, qmlDocumentSourceId3, ModuleId{}, FileType::QmlDocument}});
|
|
|
|
|
setQmlFileNames(u"/path", {"First.qml", "First2.qml"});
|
2022-09-06 15:13:29 +02:00
|
|
|
|
|
|
|
|
EXPECT_CALL(projectStorageMock,
|
|
|
|
|
synchronize(AllOf(
|
|
|
|
|
Field(&SynchronizationPackage::imports, IsEmpty()),
|
|
|
|
|
Field(&SynchronizationPackage::types,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
AllOf(IsStorageType("First.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Minimal),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsExportedType(exampleModuleId, "FirstType", 1, 0),
|
|
|
|
|
IsExportedType(pathModuleId, "First", -1, -1)))),
|
|
|
|
|
AllOf(IsStorageType("First2.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Minimal),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsExportedType(exampleModuleId, "FirstType", 2, 2),
|
|
|
|
|
IsExportedType(pathModuleId, "First2", -1, -1)))))),
|
|
|
|
|
Field(&SynchronizationPackage::updatedSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmlDirPathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
qmlDocumentSourceId3)),
|
|
|
|
|
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId3)),
|
|
|
|
|
Field(&SynchronizationPackage::fileStatuses,
|
2023-03-09 15:06:22 +01:00
|
|
|
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 1, 21))),
|
2022-09-06 15:13:29 +02:00
|
|
|
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
2023-03-02 13:33:46 +01:00
|
|
|
UnorderedElementsAre(directoryPathSourceId)),
|
2022-09-06 15:13:29 +02:00
|
|
|
Field(&SynchronizationPackage::projectDatas,
|
2023-03-02 13:33:46 +01:00
|
|
|
UnorderedElementsAre(IsProjectData(directoryPathSourceId,
|
2022-09-06 15:13:29 +02:00
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument),
|
2023-03-02 13:33:46 +01:00
|
|
|
IsProjectData(directoryPathSourceId,
|
2022-09-06 15:13:29 +02:00
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument))))));
|
|
|
|
|
|
|
|
|
|
updater.update(directories, {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeRemovesQmlDocumentInQmldirOnly)
|
|
|
|
|
{
|
|
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
FirstType 1.0 First.qml
|
|
|
|
|
)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
|
|
|
|
setFilesChanged({qmlDirPathSourceId});
|
|
|
|
|
setFilesDontChanged({qmlDocumentSourceId1, qmlDocumentSourceId2});
|
|
|
|
|
setProjectDatas(directoryPathSourceId,
|
|
|
|
|
{{directoryPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument},
|
|
|
|
|
{directoryPathSourceId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument}});
|
|
|
|
|
setQmlFileNames(u"/path", {"First.qml", "First2.qml"});
|
2021-10-21 17:23:18 +02:00
|
|
|
|
|
|
|
|
EXPECT_CALL(
|
|
|
|
|
projectStorageMock,
|
|
|
|
|
synchronize(AllOf(
|
2022-09-06 15:13:29 +02:00
|
|
|
Field(&SynchronizationPackage::imports, IsEmpty()),
|
2021-10-21 17:23:18 +02:00
|
|
|
Field(&SynchronizationPackage::types,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
AllOf(IsStorageType("First.qml",
|
2022-09-06 15:13:29 +02:00
|
|
|
Storage::Synchronization::ImportedType{},
|
2022-07-21 13:28:16 +02:00
|
|
|
TypeTraits::Reference,
|
2021-10-21 17:23:18 +02:00
|
|
|
qmlDocumentSourceId1,
|
2022-09-06 15:13:29 +02:00
|
|
|
Storage::Synchronization::ChangeLevel::Minimal),
|
2022-07-12 15:01:24 +02:00
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
2022-09-06 15:13:29 +02:00
|
|
|
UnorderedElementsAre(IsExportedType(exampleModuleId, "FirstType", 1, 0),
|
|
|
|
|
IsExportedType(pathModuleId, "First", -1, -1)))),
|
2022-06-13 13:23:12 +02:00
|
|
|
AllOf(IsStorageType("First2.qml",
|
2022-07-12 15:01:24 +02:00
|
|
|
Storage::Synchronization::ImportedType{},
|
2022-07-21 13:28:16 +02:00
|
|
|
TypeTraits::Reference,
|
2021-10-21 17:23:18 +02:00
|
|
|
qmlDocumentSourceId2,
|
2022-07-12 15:01:24 +02:00
|
|
|
Storage::Synchronization::ChangeLevel::Minimal),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
2022-09-06 15:13:29 +02:00
|
|
|
UnorderedElementsAre(IsExportedType(pathModuleId, "First2", -1, -1)))))),
|
2021-10-21 17:23:18 +02:00
|
|
|
Field(&SynchronizationPackage::updatedSourceIds,
|
2022-09-06 15:13:29 +02:00
|
|
|
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1, qmlDocumentSourceId2)),
|
2021-10-21 17:23:18 +02:00
|
|
|
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
2022-09-06 15:13:29 +02:00
|
|
|
UnorderedElementsAre(qmlDirPathSourceId)),
|
2021-10-21 17:23:18 +02:00
|
|
|
Field(&SynchronizationPackage::fileStatuses,
|
2023-03-09 15:06:22 +01:00
|
|
|
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 1, 21))),
|
2021-11-29 17:52:46 +01:00
|
|
|
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
2023-03-02 13:33:46 +01:00
|
|
|
UnorderedElementsAre(directoryPathSourceId)),
|
2021-10-21 17:23:18 +02:00
|
|
|
Field(&SynchronizationPackage::projectDatas,
|
2023-03-02 13:33:46 +01:00
|
|
|
UnorderedElementsAre(IsProjectData(directoryPathSourceId,
|
2021-11-29 17:52:46 +01:00
|
|
|
qmlDocumentSourceId1,
|
2022-09-06 15:13:29 +02:00
|
|
|
ModuleId{},
|
2021-11-29 17:52:46 +01:00
|
|
|
FileType::QmlDocument),
|
2023-03-02 13:33:46 +01:00
|
|
|
IsProjectData(directoryPathSourceId,
|
2021-11-29 17:52:46 +01:00
|
|
|
qmlDocumentSourceId2,
|
2022-09-06 15:13:29 +02:00
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument))))));
|
|
|
|
|
|
|
|
|
|
updater.update(directories, {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeAddQmlDocumentToQmldir)
|
|
|
|
|
{
|
|
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
FirstType 1.0 First.qml
|
|
|
|
|
FirstType 2.2 First2.qml
|
|
|
|
|
)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
|
|
|
|
setFilesChanged({qmlDirPathSourceId});
|
|
|
|
|
setFilesDontChanged({qmlDocumentSourceId1, qmlDocumentSourceId2});
|
|
|
|
|
setProjectDatas(directoryPathSourceId,
|
|
|
|
|
{{directoryPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument},
|
|
|
|
|
{directoryPathSourceId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument}});
|
|
|
|
|
setQmlFileNames(u"/path", {"First.qml", "First2.qml"});
|
2022-09-06 15:13:29 +02:00
|
|
|
|
|
|
|
|
EXPECT_CALL(
|
|
|
|
|
projectStorageMock,
|
|
|
|
|
synchronize(AllOf(
|
|
|
|
|
Field(&SynchronizationPackage::imports, IsEmpty()),
|
|
|
|
|
Field(
|
|
|
|
|
&SynchronizationPackage::types,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
AllOf(IsStorageType("First.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Minimal),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType(exampleModuleId, "FirstType", 1, 0),
|
|
|
|
|
IsExportedType(pathModuleId, "First", -1, -1)))),
|
|
|
|
|
AllOf(IsStorageType("First2.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Minimal),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType(exampleModuleId, "FirstType", 2, 2),
|
|
|
|
|
IsExportedType(pathModuleId, "First2", -1, -1)))))),
|
|
|
|
|
Field(&SynchronizationPackage::updatedSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1, qmlDocumentSourceId2)),
|
|
|
|
|
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmlDirPathSourceId)),
|
|
|
|
|
Field(&SynchronizationPackage::fileStatuses,
|
2023-03-09 15:06:22 +01:00
|
|
|
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 1, 21))),
|
2022-09-06 15:13:29 +02:00
|
|
|
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
2023-03-02 13:33:46 +01:00
|
|
|
UnorderedElementsAre(directoryPathSourceId)),
|
2022-09-06 15:13:29 +02:00
|
|
|
Field(&SynchronizationPackage::projectDatas,
|
2023-03-02 13:33:46 +01:00
|
|
|
UnorderedElementsAre(IsProjectData(directoryPathSourceId,
|
2022-09-06 15:13:29 +02:00
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
ModuleId{},
|
2021-11-29 17:52:46 +01:00
|
|
|
FileType::QmlDocument),
|
2023-03-02 13:33:46 +01:00
|
|
|
IsProjectData(directoryPathSourceId,
|
2022-09-06 15:13:29 +02:00
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument))))));
|
2021-09-20 14:12:57 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2021-09-20 14:12:57 +02:00
|
|
|
}
|
|
|
|
|
|
2023-03-09 15:06:22 +01:00
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeRemoveQmlDocumentFromQmldir)
|
2021-09-22 16:21:31 +02:00
|
|
|
{
|
2021-10-21 17:23:18 +02:00
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
FirstType 1.0 First.qml
|
2022-09-06 15:13:29 +02:00
|
|
|
)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
|
|
|
|
setFilesDontChanged({qmlDocumentSourceId1, qmlDocumentSourceId2});
|
|
|
|
|
setFilesChanged({qmlDirPathSourceId});
|
|
|
|
|
setProjectDatas(directoryPathSourceId,
|
|
|
|
|
{{directoryPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument},
|
|
|
|
|
{directoryPathSourceId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument}});
|
|
|
|
|
setQmlFileNames(u"/path", {"First.qml", "First2.qml"});
|
2021-09-22 16:21:31 +02:00
|
|
|
|
|
|
|
|
EXPECT_CALL(
|
|
|
|
|
projectStorageMock,
|
2021-10-20 17:34:46 +02:00
|
|
|
synchronize(AllOf(
|
2022-09-06 15:13:29 +02:00
|
|
|
Field(&SynchronizationPackage::imports, IsEmpty()),
|
2021-10-20 17:34:46 +02:00
|
|
|
Field(&SynchronizationPackage::types,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
AllOf(IsStorageType("First.qml",
|
2022-09-06 15:13:29 +02:00
|
|
|
Storage::Synchronization::ImportedType{},
|
2022-07-21 13:28:16 +02:00
|
|
|
TypeTraits::Reference,
|
2021-10-21 17:23:18 +02:00
|
|
|
qmlDocumentSourceId1,
|
2022-09-06 15:13:29 +02:00
|
|
|
Storage::Synchronization::ChangeLevel::Minimal),
|
2022-07-12 15:01:24 +02:00
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
2022-09-06 15:13:29 +02:00
|
|
|
UnorderedElementsAre(IsExportedType(exampleModuleId, "FirstType", 1, 0),
|
|
|
|
|
IsExportedType(pathModuleId, "First", -1, -1)))),
|
2022-06-13 13:23:12 +02:00
|
|
|
AllOf(IsStorageType("First2.qml",
|
2022-07-12 15:01:24 +02:00
|
|
|
Storage::Synchronization::ImportedType{},
|
2022-07-21 13:28:16 +02:00
|
|
|
TypeTraits::Reference,
|
2022-09-06 15:13:29 +02:00
|
|
|
qmlDocumentSourceId2,
|
2022-07-12 15:01:24 +02:00
|
|
|
Storage::Synchronization::ChangeLevel::Minimal),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
2022-09-06 15:13:29 +02:00
|
|
|
UnorderedElementsAre(IsExportedType(pathModuleId, "First2", -1, -1)))))),
|
|
|
|
|
Field(&SynchronizationPackage::updatedSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1, qmlDocumentSourceId2)),
|
|
|
|
|
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmlDirPathSourceId)),
|
|
|
|
|
Field(&SynchronizationPackage::fileStatuses,
|
2023-03-09 15:06:22 +01:00
|
|
|
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 1, 21))),
|
2022-09-06 15:13:29 +02:00
|
|
|
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
2023-03-02 13:33:46 +01:00
|
|
|
UnorderedElementsAre(directoryPathSourceId)),
|
2022-09-06 15:13:29 +02:00
|
|
|
Field(&SynchronizationPackage::projectDatas,
|
2023-03-02 13:33:46 +01:00
|
|
|
UnorderedElementsAre(IsProjectData(directoryPathSourceId,
|
2022-09-06 15:13:29 +02:00
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument),
|
2023-03-02 13:33:46 +01:00
|
|
|
IsProjectData(directoryPathSourceId,
|
2022-09-06 15:13:29 +02:00
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument))))));
|
|
|
|
|
|
|
|
|
|
updater.update(directories, {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmlDocumentsDontUpdateIfUpToDate)
|
|
|
|
|
{
|
|
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
FirstType 1.0 First.qml
|
|
|
|
|
FirstType 2.2 First2.qml
|
|
|
|
|
SecondType 2.2 Second.qml)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
|
|
|
|
setFilesDontChanged({qmlDocumentSourceId3});
|
2022-09-06 15:13:29 +02:00
|
|
|
|
|
|
|
|
EXPECT_CALL(
|
|
|
|
|
projectStorageMock,
|
|
|
|
|
synchronize(AllOf(
|
|
|
|
|
Field(&SynchronizationPackage::imports, UnorderedElementsAre(import1, import2)),
|
|
|
|
|
Field(
|
|
|
|
|
&SynchronizationPackage::types,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
AllOf(IsStorageType("First.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{"Object"},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Full),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType(exampleModuleId, "FirstType", 1, 0),
|
|
|
|
|
IsExportedType(pathModuleId, "First", -1, -1)))),
|
|
|
|
|
AllOf(IsStorageType("First2.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{"Object2"},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Full),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType(exampleModuleId, "FirstType", 2, 2),
|
|
|
|
|
IsExportedType(pathModuleId, "First2", -1, -1)))),
|
|
|
|
|
AllOf(IsStorageType("Second.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId3,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Minimal),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType(exampleModuleId, "SecondType", 2, 2),
|
|
|
|
|
IsExportedType(pathModuleId, "Second", -1, -1)))))),
|
2021-10-21 17:23:18 +02:00
|
|
|
Field(&SynchronizationPackage::updatedSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmlDirPathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
qmlDocumentSourceId3)),
|
2021-10-20 17:34:46 +02:00
|
|
|
Field(&SynchronizationPackage::fileStatuses,
|
2023-03-09 15:06:22 +01:00
|
|
|
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 1, 21),
|
|
|
|
|
IsFileStatus(qmlDocumentSourceId1, 1, 21),
|
|
|
|
|
IsFileStatus(qmlDocumentSourceId2, 1, 21))),
|
2021-10-21 17:23:18 +02:00
|
|
|
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId1, qmlDocumentSourceId2)),
|
2021-11-29 17:52:46 +01:00
|
|
|
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
2023-03-02 13:33:46 +01:00
|
|
|
UnorderedElementsAre(directoryPathSourceId)),
|
2021-10-21 17:23:18 +02:00
|
|
|
Field(&SynchronizationPackage::projectDatas,
|
2023-03-02 13:33:46 +01:00
|
|
|
UnorderedElementsAre(IsProjectData(directoryPathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument),
|
|
|
|
|
IsProjectData(directoryPathSourceId,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument),
|
|
|
|
|
IsProjectData(directoryPathSourceId,
|
|
|
|
|
qmlDocumentSourceId3,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument))))));
|
2022-09-06 15:13:29 +02:00
|
|
|
|
|
|
|
|
updater.update(directories, {});
|
2021-09-22 16:21:31 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-23 14:35:06 +02:00
|
|
|
TEST_F(ProjectStorageUpdater, UpdateQmldirDocuments)
|
|
|
|
|
{
|
2021-10-21 17:23:18 +02:00
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
FirstType 1.1 First.qml
|
2022-06-13 13:23:12 +02:00
|
|
|
FirstType 2.2 First2.qml
|
2021-10-21 17:23:18 +02:00
|
|
|
SecondType 2.2 Second.qml)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
|
|
|
|
setFilesDontChanged({qmlDocumentSourceId3});
|
2021-09-23 14:35:06 +02:00
|
|
|
|
|
|
|
|
updater.pathsWithIdsChanged({});
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-21 17:23:18 +02:00
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizIfQmldirFileHasNotChanged)
|
|
|
|
|
{
|
2023-03-09 15:06:22 +01:00
|
|
|
setProjectDatas(
|
|
|
|
|
directoryPathSourceId,
|
|
|
|
|
{{directoryPathSourceId, qmltypesPathSourceId, exampleModuleId, FileType::QmlTypes},
|
|
|
|
|
{directoryPathSourceId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes},
|
|
|
|
|
{directoryPathSourceId, qmlDocumentSourceId1, exampleModuleId, FileType::QmlDocument},
|
|
|
|
|
{directoryPathSourceId, qmlDocumentSourceId2, exampleModuleId, FileType::QmlDocument}});
|
|
|
|
|
setFilesDontChanged({qmlDirPathSourceId});
|
2021-10-21 17:23:18 +02:00
|
|
|
|
2022-07-12 15:01:24 +02:00
|
|
|
EXPECT_CALL(
|
|
|
|
|
projectStorageMock,
|
|
|
|
|
synchronize(AllOf(
|
|
|
|
|
Field(&SynchronizationPackage::imports,
|
|
|
|
|
UnorderedElementsAre(import1, import2, import4, import5)),
|
|
|
|
|
Field(&SynchronizationPackage::types,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
Eq(objectType),
|
|
|
|
|
Eq(itemType),
|
|
|
|
|
AllOf(IsStorageType("First.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{"Object"},
|
2022-07-21 13:28:16 +02:00
|
|
|
TypeTraits::Reference,
|
2022-07-12 15:01:24 +02:00
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::ExcludeExportedTypes),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())),
|
|
|
|
|
AllOf(IsStorageType("First2.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{"Object2"},
|
2022-07-21 13:28:16 +02:00
|
|
|
TypeTraits::Reference,
|
2022-07-12 15:01:24 +02:00
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::ExcludeExportedTypes),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())))),
|
|
|
|
|
Field(&SynchronizationPackage::updatedSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmltypesPathSourceId,
|
|
|
|
|
qmltypes2PathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
qmlDocumentSourceId2)),
|
|
|
|
|
Field(&SynchronizationPackage::fileStatuses,
|
2023-03-09 15:06:22 +01:00
|
|
|
UnorderedElementsAre(IsFileStatus(qmltypesPathSourceId, 1, 21),
|
|
|
|
|
IsFileStatus(qmltypes2PathSourceId, 1, 21),
|
|
|
|
|
IsFileStatus(qmlDocumentSourceId1, 1, 21),
|
|
|
|
|
IsFileStatus(qmlDocumentSourceId2, 1, 21))),
|
2022-07-12 15:01:24 +02:00
|
|
|
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmltypesPathSourceId,
|
|
|
|
|
qmltypes2PathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
qmlDocumentSourceId2)),
|
|
|
|
|
Field(&SynchronizationPackage::projectDatas, IsEmpty()))));
|
2021-10-21 17:23:18 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2021-10-21 17:23:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizIfQmldirFileHasNotChangedAndSomeUpdatedFiles)
|
|
|
|
|
{
|
2023-03-09 15:06:22 +01:00
|
|
|
setProjectDatas(
|
|
|
|
|
directoryPathSourceId,
|
|
|
|
|
{{directoryPathSourceId, qmltypesPathSourceId, exampleModuleId, FileType::QmlTypes},
|
|
|
|
|
{directoryPathSourceId, qmltypes2PathSourceId, exampleModuleId, FileType::QmlTypes},
|
|
|
|
|
{directoryPathSourceId, qmlDocumentSourceId1, exampleModuleId, FileType::QmlDocument},
|
|
|
|
|
{directoryPathSourceId, qmlDocumentSourceId2, exampleModuleId, FileType::QmlDocument}});
|
|
|
|
|
setFilesDontChanged({qmlDirPathSourceId, qmltypes2PathSourceId, qmlDocumentSourceId2});
|
2021-10-21 17:23:18 +02:00
|
|
|
|
|
|
|
|
EXPECT_CALL(
|
|
|
|
|
projectStorageMock,
|
|
|
|
|
synchronize(
|
|
|
|
|
AllOf(Field(&SynchronizationPackage::imports, UnorderedElementsAre(import1, import4)),
|
|
|
|
|
Field(&SynchronizationPackage::types,
|
2022-07-12 15:01:24 +02:00
|
|
|
UnorderedElementsAre(
|
|
|
|
|
Eq(objectType),
|
|
|
|
|
AllOf(IsStorageType("First.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{"Object"},
|
2022-07-21 13:28:16 +02:00
|
|
|
TypeTraits::Reference,
|
2022-07-12 15:01:24 +02:00
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::ExcludeExportedTypes),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes, IsEmpty())))),
|
2021-10-21 17:23:18 +02:00
|
|
|
Field(&SynchronizationPackage::updatedSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmltypesPathSourceId, qmlDocumentSourceId1)),
|
|
|
|
|
Field(&SynchronizationPackage::fileStatuses,
|
2023-03-09 15:06:22 +01:00
|
|
|
UnorderedElementsAre(IsFileStatus(qmltypesPathSourceId, 1, 21),
|
|
|
|
|
IsFileStatus(qmlDocumentSourceId1, 1, 21))),
|
2021-10-21 17:23:18 +02:00
|
|
|
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmltypesPathSourceId, qmlDocumentSourceId1)),
|
|
|
|
|
Field(&SynchronizationPackage::projectDatas, IsEmpty()))));
|
|
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2022-06-13 13:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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,
|
2023-03-09 15:06:22 +01:00
|
|
|
UnorderedElementsAre(IsFileStatus(qmltypesPathSourceId, 1, 21),
|
|
|
|
|
IsFileStatus(qmltypes2PathSourceId, 1, 21))),
|
2022-06-13 13:23:12 +02:00
|
|
|
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)
|
|
|
|
|
{
|
2023-03-09 15:06:22 +01:00
|
|
|
setFilesDontChanged({qmltypes2PathSourceId});
|
2022-06-13 13:23:12 +02:00
|
|
|
|
|
|
|
|
EXPECT_CALL(projectStorageMock,
|
|
|
|
|
synchronize(
|
|
|
|
|
AllOf(Field(&SynchronizationPackage::imports, UnorderedElementsAre(import4)),
|
|
|
|
|
Field(&SynchronizationPackage::types, UnorderedElementsAre(objectType)),
|
|
|
|
|
Field(&SynchronizationPackage::updatedSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmltypesPathSourceId)),
|
|
|
|
|
Field(&SynchronizationPackage::fileStatuses,
|
2023-03-09 15:06:22 +01:00
|
|
|
UnorderedElementsAre(IsFileStatus(qmltypesPathSourceId, 1, 21))),
|
2022-06-13 13:23:12 +02:00
|
|
|
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)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
|
|
|
|
setQmlFileNames(u"/path", {"First.qml"});
|
2022-06-13 13:23:12 +02:00
|
|
|
|
2023-03-02 13:33:46 +01:00
|
|
|
EXPECT_CALL(projectStorageMock,
|
|
|
|
|
synchronize(
|
|
|
|
|
AllOf(Field(&SynchronizationPackage::imports, UnorderedElementsAre(import1)),
|
|
|
|
|
Field(&SynchronizationPackage::types,
|
|
|
|
|
UnorderedElementsAre(AllOf(
|
|
|
|
|
IsStorageType("First.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{"Object"},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Full),
|
|
|
|
|
Field(&Storage::Synchronization::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,
|
2023-03-09 15:06:22 +01:00
|
|
|
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 1, 21),
|
|
|
|
|
IsFileStatus(qmlDocumentSourceId1, 1, 21))),
|
2023-03-02 13:33:46 +01:00
|
|
|
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
|
|
|
|
UnorderedElementsAre(directoryPathSourceId)),
|
|
|
|
|
Field(&SynchronizationPackage::projectDatas,
|
|
|
|
|
UnorderedElementsAre(IsProjectData(directoryPathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument))))));
|
2022-06-13 13:23:12 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2022-06-13 13:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmlDocumentsWithDifferentTypeNameButSameVersionAndFileName)
|
|
|
|
|
{
|
|
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
FirstType 1.0 First.qml
|
|
|
|
|
FirstType2 1.0 First.qml)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
|
|
|
|
setQmlFileNames(u"/path", {"First.qml"});
|
2022-06-13 13:23:12 +02:00
|
|
|
|
2023-03-02 13:33:46 +01:00
|
|
|
EXPECT_CALL(projectStorageMock,
|
|
|
|
|
synchronize(
|
|
|
|
|
AllOf(Field(&SynchronizationPackage::imports, UnorderedElementsAre(import1)),
|
|
|
|
|
Field(&SynchronizationPackage::types,
|
|
|
|
|
UnorderedElementsAre(AllOf(
|
|
|
|
|
IsStorageType("First.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{"Object"},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Full),
|
|
|
|
|
Field(&Storage::Synchronization::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,
|
2023-03-09 15:06:22 +01:00
|
|
|
UnorderedElementsAre(IsFileStatus(qmlDirPathSourceId, 1, 21),
|
|
|
|
|
IsFileStatus(qmlDocumentSourceId1, 1, 21))),
|
2023-03-02 13:33:46 +01:00
|
|
|
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
|
|
|
|
UnorderedElementsAre(directoryPathSourceId)),
|
|
|
|
|
Field(&SynchronizationPackage::projectDatas,
|
|
|
|
|
UnorderedElementsAre(IsProjectData(directoryPathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument))))));
|
2022-06-13 13:23:12 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2022-06-13 13:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, DontSynchronizeSelectors)
|
|
|
|
|
{
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/+First.qml", qmlDocument1);
|
|
|
|
|
setContent(u"/path/qml/+First.qml", qmlDocument1);
|
2022-06-13 13:23:12 +02:00
|
|
|
QString qmldir{R"(module Example
|
2022-09-06 15:13:29 +02:00
|
|
|
FirstType 1.0 +First.qml)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
|
|
|
|
setQmlFileNames(u"/path", {"First.qml"});
|
2022-06-13 13:23:12 +02:00
|
|
|
|
|
|
|
|
EXPECT_CALL(projectStorageMock,
|
2022-09-06 15:13:29 +02:00
|
|
|
synchronize(Not(Field(
|
|
|
|
|
&SynchronizationPackage::types,
|
|
|
|
|
Contains(Field(&Storage::Synchronization::Type::exportedTypes,
|
|
|
|
|
Contains(IsExportedType(exampleModuleId, "FirstType", 1, 0))))))));
|
2022-06-13 13:23:12 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2022-06-13 13:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmldirDependencies)
|
|
|
|
|
{
|
|
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
depends Qml
|
|
|
|
|
depends QML
|
|
|
|
|
typeinfo example.qmltypes
|
|
|
|
|
typeinfo types/example2.qmltypes
|
|
|
|
|
)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
2022-06-13 13:23:12 +02:00
|
|
|
|
2022-07-12 15:01:24 +02:00
|
|
|
EXPECT_CALL(projectStorageMock,
|
|
|
|
|
synchronize(
|
|
|
|
|
AllOf(Field(&SynchronizationPackage::moduleDependencies,
|
|
|
|
|
UnorderedElementsAre(Import{qmlCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
qmltypesPathSourceId},
|
|
|
|
|
Import{builtinCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
qmltypesPathSourceId},
|
|
|
|
|
Import{qmlCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
qmltypes2PathSourceId},
|
|
|
|
|
Import{builtinCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
qmltypes2PathSourceId})),
|
|
|
|
|
Field(&SynchronizationPackage::updatedModuleDependencySourceIds,
|
|
|
|
|
UnorderedElementsAre(qmltypesPathSourceId, qmltypes2PathSourceId)))));
|
2022-06-13 13:23:12 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2022-06-13 13:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmldirDependenciesWithDoubleEntries)
|
|
|
|
|
{
|
|
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
depends Qml
|
|
|
|
|
depends QML
|
|
|
|
|
depends Qml
|
|
|
|
|
typeinfo example.qmltypes
|
|
|
|
|
typeinfo types/example2.qmltypes
|
|
|
|
|
)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
2022-06-13 13:23:12 +02:00
|
|
|
|
2022-07-12 15:01:24 +02:00
|
|
|
EXPECT_CALL(projectStorageMock,
|
|
|
|
|
synchronize(
|
|
|
|
|
AllOf(Field(&SynchronizationPackage::moduleDependencies,
|
|
|
|
|
UnorderedElementsAre(Import{qmlCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
qmltypesPathSourceId},
|
|
|
|
|
Import{builtinCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
qmltypesPathSourceId},
|
|
|
|
|
Import{qmlCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
qmltypes2PathSourceId},
|
|
|
|
|
Import{builtinCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
qmltypes2PathSourceId})),
|
|
|
|
|
Field(&SynchronizationPackage::updatedModuleDependencySourceIds,
|
|
|
|
|
UnorderedElementsAre(qmltypesPathSourceId, qmltypes2PathSourceId)))));
|
2022-06-13 13:23:12 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2022-06-13 13:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmldirDependenciesWithCollidingImports)
|
|
|
|
|
{
|
|
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
depends Qml
|
|
|
|
|
depends QML
|
|
|
|
|
import Qml
|
|
|
|
|
typeinfo example.qmltypes
|
|
|
|
|
typeinfo types/example2.qmltypes
|
|
|
|
|
)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
2022-06-13 13:23:12 +02:00
|
|
|
|
2022-07-12 15:01:24 +02:00
|
|
|
EXPECT_CALL(projectStorageMock,
|
|
|
|
|
synchronize(
|
|
|
|
|
AllOf(Field(&SynchronizationPackage::moduleDependencies,
|
|
|
|
|
UnorderedElementsAre(Import{qmlCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
qmltypesPathSourceId},
|
|
|
|
|
Import{builtinCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
qmltypesPathSourceId},
|
|
|
|
|
Import{qmlCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
qmltypes2PathSourceId},
|
|
|
|
|
Import{builtinCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
qmltypes2PathSourceId})),
|
|
|
|
|
Field(&SynchronizationPackage::updatedModuleDependencySourceIds,
|
|
|
|
|
UnorderedElementsAre(qmltypesPathSourceId, qmltypes2PathSourceId)))));
|
2022-06-13 13:23:12 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2022-06-13 13:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmldirWithNoDependencies)
|
|
|
|
|
{
|
|
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
typeinfo example.qmltypes
|
|
|
|
|
typeinfo types/example2.qmltypes
|
|
|
|
|
)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
2022-06-13 13:23:12 +02:00
|
|
|
|
|
|
|
|
EXPECT_CALL(projectStorageMock,
|
|
|
|
|
synchronize(
|
|
|
|
|
AllOf(Field(&SynchronizationPackage::moduleDependencies, IsEmpty()),
|
|
|
|
|
Field(&SynchronizationPackage::updatedModuleDependencySourceIds,
|
|
|
|
|
UnorderedElementsAre(qmltypesPathSourceId, qmltypes2PathSourceId)))));
|
|
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2022-06-13 13:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmldirImports)
|
|
|
|
|
{
|
|
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
import Qml auto
|
|
|
|
|
import QML 2.1
|
|
|
|
|
import Quick
|
|
|
|
|
)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
2022-06-13 13:23:12 +02:00
|
|
|
|
2022-07-12 15:01:24 +02:00
|
|
|
EXPECT_CALL(
|
|
|
|
|
projectStorageMock,
|
|
|
|
|
synchronize(AllOf(
|
|
|
|
|
Field(&SynchronizationPackage::moduleExportedImports,
|
|
|
|
|
UnorderedElementsAre(ModuleExportedImport{exampleModuleId,
|
|
|
|
|
qmlModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
IsAutoVersion::Yes},
|
|
|
|
|
ModuleExportedImport{exampleCppNativeModuleId,
|
|
|
|
|
qmlCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
IsAutoVersion::No},
|
|
|
|
|
ModuleExportedImport{exampleModuleId,
|
|
|
|
|
builtinModuleId,
|
|
|
|
|
Storage::Synchronization::Version{2, 1},
|
|
|
|
|
IsAutoVersion::No},
|
|
|
|
|
ModuleExportedImport{exampleCppNativeModuleId,
|
|
|
|
|
builtinCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
IsAutoVersion::No},
|
|
|
|
|
ModuleExportedImport{exampleModuleId,
|
|
|
|
|
quickModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
IsAutoVersion::No},
|
|
|
|
|
ModuleExportedImport{exampleCppNativeModuleId,
|
|
|
|
|
quickCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
IsAutoVersion::No})),
|
|
|
|
|
Field(&SynchronizationPackage::updatedModuleIds, ElementsAre(exampleModuleId)))));
|
2022-06-13 13:23:12 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2022-06-13 13:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmldirWithNoImports)
|
|
|
|
|
{
|
|
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
2022-06-13 13:23:12 +02:00
|
|
|
|
|
|
|
|
EXPECT_CALL(projectStorageMock,
|
|
|
|
|
synchronize(AllOf(Field(&SynchronizationPackage::moduleExportedImports, IsEmpty()),
|
|
|
|
|
Field(&SynchronizationPackage::updatedModuleIds,
|
|
|
|
|
ElementsAre(exampleModuleId)))));
|
|
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2022-06-13 13:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmldirImportsWithDoubleEntries)
|
|
|
|
|
{
|
|
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
import Qml auto
|
|
|
|
|
import QML 2.1
|
|
|
|
|
import Quick
|
|
|
|
|
import Qml
|
|
|
|
|
)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
2022-06-13 13:23:12 +02:00
|
|
|
|
2022-07-12 15:01:24 +02:00
|
|
|
EXPECT_CALL(
|
|
|
|
|
projectStorageMock,
|
|
|
|
|
synchronize(AllOf(
|
|
|
|
|
Field(&SynchronizationPackage::moduleExportedImports,
|
|
|
|
|
UnorderedElementsAre(ModuleExportedImport{exampleModuleId,
|
|
|
|
|
qmlModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
IsAutoVersion::Yes},
|
|
|
|
|
ModuleExportedImport{exampleCppNativeModuleId,
|
|
|
|
|
qmlCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
IsAutoVersion::No},
|
|
|
|
|
ModuleExportedImport{exampleModuleId,
|
|
|
|
|
builtinModuleId,
|
|
|
|
|
Storage::Synchronization::Version{2, 1},
|
|
|
|
|
IsAutoVersion::No},
|
|
|
|
|
ModuleExportedImport{exampleCppNativeModuleId,
|
|
|
|
|
builtinCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
IsAutoVersion::No},
|
|
|
|
|
ModuleExportedImport{exampleModuleId,
|
|
|
|
|
quickModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
IsAutoVersion::No},
|
|
|
|
|
ModuleExportedImport{exampleCppNativeModuleId,
|
|
|
|
|
quickCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
IsAutoVersion::No})),
|
|
|
|
|
Field(&SynchronizationPackage::updatedModuleIds, ElementsAre(exampleModuleId)))));
|
2022-06-13 13:23:12 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2022-06-13 13:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmldirOptionalImports)
|
|
|
|
|
{
|
|
|
|
|
QString qmldir{R"(module Example
|
|
|
|
|
import Qml auto
|
|
|
|
|
import QML 2.1
|
|
|
|
|
optional import Quick
|
|
|
|
|
)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/qmldir", qmldir);
|
2022-06-13 13:23:12 +02:00
|
|
|
|
2022-07-12 15:01:24 +02:00
|
|
|
EXPECT_CALL(
|
|
|
|
|
projectStorageMock,
|
|
|
|
|
synchronize(AllOf(
|
|
|
|
|
Field(&SynchronizationPackage::moduleExportedImports,
|
|
|
|
|
UnorderedElementsAre(ModuleExportedImport{exampleModuleId,
|
|
|
|
|
qmlModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
IsAutoVersion::Yes},
|
|
|
|
|
ModuleExportedImport{exampleCppNativeModuleId,
|
|
|
|
|
qmlCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
IsAutoVersion::No},
|
|
|
|
|
ModuleExportedImport{exampleModuleId,
|
|
|
|
|
builtinModuleId,
|
|
|
|
|
Storage::Synchronization::Version{2, 1},
|
|
|
|
|
IsAutoVersion::No},
|
|
|
|
|
ModuleExportedImport{exampleCppNativeModuleId,
|
|
|
|
|
builtinCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
IsAutoVersion::No},
|
|
|
|
|
ModuleExportedImport{exampleModuleId,
|
|
|
|
|
quickModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
IsAutoVersion::No},
|
|
|
|
|
ModuleExportedImport{exampleCppNativeModuleId,
|
|
|
|
|
quickCppNativeModuleId,
|
|
|
|
|
Storage::Synchronization::Version{},
|
|
|
|
|
IsAutoVersion::No})),
|
|
|
|
|
Field(&SynchronizationPackage::updatedModuleIds, ElementsAre(exampleModuleId)))));
|
2022-06-13 13:23:12 +02:00
|
|
|
|
2022-09-06 15:13:29 +02:00
|
|
|
updater.update(directories, {});
|
2021-10-21 17:23:18 +02:00
|
|
|
}
|
|
|
|
|
|
2023-02-28 15:12:07 +01:00
|
|
|
TEST_F(ProjectStorageUpdater, UpdatePathWatcherDirectories)
|
|
|
|
|
{
|
|
|
|
|
EXPECT_CALL(patchWatcherMock,
|
|
|
|
|
updateIdPaths(Contains(IdPaths{projectPartId,
|
|
|
|
|
QmlDesigner::SourceType::Directory,
|
|
|
|
|
{path1SourceId, path2SourceId, path3SourceId}})));
|
|
|
|
|
|
|
|
|
|
updater.update(directories3, {}, projectPartId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, UpdatePathWatcherDirectoryDoesNotExists)
|
|
|
|
|
{
|
2023-03-09 15:06:22 +01:00
|
|
|
setFilesDontExists({path2SourceId});
|
2023-02-28 15:12:07 +01:00
|
|
|
|
|
|
|
|
EXPECT_CALL(patchWatcherMock,
|
|
|
|
|
updateIdPaths(Contains(IdPaths{projectPartId,
|
|
|
|
|
QmlDesigner::SourceType::Directory,
|
|
|
|
|
{path1SourceId, path3SourceId}})));
|
|
|
|
|
|
|
|
|
|
updater.update(directories3, {}, projectPartId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, UpdatePathWatcherQmldirs)
|
|
|
|
|
{
|
|
|
|
|
EXPECT_CALL(patchWatcherMock,
|
|
|
|
|
updateIdPaths(Contains(IdPaths{projectPartId,
|
|
|
|
|
QmlDesigner::SourceType::QmlDir,
|
|
|
|
|
{qmldir1SourceId, qmldir2SourceId, qmldir3SourceId}})));
|
|
|
|
|
|
|
|
|
|
updater.update(directories3, {}, projectPartId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, UpdatePathWatcherQmldirDoesNotExists)
|
|
|
|
|
{
|
2023-03-09 15:06:22 +01:00
|
|
|
setFilesDontExists({qmldir2SourceId});
|
2023-02-28 15:12:07 +01:00
|
|
|
|
|
|
|
|
EXPECT_CALL(patchWatcherMock,
|
|
|
|
|
updateIdPaths(Contains(IdPaths{projectPartId,
|
|
|
|
|
QmlDesigner::SourceType::QmlDir,
|
|
|
|
|
{qmldir1SourceId, qmldir3SourceId}})));
|
|
|
|
|
|
|
|
|
|
updater.update(directories3, {}, projectPartId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, UpdatePathWatcherQmlFiles)
|
|
|
|
|
{
|
|
|
|
|
QString qmldir1{R"(module Example
|
|
|
|
|
FirstType 1.0 First.qml
|
|
|
|
|
Second 1.0 Second.qml)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setQmlFileNames(u"/path/one", {"First.qml", "Second.qml"});
|
|
|
|
|
setQmlFileNames(u"/path/two", {"Third.qml"});
|
|
|
|
|
setContent(u"/path/one/qmldir", qmldir1);
|
|
|
|
|
setContent(u"/path/one/First.qml", qmlDocument1);
|
|
|
|
|
setContent(u"/path/one/Second.qml", qmlDocument2);
|
|
|
|
|
setContent(u"/path/two/Third.qml", qmlDocument3);
|
2023-02-28 15:12:07 +01:00
|
|
|
|
|
|
|
|
EXPECT_CALL(patchWatcherMock,
|
|
|
|
|
updateIdPaths(Contains(IdPaths{projectPartId,
|
|
|
|
|
QmlDesigner::SourceType::Qml,
|
|
|
|
|
{firstSourceId, secondSourceId, thirdSourceId}})));
|
|
|
|
|
|
|
|
|
|
updater.update(directories2, {}, projectPartId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, UpdatePathWatcherQmltypesFilesInQmldirFiles)
|
|
|
|
|
{
|
|
|
|
|
QString qmldir1{R"(module Example
|
|
|
|
|
typeinfo example.qmltypes)"};
|
|
|
|
|
QString qmldir2{R"(module Example2
|
|
|
|
|
typeinfo example2.qmltypes)"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(u"/path/one/qmldir", qmldir1);
|
|
|
|
|
setContent(u"/path/two/qmldir", qmldir2);
|
|
|
|
|
setContent(u"/path/one/example.qmltypes", qmltypes1);
|
|
|
|
|
setContent(u"/path/two/example2.qmltypes", qmltypes2);
|
2023-02-28 15:12:07 +01:00
|
|
|
SourceId qmltypes1SourceId = sourcePathCache.sourceId("/path/one/example.qmltypes");
|
|
|
|
|
SourceId qmltypes2SourceId = sourcePathCache.sourceId("/path/two/example2.qmltypes");
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(patchWatcherMock,
|
|
|
|
|
updateIdPaths(Contains(IdPaths{projectPartId,
|
|
|
|
|
QmlDesigner::SourceType::QmlTypes,
|
|
|
|
|
{qmltypes1SourceId, qmltypes2SourceId}})));
|
|
|
|
|
|
|
|
|
|
updater.update(directories2, {}, projectPartId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, UpdatePathWatcherBuiltinQmltypesFiles)
|
|
|
|
|
{
|
|
|
|
|
QString builtinQmltyplesPath1{"/path/one/example.qmltypes"};
|
|
|
|
|
QString builtinQmltyplesPath2{"/path/two/example2.qmltypes"};
|
2023-03-09 15:06:22 +01:00
|
|
|
setContent(builtinQmltyplesPath1, qmltypes1);
|
|
|
|
|
setContent(builtinQmltyplesPath2, qmltypes2);
|
2023-02-28 15:12:07 +01:00
|
|
|
SourceId qmltypes1SourceId = sourcePathCache.sourceId("/path/one/example.qmltypes");
|
|
|
|
|
SourceId qmltypes2SourceId = sourcePathCache.sourceId("/path/two/example2.qmltypes");
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(patchWatcherMock,
|
|
|
|
|
updateIdPaths(Contains(IdPaths{projectPartId,
|
|
|
|
|
QmlDesigner::SourceType::QmlTypes,
|
|
|
|
|
{qmltypes1SourceId, qmltypes2SourceId}})));
|
|
|
|
|
|
|
|
|
|
updater.update({}, {builtinQmltyplesPath1, builtinQmltyplesPath2}, projectPartId);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-06 18:03:57 +01:00
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmlDocumentsWithoutQmldir)
|
|
|
|
|
{
|
2023-03-09 15:06:22 +01:00
|
|
|
setFilesDontExists({qmlDirPathSourceId});
|
|
|
|
|
setFilesChanged({directoryPathSourceId});
|
2023-03-06 18:03:57 +01:00
|
|
|
|
|
|
|
|
EXPECT_CALL(
|
|
|
|
|
projectStorageMock,
|
|
|
|
|
synchronize(AllOf(
|
|
|
|
|
Field(&SynchronizationPackage::imports, UnorderedElementsAre(import1, import2, import3)),
|
|
|
|
|
Field(&SynchronizationPackage::types,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
AllOf(IsStorageType("First.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{"Object"},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Full),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType(pathModuleId, "First", -1, -1)))),
|
|
|
|
|
AllOf(IsStorageType("First2.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{"Object2"},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Full),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType(pathModuleId, "First2", -1, -1)))),
|
|
|
|
|
AllOf(IsStorageType("Second.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{"Object3"},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId3,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Full),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType(pathModuleId, "Second", -1, -1)))))),
|
|
|
|
|
Field(&SynchronizationPackage::updatedSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmlDirPathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
qmlDocumentSourceId3)),
|
|
|
|
|
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
|
|
|
|
UnorderedElementsAre(directoryPathSourceId,
|
|
|
|
|
qmlDirPathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
qmlDocumentSourceId3)),
|
|
|
|
|
Field(&SynchronizationPackage::fileStatuses,
|
2023-03-09 15:06:22 +01:00
|
|
|
UnorderedElementsAre(IsFileStatus(directoryPathSourceId, 1, 21),
|
|
|
|
|
IsFileStatus(qmlDocumentSourceId1, 1, 21),
|
|
|
|
|
IsFileStatus(qmlDocumentSourceId2, 1, 21),
|
|
|
|
|
IsFileStatus(qmlDocumentSourceId3, 1, 21))),
|
2023-03-06 18:03:57 +01:00
|
|
|
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
|
|
|
|
UnorderedElementsAre(directoryPathSourceId)),
|
|
|
|
|
Field(&SynchronizationPackage::projectDatas,
|
|
|
|
|
UnorderedElementsAre(IsProjectData(directoryPathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument),
|
|
|
|
|
IsProjectData(directoryPathSourceId,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument),
|
|
|
|
|
IsProjectData(directoryPathSourceId,
|
|
|
|
|
qmlDocumentSourceId3,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument))))));
|
|
|
|
|
|
|
|
|
|
updater.update(directories, {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmlDocumentsWithoutQmldirThrowsIfQmlDocumentDoesNotExists)
|
|
|
|
|
{
|
2023-03-09 15:06:22 +01:00
|
|
|
setFilesDontExists({qmlDirPathSourceId, qmlDocumentSourceId1});
|
|
|
|
|
setFilesAdded({directoryPathSourceId});
|
2023-03-06 18:03:57 +01:00
|
|
|
|
|
|
|
|
ASSERT_THROW(updater.update(directories, {}), QmlDesigner::CannotParseQmlDocumentFile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmlDocumentsWithoutQmldirThrowsIfDirectoryDoesNotExists)
|
|
|
|
|
{
|
2023-03-09 15:06:22 +01:00
|
|
|
setFilesDontExists({qmlDirPathSourceId, directoryPathSourceId});
|
|
|
|
|
setProjectDatas(directoryPathSourceId,
|
|
|
|
|
{{directoryPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument},
|
|
|
|
|
{directoryPathSourceId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument},
|
|
|
|
|
{directoryPathSourceId, qmlDocumentSourceId3, ModuleId{}, FileType::QmlDocument}});
|
2023-03-06 18:03:57 +01:00
|
|
|
|
|
|
|
|
EXPECT_CALL(projectStorageMock,
|
|
|
|
|
synchronize(AllOf(Field(&SynchronizationPackage::imports, IsEmpty()),
|
|
|
|
|
Field(&SynchronizationPackage::types, IsEmpty()),
|
|
|
|
|
Field(&SynchronizationPackage::updatedSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmlDirPathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
qmlDocumentSourceId3)),
|
|
|
|
|
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
|
|
|
|
UnorderedElementsAre(directoryPathSourceId,
|
|
|
|
|
qmlDirPathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
qmlDocumentSourceId3)),
|
|
|
|
|
Field(&SynchronizationPackage::fileStatuses, IsEmpty()),
|
|
|
|
|
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
|
|
|
|
UnorderedElementsAre(directoryPathSourceId)),
|
|
|
|
|
Field(&SynchronizationPackage::projectDatas, IsEmpty()))));
|
|
|
|
|
|
|
|
|
|
updater.update(directories, {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmlDocumentsWithoutQmldirAddQmlDocument)
|
|
|
|
|
{
|
|
|
|
|
setFilesDontExists({qmlDirPathSourceId});
|
|
|
|
|
setFilesChanged({directoryPathSourceId});
|
|
|
|
|
setFilesAdded({qmlDocumentSourceId3});
|
|
|
|
|
setFilesDontChanged({qmlDocumentSourceId1, qmlDocumentSourceId2});
|
|
|
|
|
setProjectDatas(directoryPathSourceId,
|
|
|
|
|
{{directoryPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument},
|
|
|
|
|
{directoryPathSourceId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument}});
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(
|
|
|
|
|
projectStorageMock,
|
|
|
|
|
synchronize(AllOf(
|
|
|
|
|
Field(&SynchronizationPackage::imports, UnorderedElementsAre(import3)),
|
|
|
|
|
Field(&SynchronizationPackage::types,
|
|
|
|
|
UnorderedElementsAre(AllOf(
|
|
|
|
|
IsStorageType("Second.qml",
|
|
|
|
|
Storage::Synchronization::ImportedType{"Object3"},
|
|
|
|
|
TypeTraits::Reference,
|
|
|
|
|
qmlDocumentSourceId3,
|
|
|
|
|
Storage::Synchronization::ChangeLevel::Full),
|
|
|
|
|
Field(&Storage::Synchronization::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType(pathModuleId, "Second", -1, -1)))))),
|
|
|
|
|
Field(&SynchronizationPackage::updatedSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId3)),
|
|
|
|
|
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
|
|
|
|
UnorderedElementsAre(directoryPathSourceId, qmlDirPathSourceId, qmlDocumentSourceId3)),
|
|
|
|
|
Field(&SynchronizationPackage::fileStatuses,
|
|
|
|
|
UnorderedElementsAre(IsFileStatus(directoryPathSourceId, 1, 21),
|
|
|
|
|
IsFileStatus(qmlDocumentSourceId3, 1, 21))),
|
|
|
|
|
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
|
|
|
|
UnorderedElementsAre(directoryPathSourceId)),
|
|
|
|
|
Field(&SynchronizationPackage::projectDatas,
|
|
|
|
|
UnorderedElementsAre(IsProjectData(directoryPathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument),
|
|
|
|
|
IsProjectData(directoryPathSourceId,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument),
|
|
|
|
|
IsProjectData(directoryPathSourceId,
|
|
|
|
|
qmlDocumentSourceId3,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument))))));
|
|
|
|
|
|
|
|
|
|
updater.update(directories, {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorageUpdater, SynchronizeQmlDocumentsWithoutQmldirRemovesQmlDocument)
|
|
|
|
|
{
|
|
|
|
|
setFilesDontExists({qmlDirPathSourceId});
|
|
|
|
|
setFilesChanged({directoryPathSourceId});
|
|
|
|
|
setFilesRemoved({qmlDocumentSourceId3});
|
|
|
|
|
setFilesDontChanged({qmlDocumentSourceId1, qmlDocumentSourceId2});
|
|
|
|
|
setQmlFileNames(u"/path", {"First.qml", "First2.qml"});
|
|
|
|
|
setProjectDatas(directoryPathSourceId,
|
|
|
|
|
{{directoryPathSourceId, qmlDocumentSourceId1, ModuleId{}, FileType::QmlDocument},
|
|
|
|
|
{directoryPathSourceId, qmlDocumentSourceId2, ModuleId{}, FileType::QmlDocument},
|
|
|
|
|
{directoryPathSourceId, qmlDocumentSourceId3, ModuleId{}, FileType::QmlDocument}});
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(projectStorageMock,
|
|
|
|
|
synchronize(
|
|
|
|
|
AllOf(Field(&SynchronizationPackage::imports, IsEmpty()),
|
|
|
|
|
Field(&SynchronizationPackage::types, IsEmpty()),
|
|
|
|
|
Field(&SynchronizationPackage::updatedSourceIds,
|
|
|
|
|
UnorderedElementsAre(qmlDirPathSourceId, qmlDocumentSourceId3)),
|
|
|
|
|
Field(&SynchronizationPackage::updatedFileStatusSourceIds,
|
|
|
|
|
UnorderedElementsAre(directoryPathSourceId,
|
|
|
|
|
qmlDirPathSourceId,
|
|
|
|
|
qmlDocumentSourceId3)),
|
|
|
|
|
Field(&SynchronizationPackage::fileStatuses,
|
|
|
|
|
UnorderedElementsAre(IsFileStatus(directoryPathSourceId, 1, 21))),
|
|
|
|
|
Field(&SynchronizationPackage::updatedProjectSourceIds,
|
|
|
|
|
UnorderedElementsAre(directoryPathSourceId)),
|
|
|
|
|
Field(&SynchronizationPackage::projectDatas,
|
|
|
|
|
UnorderedElementsAre(IsProjectData(directoryPathSourceId,
|
|
|
|
|
qmlDocumentSourceId1,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument),
|
|
|
|
|
IsProjectData(directoryPathSourceId,
|
|
|
|
|
qmlDocumentSourceId2,
|
|
|
|
|
ModuleId{},
|
|
|
|
|
FileType::QmlDocument))))));
|
|
|
|
|
|
|
|
|
|
updater.update(directories, {});
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
} // namespace
|