diff options
author | Marco Bubke <marco.bubke@qt.io> | 2021-09-23 11:22:04 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2021-09-27 13:00:21 +0000 |
commit | 03687c1d0288544b12db64bc7d828d899986075c (patch) | |
tree | 2664bf62c3244e5d7d3b9fb5b4951795b952dfac /tests | |
parent | b2a300dd60873198efffa526622e85091f4fc281 (diff) |
QmlDesigner: Add minimal updates
Exported type names are synchronized so that old type names are removed.
Task-number: QDS-5130
Task-number: QDS-5126
Change-Id: I6e6482170c8197f37f60a57bdfb7f1b450001b4b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/unittest/projectstorage-test.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/unit/unittest/projectstorage-test.cpp b/tests/unit/unittest/projectstorage-test.cpp index dd570f4c4b..a30d44889d 100644 --- a/tests/unit/unittest/projectstorage-test.cpp +++ b/tests/unit/unittest/projectstorage-test.cpp @@ -122,6 +122,19 @@ MATCHER_P(IsExportedType, return type.name == name; } +MATCHER_P3(IsExportedType, + name, + majorVersion, + minorVersion, + std::string(negation ? "isn't " : "is ") + + PrintToString(Storage::ExportedType{name, + Storage::Version{majorVersion, minorVersion}})) +{ + const Storage::ExportedType &type = arg; + + return type.name == name && type.version == Storage::Version{majorVersion, minorVersion}; +} + MATCHER_P3(IsPropertyDeclaration, name, typeName, @@ -417,6 +430,7 @@ protected: protected: Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory}; + //Sqlite::Database database{TESTDATA_DIR "/aaaa.db", Sqlite::JournalMode::Wal}; QmlDesigner::ProjectStorage<Sqlite::Database> storage{database, database.isInitialized()}; QmlDesigner::SourcePathCache<QmlDesigner::ProjectStorage<Sqlite::Database>> sourcePathCache{ storage}; @@ -4497,4 +4511,44 @@ TEST_F(ProjectStorage, EnsureThatPrototypesForRemovedTypesAreNotAnymoreRelinked) ASSERT_NO_THROW(storage.synchronize({}, {}, {}, {sourceId1, sourceId2}, {})); } +TEST_F(ProjectStorage, MinimalUpdates) +{ + auto types = createTypes(); + storage.synchronize(modules, + imports, + types, + {sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3}, + {}); + Storage::Type quickType{Storage::Module{"QtQuick"}, + "QQuickItem", + {}, + TypeAccessSemantics::Reference, + sourceId1, + {Storage::ExportedType{"Item", Storage::Version{2, 0}}}, + {}, + {}, + {}, + {}, + Storage::ChangeLevel::Minimal}; + + storage.synchronize({modules[1]}, {}, {quickType}, {moduleSourceId2}, {}); + + ASSERT_THAT(storage.fetchTypes(), + UnorderedElementsAre(AllOf(IsStorageType(Storage::Module{"Qml"}, + "QObject", + Storage::NativeType{}, + TypeAccessSemantics::Reference, + sourceId2), + Field(&Storage::Type::exportedTypes, + UnorderedElementsAre(IsExportedType("Object"), + IsExportedType("Obj")))), + AllOf(IsStorageType(Storage::Module{"QtQuick"}, + "QQuickItem", + Storage::NativeType{"QObject"}, + TypeAccessSemantics::Reference, + sourceId1), + Field(&Storage::Type::exportedTypes, + UnorderedElementsAre(IsExportedType("Item", 2, 0)))))); +} + } // namespace |