2021-04-28 16:18:59 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2021 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "googletest.h"
|
|
|
|
|
|
|
|
|
|
#include "sqlitedatabasemock.h"
|
|
|
|
|
|
|
|
|
|
#include <modelnode.h>
|
2021-05-04 13:27:42 +02:00
|
|
|
#include <projectstorage/projectstorage.h>
|
2021-05-06 15:52:20 +02:00
|
|
|
#include <projectstorage/sourcepathcache.h>
|
2021-04-28 16:18:59 +02:00
|
|
|
#include <sqlitedatabase.h>
|
|
|
|
|
#include <sqlitereadstatement.h>
|
|
|
|
|
#include <sqlitewritestatement.h>
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
2021-08-03 15:03:36 +02:00
|
|
|
using QmlDesigner::FileStatus;
|
|
|
|
|
using QmlDesigner::FileStatuses;
|
2021-08-24 11:53:15 +02:00
|
|
|
using QmlDesigner::ModuleId;
|
2021-04-28 16:18:59 +02:00
|
|
|
using QmlDesigner::PropertyDeclarationId;
|
|
|
|
|
using QmlDesigner::SourceContextId;
|
|
|
|
|
using QmlDesigner::SourceId;
|
2021-08-24 16:49:42 +02:00
|
|
|
using QmlDesigner::SourceIds;
|
2021-04-28 16:18:59 +02:00
|
|
|
using QmlDesigner::TypeId;
|
2021-05-06 12:26:39 +02:00
|
|
|
using QmlDesigner::Cache::Source;
|
|
|
|
|
using QmlDesigner::Cache::SourceContext;
|
2021-05-06 15:52:20 +02:00
|
|
|
using QmlDesigner::Storage::TypeAccessSemantics;
|
|
|
|
|
|
|
|
|
|
namespace Storage = QmlDesigner::Storage;
|
2021-04-28 16:18:59 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::Imports operator+(const Storage::Imports &first, const Storage::Imports &second)
|
|
|
|
|
{
|
|
|
|
|
Storage::Imports imports;
|
|
|
|
|
imports.reserve(first.size() + second.size());
|
|
|
|
|
|
|
|
|
|
imports.insert(imports.end(), first.begin(), first.end());
|
|
|
|
|
imports.insert(imports.end(), second.begin(), second.end());
|
|
|
|
|
|
|
|
|
|
return imports;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-28 16:18:59 +02:00
|
|
|
MATCHER_P2(IsSourceContext,
|
|
|
|
|
id,
|
|
|
|
|
value,
|
|
|
|
|
std::string(negation ? "isn't " : "is ") + PrintToString(SourceContext{value, id}))
|
|
|
|
|
{
|
|
|
|
|
const SourceContext &sourceContext = arg;
|
|
|
|
|
|
|
|
|
|
return sourceContext.id == id && sourceContext.value == value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MATCHER_P2(IsSourceNameAndSourceContextId,
|
|
|
|
|
name,
|
|
|
|
|
id,
|
|
|
|
|
std::string(negation ? "isn't " : "is ")
|
2021-05-06 12:26:39 +02:00
|
|
|
+ PrintToString(QmlDesigner::Cache::SourceNameAndSourceContextId{name, id}))
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
2021-05-06 12:26:39 +02:00
|
|
|
const QmlDesigner::Cache::SourceNameAndSourceContextId &sourceNameAndSourceContextId = arg;
|
2021-04-28 16:18:59 +02:00
|
|
|
|
|
|
|
|
return sourceNameAndSourceContextId.sourceName == name
|
|
|
|
|
&& sourceNameAndSourceContextId.sourceContextId == id;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-03 13:06:23 +02:00
|
|
|
MATCHER_P5(IsStorageType,
|
2021-08-24 11:53:15 +02:00
|
|
|
module,
|
2021-05-06 15:52:20 +02:00
|
|
|
typeName,
|
|
|
|
|
prototype,
|
|
|
|
|
accessSemantics,
|
|
|
|
|
sourceId,
|
|
|
|
|
std::string(negation ? "isn't " : "is ")
|
2021-08-24 11:53:15 +02:00
|
|
|
+ PrintToString(Storage::Type{module, typeName, prototype, accessSemantics, sourceId}))
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
const Storage::Type &type = arg;
|
|
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
return type.module == module && type.typeName == typeName
|
2021-06-07 16:16:24 +02:00
|
|
|
&& type.accessSemantics == accessSemantics && type.sourceId == sourceId
|
2021-08-24 16:49:42 +02:00
|
|
|
&& Storage::ImportedTypeName{prototype} == type.prototype;
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-06-03 13:06:23 +02:00
|
|
|
MATCHER_P4(IsStorageTypeWithInvalidSourceId,
|
2021-08-24 11:53:15 +02:00
|
|
|
module,
|
2021-05-31 18:13:42 +02:00
|
|
|
typeName,
|
|
|
|
|
prototype,
|
|
|
|
|
accessSemantics,
|
|
|
|
|
std::string(negation ? "isn't " : "is ")
|
2021-08-24 11:53:15 +02:00
|
|
|
+ PrintToString(Storage::Type{module, typeName, prototype, accessSemantics, SourceId{}}))
|
2021-05-31 18:13:42 +02:00
|
|
|
{
|
|
|
|
|
const Storage::Type &type = arg;
|
|
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
return type.module == module && type.typeName == typeName && type.prototype == prototype
|
2021-05-31 18:13:42 +02:00
|
|
|
&& type.accessSemantics == accessSemantics && !type.sourceId.isValid();
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-07 10:51:25 +02:00
|
|
|
MATCHER_P(IsExportedType,
|
2021-06-07 16:16:24 +02:00
|
|
|
name,
|
|
|
|
|
std::string(negation ? "isn't " : "is ") + PrintToString(Storage::ExportedType{name}))
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
const Storage::ExportedType &type = arg;
|
|
|
|
|
|
2021-06-07 16:16:24 +02:00
|
|
|
return type.name == name;
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MATCHER_P3(IsPropertyDeclaration,
|
|
|
|
|
name,
|
|
|
|
|
typeName,
|
|
|
|
|
traits,
|
|
|
|
|
std::string(negation ? "isn't " : "is ")
|
|
|
|
|
+ PrintToString(Storage::PropertyDeclaration{name, typeName, traits}))
|
|
|
|
|
{
|
|
|
|
|
const Storage::PropertyDeclaration &propertyDeclaration = arg;
|
|
|
|
|
|
2021-06-07 16:16:24 +02:00
|
|
|
return propertyDeclaration.name == name
|
2021-08-24 16:49:42 +02:00
|
|
|
&& Storage::ImportedTypeName{typeName} == propertyDeclaration.typeName
|
2021-05-06 15:52:20 +02:00
|
|
|
&& propertyDeclaration.traits == traits;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-07 16:38:08 +02:00
|
|
|
MATCHER_P4(IsPropertyDeclaration,
|
|
|
|
|
name,
|
|
|
|
|
typeName,
|
|
|
|
|
traits,
|
|
|
|
|
aliasPropertyName,
|
|
|
|
|
std::string(negation ? "isn't " : "is ")
|
|
|
|
|
+ PrintToString(Storage::PropertyDeclaration(name, typeName, traits, aliasPropertyName)))
|
|
|
|
|
{
|
|
|
|
|
const Storage::PropertyDeclaration &propertyDeclaration = arg;
|
|
|
|
|
|
|
|
|
|
return propertyDeclaration.name == name
|
|
|
|
|
&& Utils::visit([&](auto &&v) -> bool { return v.name == typeName.name; },
|
|
|
|
|
propertyDeclaration.typeName)
|
|
|
|
|
&& propertyDeclaration.aliasPropertyName == aliasPropertyName
|
|
|
|
|
&& propertyDeclaration.traits == traits;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
MATCHER_P(IsModule,
|
|
|
|
|
name,
|
|
|
|
|
std::string(negation ? "isn't " : "is ") + PrintToString(Storage::Module{name}))
|
2021-06-01 17:46:49 +02:00
|
|
|
{
|
2021-08-24 11:53:15 +02:00
|
|
|
const Storage::Module &module = arg;
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
return module.name == name;
|
2021-06-01 17:46:49 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
MATCHER_P2(IsModule,
|
2021-06-01 17:46:49 +02:00
|
|
|
name,
|
|
|
|
|
sourceId,
|
2021-08-24 16:49:42 +02:00
|
|
|
std::string(negation ? "isn't " : "is ") + PrintToString(Storage::Module{name, sourceId}))
|
2021-06-01 17:46:49 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
const Storage::Module &module = arg;
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
return module.name == name;
|
2021-06-01 17:46:49 +02:00
|
|
|
}
|
|
|
|
|
|
2021-04-28 16:18:59 +02:00
|
|
|
class ProjectStorage : public testing::Test
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
template<typename Range>
|
|
|
|
|
static auto toValues(Range &&range)
|
|
|
|
|
{
|
|
|
|
|
using Type = typename std::decay_t<Range>;
|
|
|
|
|
|
|
|
|
|
return std::vector<typename Type::value_type>{range.begin(), range.end()};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void addSomeDummyData()
|
|
|
|
|
{
|
|
|
|
|
auto sourceContextId1 = storage.fetchSourceContextId("/path/dummy");
|
|
|
|
|
auto sourceContextId2 = storage.fetchSourceContextId("/path/dummy2");
|
|
|
|
|
auto sourceContextId3 = storage.fetchSourceContextId("/path/");
|
|
|
|
|
|
|
|
|
|
storage.fetchSourceId(sourceContextId1, "foo");
|
|
|
|
|
storage.fetchSourceId(sourceContextId1, "dummy");
|
|
|
|
|
storage.fetchSourceId(sourceContextId2, "foo");
|
|
|
|
|
storage.fetchSourceId(sourceContextId2, "bar");
|
|
|
|
|
storage.fetchSourceId(sourceContextId3, "foo");
|
|
|
|
|
storage.fetchSourceId(sourceContextId3, "bar");
|
|
|
|
|
storage.fetchSourceId(sourceContextId1, "bar");
|
|
|
|
|
storage.fetchSourceId(sourceContextId3, "bar");
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-06 15:52:20 +02:00
|
|
|
auto createTypes()
|
|
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
imports.emplace_back("Qml", Storage::Version{}, sourceId1);
|
|
|
|
|
imports.emplace_back("Qml", Storage::Version{}, sourceId2);
|
|
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId1);
|
|
|
|
|
|
|
|
|
|
importsSourceId1.emplace_back("Qml", Storage::Version{}, sourceId1);
|
|
|
|
|
importsSourceId1.emplace_back("QtQuick", Storage::Version{}, sourceId1);
|
|
|
|
|
|
|
|
|
|
importsSourceId2.emplace_back("Qml", Storage::Version{}, sourceId2);
|
2021-06-15 12:32:55 +02:00
|
|
|
|
2021-05-06 15:52:20 +02:00
|
|
|
return Storage::Types{
|
|
|
|
|
Storage::Type{
|
2021-08-24 11:53:15 +02:00
|
|
|
Storage::Module{"QtQuick"},
|
2021-05-06 15:52:20 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-05-06 15:52:20 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1,
|
2021-06-07 10:51:25 +02:00
|
|
|
{Storage::ExportedType{"Item"}},
|
2021-06-07 16:16:24 +02:00
|
|
|
{Storage::PropertyDeclaration{"data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-09 17:56:34 +02:00
|
|
|
Storage::PropertyDeclarationTraits::IsList},
|
2021-05-06 15:52:20 +02:00
|
|
|
Storage::PropertyDeclaration{"children",
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::ImportedType{"Item"},
|
2021-06-09 17:56:34 +02:00
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly}},
|
2021-05-06 15:52:20 +02:00
|
|
|
{Storage::FunctionDeclaration{"execute", "", {Storage::ParameterDeclaration{"arg", ""}}},
|
|
|
|
|
Storage::FunctionDeclaration{
|
|
|
|
|
"values",
|
|
|
|
|
"Vector3D",
|
|
|
|
|
{Storage::ParameterDeclaration{"arg1", "int"},
|
2021-06-09 17:56:34 +02:00
|
|
|
Storage::ParameterDeclaration{"arg2",
|
|
|
|
|
"QObject",
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsPointer},
|
2021-05-06 15:52:20 +02:00
|
|
|
Storage::ParameterDeclaration{"arg3", "string"}}}},
|
|
|
|
|
{Storage::SignalDeclaration{"execute", {Storage::ParameterDeclaration{"arg", ""}}},
|
2021-06-09 17:56:34 +02:00
|
|
|
Storage::SignalDeclaration{
|
2021-08-24 16:49:42 +02:00
|
|
|
"value0s",
|
2021-06-09 17:56:34 +02:00
|
|
|
{Storage::ParameterDeclaration{"arg1", "int"},
|
|
|
|
|
Storage::ParameterDeclaration{"arg2",
|
|
|
|
|
"QObject",
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsPointer},
|
|
|
|
|
Storage::ParameterDeclaration{"arg3", "string"}}}},
|
2021-05-06 15:52:20 +02:00
|
|
|
{Storage::EnumerationDeclaration{"Enum",
|
|
|
|
|
{Storage::EnumeratorDeclaration{"Foo"},
|
|
|
|
|
Storage::EnumeratorDeclaration{"Bar", 32}}},
|
|
|
|
|
Storage::EnumerationDeclaration{"Type",
|
|
|
|
|
{Storage::EnumeratorDeclaration{"Foo"},
|
|
|
|
|
Storage::EnumeratorDeclaration{"Poo", 12}}}}},
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::Type{Storage::Module{"Qml"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QObject",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{},
|
2021-05-06 15:52:20 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
2021-08-24 16:49:42 +02:00
|
|
|
{Storage::ExportedType{"Object", Storage::Version{2}},
|
|
|
|
|
Storage::ExportedType{"Obj", Storage::Version{2}}}}};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto createVersionedTypes()
|
|
|
|
|
{
|
|
|
|
|
return Storage::Types{Storage::Type{Storage::Module{"Qml"},
|
|
|
|
|
"QObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1,
|
|
|
|
|
{Storage::ExportedType{"Object", Storage::Version{1}},
|
|
|
|
|
Storage::ExportedType{"Obj", Storage::Version{1, 2}},
|
|
|
|
|
Storage::ExportedType{"BuiltInObj", Storage::Version{}}}},
|
|
|
|
|
Storage::Type{Storage::Module{"Qml"},
|
|
|
|
|
"QObject2",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1,
|
|
|
|
|
{Storage::ExportedType{"Object", Storage::Version{2, 0}},
|
|
|
|
|
Storage::ExportedType{"Obj", Storage::Version{2, 3}}}},
|
|
|
|
|
Storage::Type{Storage::Module{"Qml"},
|
|
|
|
|
"QObject3",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1,
|
|
|
|
|
{Storage::ExportedType{"Object", Storage::Version{2, 11}},
|
|
|
|
|
Storage::ExportedType{"Obj", Storage::Version{2, 11}}}},
|
|
|
|
|
Storage::Type{Storage::Module{"Qml"},
|
|
|
|
|
"QObject4",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1,
|
|
|
|
|
{Storage::ExportedType{"Object", Storage::Version{3, 4}},
|
|
|
|
|
Storage::ExportedType{"Obj", Storage::Version{3, 4}},
|
|
|
|
|
Storage::ExportedType{"BuiltInObj",
|
|
|
|
|
Storage::Version{3, 4}}}}};
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-07-07 16:38:08 +02:00
|
|
|
auto createTypesWithExportedTypeNamesOnly()
|
|
|
|
|
{
|
|
|
|
|
auto types = createTypes();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].prototype = Storage::ImportedType{"Object"};
|
|
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::ImportedType{"Object"};
|
2021-07-07 16:38:08 +02:00
|
|
|
|
|
|
|
|
return types;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-09 17:56:34 +02:00
|
|
|
auto createTypesWithAliases()
|
|
|
|
|
{
|
|
|
|
|
auto types = createTypes();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
imports.emplace_back("Qml", Storage::Version{}, sourceId3);
|
|
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId3);
|
|
|
|
|
|
|
|
|
|
imports.emplace_back("Qml", Storage::Version{}, sourceId4);
|
|
|
|
|
imports.emplace_back("/path/to", Storage::Version{}, sourceId4);
|
|
|
|
|
|
|
|
|
|
importsSourceId3.emplace_back("Qml", Storage::Version{}, sourceId3);
|
|
|
|
|
importsSourceId3.emplace_back("QtQuick", Storage::Version{}, sourceId3);
|
|
|
|
|
|
|
|
|
|
importsSourceId4.emplace_back("Qml", Storage::Version{}, sourceId4);
|
|
|
|
|
importsSourceId4.emplace_back("/path/to", Storage::Version{}, sourceId4);
|
|
|
|
|
|
2021-06-09 17:56:34 +02:00
|
|
|
types[1].propertyDeclarations.push_back(
|
|
|
|
|
Storage::PropertyDeclaration{"objects",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList});
|
|
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
types.push_back(Storage::Type{Storage::Module{"QtQuick"},
|
2021-06-09 17:56:34 +02:00
|
|
|
"QAliasItem",
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::ImportedType{"Item"},
|
2021-06-09 17:56:34 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
2021-06-10 16:39:29 +02:00
|
|
|
sourceId3,
|
2021-06-09 17:56:34 +02:00
|
|
|
{Storage::ExportedType{"AliasItem"}}});
|
|
|
|
|
types.back().propertyDeclarations.push_back(
|
|
|
|
|
Storage::PropertyDeclaration{"data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList});
|
2021-07-07 16:38:08 +02:00
|
|
|
types.back().propertyDeclarations.push_back(
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::PropertyDeclaration{"items", Storage::ImportedType{"Item"}, "children"});
|
2021-07-07 16:38:08 +02:00
|
|
|
types.back().propertyDeclarations.push_back(
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::PropertyDeclaration{"objects", Storage::ImportedType{"Item"}, "objects"});
|
2021-07-01 10:42:38 +02:00
|
|
|
|
|
|
|
|
types.push_back(
|
2021-08-24 11:53:15 +02:00
|
|
|
Storage::Type{Storage::Module{"/path/to"},
|
2021-07-01 10:42:38 +02:00
|
|
|
"QObject2",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId4,
|
|
|
|
|
{Storage::ExportedType{"Object2"}, Storage::ExportedType{"Obj2"}}});
|
|
|
|
|
types[3].propertyDeclarations.push_back(
|
|
|
|
|
Storage::PropertyDeclaration{"objects",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList});
|
|
|
|
|
|
|
|
|
|
return types;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-07 16:38:08 +02:00
|
|
|
auto createTypesWithRecursiveAliases()
|
2021-07-01 10:42:38 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
imports.emplace_back("Qml", Storage::Version{}, sourceId5);
|
|
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId5);
|
|
|
|
|
|
2021-07-07 16:38:08 +02:00
|
|
|
auto types = createTypesWithAliases();
|
2021-08-24 11:53:15 +02:00
|
|
|
types.push_back(Storage::Type{Storage::Module{"QtQuick"},
|
2021-07-07 16:38:08 +02:00
|
|
|
"QAliasItem2",
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::ImportedType{"Object"},
|
2021-07-01 10:42:38 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
2021-07-07 16:38:08 +02:00
|
|
|
sourceId5,
|
|
|
|
|
{Storage::ExportedType{"AliasItem2"}}});
|
|
|
|
|
|
2021-07-01 10:42:38 +02:00
|
|
|
types.back().propertyDeclarations.push_back(
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::PropertyDeclaration{"objects", Storage::ImportedType{"AliasItem"}, "objects"});
|
2021-06-09 17:56:34 +02:00
|
|
|
|
2021-07-07 16:38:08 +02:00
|
|
|
return types;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto createTypesWithAliases2()
|
|
|
|
|
{
|
|
|
|
|
auto types = createTypesWithAliases();
|
|
|
|
|
types[2].prototype = Storage::NativeType{"QObject"};
|
|
|
|
|
types[2].propertyDeclarations.erase(std::next(types[2].propertyDeclarations.begin()));
|
2021-06-10 16:39:29 +02:00
|
|
|
|
2021-06-09 17:56:34 +02:00
|
|
|
return types;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
Storage::Modules createModules()
|
2021-07-15 13:46:17 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
return Storage::Modules{Storage::Module{"Qml", moduleSourceId1},
|
|
|
|
|
Storage::Module{"QtQuick", moduleSourceId2},
|
|
|
|
|
Storage::Module{"/path/to", moduleSourceId3}};
|
2021-06-01 17:46:49 +02:00
|
|
|
}
|
2021-07-15 13:46:17 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::Imports createImports(SourceId sourceId)
|
2021-07-07 16:38:08 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
return Storage::Imports{Storage::Import{"Qml", Storage::Version{2}, sourceId},
|
|
|
|
|
Storage::Import{"QtQuick", Storage::Version{}, sourceId},
|
|
|
|
|
Storage::Import{"/path/to", Storage::Version{}, sourceId}};
|
2021-07-07 16:38:08 +02:00
|
|
|
}
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
static Storage::Imports createImports(const SourceIds &sourceIds)
|
2021-06-03 13:06:23 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::Imports imports;
|
|
|
|
|
imports.reserve(3 * sourceIds.size());
|
2021-08-03 15:03:36 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
for (SourceId sourceId : sourceIds) {
|
|
|
|
|
imports.emplace_back("Qml", Storage::Version{2}, sourceId);
|
|
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId);
|
|
|
|
|
imports.emplace_back("/path/to", Storage::Version{}, sourceId);
|
|
|
|
|
}
|
2021-07-07 16:38:08 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
return imports;
|
|
|
|
|
}
|
2021-07-15 13:46:17 +02:00
|
|
|
|
2021-08-03 15:03:36 +02:00
|
|
|
template<typename Range>
|
|
|
|
|
static FileStatuses convert(const Range &range)
|
|
|
|
|
{
|
|
|
|
|
return FileStatuses(range.begin(), range.end());
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-28 16:18:59 +02:00
|
|
|
protected:
|
|
|
|
|
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
|
2021-09-16 17:19:56 +02:00
|
|
|
QmlDesigner::ProjectStorage<Sqlite::Database> storage{database, database.isInitialized()};
|
|
|
|
|
QmlDesigner::SourcePathCache<QmlDesigner::ProjectStorage<Sqlite::Database>> sourcePathCache{
|
|
|
|
|
storage};
|
2021-05-06 15:52:20 +02:00
|
|
|
QmlDesigner::SourcePathView path1{"/path1/to"};
|
|
|
|
|
QmlDesigner::SourcePathView path2{"/path2/to"};
|
|
|
|
|
QmlDesigner::SourcePathView path3{"/path3/to"};
|
|
|
|
|
QmlDesigner::SourcePathView path4{"/path4/to"};
|
2021-07-07 16:38:08 +02:00
|
|
|
QmlDesigner::SourcePathView path5{"/path5/to"};
|
2021-08-24 11:53:15 +02:00
|
|
|
QmlDesigner::SourcePathView modulePath1{"/module/path1/to"};
|
|
|
|
|
QmlDesigner::SourcePathView modulePath2{"/module/path2/to"};
|
|
|
|
|
QmlDesigner::SourcePathView modulePath3{"/module/aaaa/to"};
|
|
|
|
|
QmlDesigner::SourcePathView modulePath4{"/module/ooo/to"};
|
2021-08-24 16:49:42 +02:00
|
|
|
QmlDesigner::SourcePathView modulePath5{"/module/xxx/to"};
|
|
|
|
|
SourceId sourceId1{sourcePathCache.sourceId(path1)};
|
|
|
|
|
SourceId sourceId2{sourcePathCache.sourceId(path2)};
|
|
|
|
|
SourceId sourceId3{sourcePathCache.sourceId(path3)};
|
|
|
|
|
SourceId sourceId4{sourcePathCache.sourceId(path4)};
|
|
|
|
|
SourceId sourceId5{sourcePathCache.sourceId(path5)};
|
|
|
|
|
SourceIds sourceIds{sourceId1, sourceId2, sourceId3, sourceId4, sourceId5};
|
|
|
|
|
SourceId moduleSourceId1{sourcePathCache.sourceId(modulePath1)};
|
|
|
|
|
SourceId moduleSourceId2{sourcePathCache.sourceId(modulePath2)};
|
|
|
|
|
SourceId moduleSourceId3{sourcePathCache.sourceId(modulePath3)};
|
|
|
|
|
SourceId moduleSourceId4{sourcePathCache.sourceId(modulePath4)};
|
|
|
|
|
SourceId moduleSourceId5{sourcePathCache.sourceId(modulePath5)};
|
|
|
|
|
Storage::Modules modules{createModules()};
|
|
|
|
|
QmlDesigner::ModuleIds moduleIds{storage.fetchModuleIds(modules)};
|
|
|
|
|
ModuleId moduleId1{moduleIds[0]};
|
|
|
|
|
ModuleId moduleId2{moduleIds[1]};
|
|
|
|
|
ModuleId moduleId3{moduleIds[2]};
|
|
|
|
|
Storage::Imports imports;
|
|
|
|
|
Storage::Imports importsSourceId1;
|
|
|
|
|
Storage::Imports importsSourceId2;
|
|
|
|
|
Storage::Imports importsSourceId3;
|
|
|
|
|
Storage::Imports importsSourceId4;
|
2021-04-28 16:18:59 +02:00
|
|
|
};
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchSourceContextIdReturnsAlwaysTheSameIdForTheSamePath)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
auto sourceContextId = storage.fetchSourceContextId("/path/to");
|
|
|
|
|
|
|
|
|
|
auto newSourceContextId = storage.fetchSourceContextId("/path/to");
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(newSourceContextId, Eq(sourceContextId));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchSourceContextIdReturnsNotTheSameIdForDifferentPath)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
auto sourceContextId = storage.fetchSourceContextId("/path/to");
|
|
|
|
|
|
|
|
|
|
auto newSourceContextId = storage.fetchSourceContextId("/path/to2");
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(newSourceContextId, Ne(sourceContextId));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchSourceContextPath)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
auto sourceContextId = storage.fetchSourceContextId("/path/to");
|
|
|
|
|
|
|
|
|
|
auto path = storage.fetchSourceContextPath(sourceContextId);
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(path, Eq("/path/to"));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchUnknownSourceContextPathThrows)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
ASSERT_THROW(storage.fetchSourceContextPath(SourceContextId{323}),
|
|
|
|
|
QmlDesigner::SourceContextIdDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchAllSourceContextsAreEmptyIfNoSourceContextsExists)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.clearSources();
|
|
|
|
|
|
2021-04-28 16:18:59 +02:00
|
|
|
auto sourceContexts = storage.fetchAllSourceContexts();
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(toValues(sourceContexts), IsEmpty());
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchAllSourceContexts)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.clearSources();
|
2021-04-28 16:18:59 +02:00
|
|
|
auto sourceContextId = storage.fetchSourceContextId("/path/to");
|
|
|
|
|
auto sourceContextId2 = storage.fetchSourceContextId("/path/to2");
|
|
|
|
|
|
|
|
|
|
auto sourceContexts = storage.fetchAllSourceContexts();
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(toValues(sourceContexts),
|
|
|
|
|
UnorderedElementsAre(IsSourceContext(sourceContextId, "/path/to"),
|
|
|
|
|
IsSourceContext(sourceContextId2, "/path/to2")));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchSourceIdFirstTime)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
addSomeDummyData();
|
|
|
|
|
auto sourceContextId = storage.fetchSourceContextId("/path/to");
|
|
|
|
|
|
|
|
|
|
auto sourceId = storage.fetchSourceId(sourceContextId, "foo");
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(sourceId.isValid());
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchExistingSourceId)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
addSomeDummyData();
|
|
|
|
|
auto sourceContextId = storage.fetchSourceContextId("/path/to");
|
|
|
|
|
auto createdSourceId = storage.fetchSourceId(sourceContextId, "foo");
|
|
|
|
|
|
|
|
|
|
auto sourceId = storage.fetchSourceId(sourceContextId, "foo");
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(sourceId, createdSourceId);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchSourceIdWithDifferentContextIdAreNotEqual)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
addSomeDummyData();
|
|
|
|
|
auto sourceContextId = storage.fetchSourceContextId("/path/to");
|
|
|
|
|
auto sourceContextId2 = storage.fetchSourceContextId("/path/to2");
|
|
|
|
|
auto sourceId2 = storage.fetchSourceId(sourceContextId2, "foo");
|
|
|
|
|
|
|
|
|
|
auto sourceId = storage.fetchSourceId(sourceContextId, "foo");
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(sourceId, Ne(sourceId2));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchSourceIdWithDifferentNameAreNotEqual)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
addSomeDummyData();
|
|
|
|
|
auto sourceContextId = storage.fetchSourceContextId("/path/to");
|
|
|
|
|
auto sourceId2 = storage.fetchSourceId(sourceContextId, "foo");
|
|
|
|
|
|
|
|
|
|
auto sourceId = storage.fetchSourceId(sourceContextId, "foo2");
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(sourceId, Ne(sourceId2));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchSourceIdWithNonExistingSourceContextIdThrows)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
ASSERT_THROW(storage.fetchSourceId(SourceContextId{42}, "foo"),
|
|
|
|
|
Sqlite::ConstraintPreventsModification);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchSourceNameAndSourceContextIdForNonExistingSourceId)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
ASSERT_THROW(storage.fetchSourceNameAndSourceContextId(SourceId{212}),
|
|
|
|
|
QmlDesigner::SourceIdDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchSourceNameAndSourceContextIdForNonExistingEntry)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
addSomeDummyData();
|
|
|
|
|
auto sourceContextId = storage.fetchSourceContextId("/path/to");
|
|
|
|
|
auto sourceId = storage.fetchSourceId(sourceContextId, "foo");
|
|
|
|
|
|
|
|
|
|
auto sourceNameAndSourceContextId = storage.fetchSourceNameAndSourceContextId(sourceId);
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(sourceNameAndSourceContextId, IsSourceNameAndSourceContextId("foo", sourceContextId));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchSourceContextIdForNonExistingSourceId)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
ASSERT_THROW(storage.fetchSourceContextId(SourceId{212}), QmlDesigner::SourceIdDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchSourceContextIdForExistingSourceId)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
addSomeDummyData();
|
|
|
|
|
auto originalSourceContextId = storage.fetchSourceContextId("/path/to3");
|
|
|
|
|
auto sourceId = storage.fetchSourceId(originalSourceContextId, "foo");
|
|
|
|
|
|
|
|
|
|
auto sourceContextId = storage.fetchSourceContextId(sourceId);
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(sourceContextId, Eq(originalSourceContextId));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchAllSources)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.clearSources();
|
|
|
|
|
|
2021-04-28 16:18:59 +02:00
|
|
|
auto sources = storage.fetchAllSources();
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(toValues(sources), IsEmpty());
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchSourceIdUnguardedFirstTime)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
addSomeDummyData();
|
|
|
|
|
auto sourceContextId = storage.fetchSourceContextId("/path/to");
|
|
|
|
|
std::lock_guard lock{database};
|
|
|
|
|
|
|
|
|
|
auto sourceId = storage.fetchSourceIdUnguarded(sourceContextId, "foo");
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(sourceId.isValid());
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchExistingSourceIdUnguarded)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
addSomeDummyData();
|
|
|
|
|
auto sourceContextId = storage.fetchSourceContextId("/path/to");
|
|
|
|
|
std::lock_guard lock{database};
|
|
|
|
|
auto createdSourceId = storage.fetchSourceIdUnguarded(sourceContextId, "foo");
|
|
|
|
|
|
|
|
|
|
auto sourceId = storage.fetchSourceIdUnguarded(sourceContextId, "foo");
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(sourceId, createdSourceId);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchSourceIdUnguardedWithDifferentContextIdAreNotEqual)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
addSomeDummyData();
|
|
|
|
|
auto sourceContextId = storage.fetchSourceContextId("/path/to");
|
|
|
|
|
auto sourceContextId2 = storage.fetchSourceContextId("/path/to2");
|
|
|
|
|
std::lock_guard lock{database};
|
|
|
|
|
auto sourceId2 = storage.fetchSourceIdUnguarded(sourceContextId2, "foo");
|
|
|
|
|
|
|
|
|
|
auto sourceId = storage.fetchSourceIdUnguarded(sourceContextId, "foo");
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(sourceId, Ne(sourceId2));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchSourceIdUnguardedWithDifferentNameAreNotEqual)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
addSomeDummyData();
|
|
|
|
|
auto sourceContextId = storage.fetchSourceContextId("/path/to");
|
|
|
|
|
std::lock_guard lock{database};
|
|
|
|
|
auto sourceId2 = storage.fetchSourceIdUnguarded(sourceContextId, "foo");
|
|
|
|
|
|
|
|
|
|
auto sourceId = storage.fetchSourceIdUnguarded(sourceContextId, "foo2");
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(sourceId, Ne(sourceId2));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchSourceIdUnguardedWithNonExistingSourceContextIdThrows)
|
2021-04-28 16:18:59 +02:00
|
|
|
{
|
|
|
|
|
std::lock_guard lock{database};
|
|
|
|
|
|
|
|
|
|
ASSERT_THROW(storage.fetchSourceIdUnguarded(SourceContextId{42}, "foo"),
|
|
|
|
|
Sqlite::ConstraintPreventsModification);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddsNewTypes)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-06-07 16:16:24 +02:00
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 16:49:42 +02:00
|
|
|
UnorderedElementsAre(AllOf(IsStorageType(Storage::Module{"Qml"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Object"),
|
|
|
|
|
IsExportedType("Obj")))),
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Item"))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddsNewTypesWithExportedPrototypeName)
|
2021-06-07 16:16:24 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].prototype = Storage::ImportedType{"Object"};
|
2021-06-07 16:16:24 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
importsSourceId1,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-07 16:16:24 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 16:49:42 +02:00
|
|
|
UnorderedElementsAre(AllOf(IsStorageType(Storage::Module{"Qml"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Object"),
|
|
|
|
|
IsExportedType("Obj")))),
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Item"))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddsNewTypesThrowsWithWrongPrototypeName)
|
2021-06-07 16:16:24 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].prototype = Storage::ImportedType{"Objec"};
|
2021-06-07 16:16:24 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{}),
|
2021-06-07 16:16:24 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddsNewTypesWithMissingModuleAndPrototypeName)
|
2021-06-07 16:16:24 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 11:53:15 +02:00
|
|
|
types.push_back(Storage::Type{Storage::Module{"/path/to"},
|
2021-07-06 15:45:10 +02:00
|
|
|
"QObject2",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
2021-08-24 16:49:42 +02:00
|
|
|
sourceId3,
|
2021-07-06 15:45:10 +02:00
|
|
|
{Storage::ExportedType{"Object2"}, Storage::ExportedType{"Obj2"}}});
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
{},
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
types[1].prototype = Storage::ImportedType{"Object2"};
|
2021-06-07 16:16:24 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize({}, importsSourceId2, {types[1]}, {sourceId2}, {}),
|
2021-06-07 16:16:24 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddsNewTypesWithMissingModule)
|
2021-06-07 16:16:24 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
{},
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-07 16:16:24 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize({},
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{}),
|
|
|
|
|
QmlDesigner::ModuleDoesNotExists);
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddsNewTypesReverseOrder)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
|
|
|
|
std::reverse(types.begin(), types.end());
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-06-07 16:16:24 +02:00
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 16:49:42 +02:00
|
|
|
UnorderedElementsAre(AllOf(IsStorageType(Storage::Module{"Qml"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Object"),
|
|
|
|
|
IsExportedType("Obj")))),
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Item"))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesOverwritesTypeAccessSemantics)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].accessSemantics = TypeAccessSemantics::Value;
|
|
|
|
|
types[1].accessSemantics = TypeAccessSemantics::Value;
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, imports, types, {sourceId1, sourceId2}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-06-07 16:16:24 +02:00
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 16:49:42 +02:00
|
|
|
UnorderedElementsAre(AllOf(IsStorageType(Storage::Module{"Qml"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Value,
|
|
|
|
|
sourceId2),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Object"),
|
|
|
|
|
IsExportedType("Obj")))),
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Value,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Item"))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesOverwritesSources)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].sourceId = sourceId3;
|
|
|
|
|
types[1].sourceId = sourceId4;
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::Imports newImports;
|
|
|
|
|
newImports.emplace_back("Qml", Storage::Version{}, sourceId3);
|
|
|
|
|
newImports.emplace_back("Qml", Storage::Version{}, sourceId4);
|
|
|
|
|
newImports.emplace_back("QtQuick", Storage::Version{}, sourceId3);
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, newImports, types, {sourceId1, sourceId2, sourceId3, sourceId4}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-06-07 16:16:24 +02:00
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 16:49:42 +02:00
|
|
|
UnorderedElementsAre(AllOf(IsStorageType(Storage::Module{"Qml"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId4),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Object"),
|
|
|
|
|
IsExportedType("Obj")))),
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Item"))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesInsertTypeIntoPrototypeChain)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-07 16:16:24 +02:00
|
|
|
types[0].prototype = Storage::NativeType{"QQuickObject"};
|
2021-08-24 11:53:15 +02:00
|
|
|
types.push_back(Storage::Type{Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickObject",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-05-06 15:52:20 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1,
|
2021-06-07 10:51:25 +02:00
|
|
|
{Storage::ExportedType{"Object"}}});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0], types[2]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-06-07 16:16:24 +02:00
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 16:49:42 +02:00
|
|
|
UnorderedElementsAre(AllOf(IsStorageType(Storage::Module{"Qml"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Object"),
|
|
|
|
|
IsExportedType("Obj")))),
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QQuickObject",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Object")))),
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QQuickObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Item"))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddQualifiedPrototype)
|
2021-06-07 16:16:24 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].prototype = Storage::QualifiedImportedType{"Object",
|
|
|
|
|
Storage::Import{"QtQuick",
|
|
|
|
|
Storage::Version{},
|
|
|
|
|
sourceId1}};
|
2021-08-24 11:53:15 +02:00
|
|
|
types.push_back(Storage::Type{Storage::Module{"QtQuick"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QQuickObject",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1,
|
|
|
|
|
{Storage::ExportedType{"Object"}}});
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-06-07 16:16:24 +02:00
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 16:49:42 +02:00
|
|
|
UnorderedElementsAre(AllOf(IsStorageType(Storage::Module{"Qml"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Object"),
|
|
|
|
|
IsExportedType("Obj")))),
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QQuickObject",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Object")))),
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QQuickObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Item"))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesThrowsForMissingPrototype)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
2021-05-31 18:13:42 +02:00
|
|
|
sourceId1 = sourcePathCache.sourceId(path1);
|
2021-08-24 11:53:15 +02:00
|
|
|
Storage::Types types{Storage::Type{Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1,
|
2021-06-07 10:51:25 +02:00
|
|
|
{Storage::ExportedType{"Item"}}}};
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{}),
|
2021-08-03 15:03:36 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesThrowsForMissingModule)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
sourceId1 = sourcePathCache.sourceId(path1);
|
2021-08-24 11:53:15 +02:00
|
|
|
Storage::Types types{Storage::Type{Storage::Module{"QtQuick"},
|
2021-07-22 17:26:53 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1,
|
|
|
|
|
{Storage::ExportedType{"Item"}}}};
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize({}, imports, types, {sourceId1}, {}),
|
2021-08-24 11:53:15 +02:00
|
|
|
QmlDesigner::ModuleDoesNotExists);
|
2021-07-22 17:26:53 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, TypeWithInvalidSourceIdThrows)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
2021-08-24 11:53:15 +02:00
|
|
|
Storage::Types types{Storage::Type{Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{""},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
SourceId{},
|
2021-06-07 10:51:25 +02:00
|
|
|
{Storage::ExportedType{"Item"}}}};
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{}),
|
|
|
|
|
QmlDesigner::TypeHasInvalidSourceId);
|
2021-05-31 18:13:42 +02:00
|
|
|
}
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, DeleteTypeIfSourceIdIsSynchronized)
|
2021-05-31 18:13:42 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-03 13:06:23 +02:00
|
|
|
types.erase(types.begin());
|
2021-05-31 18:13:42 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId2, types, {sourceId1, sourceId2}, {});
|
2021-05-31 18:13:42 +02:00
|
|
|
|
2021-06-07 10:51:25 +02:00
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 16:49:42 +02:00
|
|
|
UnorderedElementsAre(AllOf(IsStorageType(Storage::Module{"Qml"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Object"),
|
|
|
|
|
IsExportedType("Obj"))))));
|
2021-05-31 18:13:42 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, DontDeleteTypeIfSourceIdIsNotSynchronized)
|
2021-05-31 18:13:42 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-31 18:13:42 +02:00
|
|
|
types.pop_back();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, types, {sourceId1}, {});
|
2021-05-31 18:13:42 +02:00
|
|
|
|
2021-06-07 16:16:24 +02:00
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 16:49:42 +02:00
|
|
|
UnorderedElementsAre(AllOf(IsStorageType(Storage::Module{"Qml"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Object"),
|
|
|
|
|
IsExportedType("Obj")))),
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Item"))))));
|
2021-06-03 13:06:23 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, UpdateExportedTypesIfTypeNameChanges)
|
2021-07-01 10:42:38 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-01 10:42:38 +02:00
|
|
|
types[0].typeName = "QQuickItem2";
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-07-01 10:42:38 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 16:49:42 +02:00
|
|
|
UnorderedElementsAre(AllOf(IsStorageType(Storage::Module{"Qml"},
|
2021-07-01 10:42:38 +02:00
|
|
|
"QObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Object"),
|
|
|
|
|
IsExportedType("Obj")))),
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-01 10:42:38 +02:00
|
|
|
"QQuickItem2",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Item"))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, BreakingPrototypeChainByDeletingBaseComponentThrows)
|
2021-06-03 13:06:23 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-03 13:06:23 +02:00
|
|
|
types.pop_back();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize({}, importsSourceId1, types, {sourceId1, sourceId2}, {}),
|
2021-07-01 16:28:02 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddPropertyDeclarations)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-06-07 16:16:24 +02:00
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-06-09 17:56:34 +02:00
|
|
|
Contains(
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-09 17:56:34 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList),
|
|
|
|
|
IsPropertyDeclaration(
|
|
|
|
|
"children",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly))))));
|
2021-06-07 16:16:24 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddPropertyDeclarationsWithMissingImportsForNativeTypes)
|
2021-06-07 16:16:24 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
|
|
|
|
types[0].propertyDeclarations.pop_back();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(modules,
|
|
|
|
|
{},
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{}),
|
|
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
2021-06-07 16:16:24 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddPropertyDeclarationsWithMissingImportsForExportedTypes)
|
2021-06-07 16:16:24 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::ImportedType{"Obj"};
|
2021-06-07 16:16:24 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize({}, {}, {types[0]}, {sourceId1}, {}),
|
|
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
2021-06-07 16:16:24 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddPropertyDeclarationQualifiedType)
|
2021-06-07 16:16:24 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::QualifiedImportedType{
|
|
|
|
|
"Object", Storage::Import{"QtQuick", Storage::Version{}, sourceId1}};
|
2021-08-24 11:53:15 +02:00
|
|
|
types.push_back(Storage::Type{Storage::Module{"QtQuick"},
|
2021-06-07 16:16:24 +02:00
|
|
|
"QQuickObject",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1,
|
|
|
|
|
{Storage::ExportedType{"Object"}}});
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-07 16:16:24 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-06-09 17:56:34 +02:00
|
|
|
Contains(
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-09 17:56:34 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QQuickObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList),
|
|
|
|
|
IsPropertyDeclaration(
|
|
|
|
|
"children",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesPropertyDeclarationType)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-07 16:16:24 +02:00
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::NativeType{"QQuickItem"};
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-06-07 16:16:24 +02:00
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-06-09 17:56:34 +02:00
|
|
|
Contains(
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-09 17:56:34 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList),
|
|
|
|
|
IsPropertyDeclaration(
|
|
|
|
|
"children",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesDeclarationTraits)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-09 17:56:34 +02:00
|
|
|
types[0].propertyDeclarations[0].traits = Storage::PropertyDeclarationTraits::IsPointer;
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-06-07 16:16:24 +02:00
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-06-09 17:56:34 +02:00
|
|
|
Contains(
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-09 17:56:34 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsPointer),
|
|
|
|
|
IsPropertyDeclaration(
|
|
|
|
|
"children",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesDeclarationTraitsAndType)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-09 17:56:34 +02:00
|
|
|
types[0].propertyDeclarations[0].traits = Storage::PropertyDeclarationTraits::IsPointer;
|
2021-06-07 16:16:24 +02:00
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::NativeType{"QQuickItem"};
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-06-07 16:16:24 +02:00
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-06-09 17:56:34 +02:00
|
|
|
Contains(
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-09 17:56:34 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsPointer),
|
|
|
|
|
IsPropertyDeclaration(
|
|
|
|
|
"children",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesRemovesAPropertyDeclaration)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].propertyDeclarations.pop_back();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
2021-06-09 17:56:34 +02:00
|
|
|
UnorderedElementsAre(IsPropertyDeclaration(
|
|
|
|
|
"data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddsAPropertyDeclaration)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].propertyDeclarations.push_back(
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::PropertyDeclaration{"object",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-09 17:56:34 +02:00
|
|
|
Storage::PropertyDeclarationTraits::IsPointer});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-06-09 17:56:34 +02:00
|
|
|
ASSERT_THAT(
|
|
|
|
|
storage.fetchTypes(),
|
|
|
|
|
Contains(AllOf(
|
2021-08-24 11:53:15 +02:00
|
|
|
IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-09 17:56:34 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("object",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsPointer),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList),
|
|
|
|
|
IsPropertyDeclaration("children",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesRenameAPropertyDeclaration)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].propertyDeclarations[1].name = "objects";
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-06-07 16:16:24 +02:00
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-06-09 17:56:34 +02:00
|
|
|
Contains(
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-09 17:56:34 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList),
|
|
|
|
|
IsPropertyDeclaration(
|
|
|
|
|
"objects",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly))))));
|
2021-06-03 13:06:23 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, UsingNonExistingNativePropertyTypeThrows)
|
2021-06-03 13:06:23 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-06-07 16:16:24 +02:00
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::NativeType{"QObject2"};
|
2021-06-03 13:06:23 +02:00
|
|
|
types.pop_back();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(modules,
|
|
|
|
|
importsSourceId1,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{}),
|
2021-06-07 16:16:24 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, UsingNonExistingExportedPropertyTypeThrows)
|
2021-06-07 16:16:24 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::ImportedType{"QObject2"};
|
2021-06-07 16:16:24 +02:00
|
|
|
types.pop_back();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(modules,
|
|
|
|
|
importsSourceId1,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{}),
|
2021-06-07 16:16:24 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, UsingNonExistingQualifiedExportedPropertyTypeWithWrongNameThrows)
|
2021-06-07 16:16:24 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::QualifiedImportedType{
|
|
|
|
|
"QObject2", Storage::Import{"Qml", Storage::Version{}, sourceId1}};
|
2021-06-07 16:16:24 +02:00
|
|
|
types.pop_back();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(modules,
|
|
|
|
|
importsSourceId1,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{}),
|
2021-06-07 16:16:24 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, UsingNonExistingQualifiedExportedPropertyTypeWithWrongModuleThrows)
|
2021-06-07 16:16:24 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::QualifiedImportedType{
|
|
|
|
|
"QObject", Storage::Import{"QtQuick", Storage::Version{}, sourceId1}};
|
2021-06-07 16:16:24 +02:00
|
|
|
types.pop_back();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(modules,
|
|
|
|
|
importsSourceId1,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{}),
|
2021-06-07 16:16:24 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
2021-06-03 13:06:23 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, BreakingPropertyDeclarationTypeDependencyByDeletingTypeThrows)
|
2021-06-03 13:06:23 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-07 16:16:24 +02:00
|
|
|
types[0].prototype = Storage::NativeType{};
|
2021-06-03 13:06:23 +02:00
|
|
|
types.pop_back();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(modules,
|
|
|
|
|
importsSourceId1,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{}),
|
2021-06-15 12:32:55 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddFunctionDeclarations)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::functionDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].functionDeclarations[0]),
|
|
|
|
|
Eq(types[0].functionDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesFunctionDeclarationReturnType)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].functionDeclarations[1].returnTypeName = "item";
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::functionDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].functionDeclarations[0]),
|
|
|
|
|
Eq(types[0].functionDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesFunctionDeclarationName)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].functionDeclarations[1].name = "name";
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::functionDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].functionDeclarations[0]),
|
|
|
|
|
Eq(types[0].functionDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesFunctionDeclarationPopParameters)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].functionDeclarations[1].parameters.pop_back();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::functionDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].functionDeclarations[0]),
|
|
|
|
|
Eq(types[0].functionDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesFunctionDeclarationAppendParameters)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].functionDeclarations[1].parameters.push_back(Storage::ParameterDeclaration{"arg4", "int"});
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::functionDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].functionDeclarations[0]),
|
|
|
|
|
Eq(types[0].functionDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesFunctionDeclarationChangeParameterName)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].functionDeclarations[1].parameters[0].name = "other";
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::functionDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].functionDeclarations[0]),
|
|
|
|
|
Eq(types[0].functionDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesFunctionDeclarationChangeParameterTypeName)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].functionDeclarations[1].parameters[0].name = "long long";
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::functionDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].functionDeclarations[0]),
|
|
|
|
|
Eq(types[0].functionDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesFunctionDeclarationChangeParameterTraits)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-09 17:56:34 +02:00
|
|
|
types[0].functionDeclarations[1].parameters[0].traits = QmlDesigner::Storage::PropertyDeclarationTraits::IsList;
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::functionDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].functionDeclarations[0]),
|
|
|
|
|
Eq(types[0].functionDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesRemovesFunctionDeclaration)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].functionDeclarations.pop_back();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::functionDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].functionDeclarations[0]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddFunctionDeclaration)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].functionDeclarations.push_back(
|
|
|
|
|
Storage::FunctionDeclaration{"name", "string", {Storage::ParameterDeclaration{"arg", "int"}}});
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::functionDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].functionDeclarations[0]),
|
|
|
|
|
Eq(types[0].functionDeclarations[1]),
|
|
|
|
|
Eq(types[0].functionDeclarations[2]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddSignalDeclarations)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::signalDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].signalDeclarations[0]),
|
|
|
|
|
Eq(types[0].signalDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesSignalDeclarationName)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].signalDeclarations[1].name = "name";
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::signalDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].signalDeclarations[0]),
|
|
|
|
|
Eq(types[0].signalDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesSignalDeclarationPopParameters)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].signalDeclarations[1].parameters.pop_back();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::signalDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].signalDeclarations[0]),
|
|
|
|
|
Eq(types[0].signalDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesSignalDeclarationAppendParameters)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].signalDeclarations[1].parameters.push_back(Storage::ParameterDeclaration{"arg4", "int"});
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::signalDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].signalDeclarations[0]),
|
|
|
|
|
Eq(types[0].signalDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesSignalDeclarationChangeParameterName)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].signalDeclarations[1].parameters[0].name = "other";
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::signalDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].signalDeclarations[0]),
|
|
|
|
|
Eq(types[0].signalDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesSignalDeclarationChangeParameterTypeName)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].signalDeclarations[1].parameters[0].typeName = "long long";
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::signalDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].signalDeclarations[0]),
|
|
|
|
|
Eq(types[0].signalDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesSignalDeclarationChangeParameterTraits)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-09 17:56:34 +02:00
|
|
|
types[0].signalDeclarations[1].parameters[0].traits = QmlDesigner::Storage::PropertyDeclarationTraits::IsList;
|
2021-05-06 15:52:20 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::signalDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].signalDeclarations[0]),
|
|
|
|
|
Eq(types[0].signalDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesRemovesSignalDeclaration)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].signalDeclarations.pop_back();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::signalDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].signalDeclarations[0]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddSignalDeclaration)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].signalDeclarations.push_back(
|
|
|
|
|
Storage::SignalDeclaration{"name", {Storage::ParameterDeclaration{"arg", "int"}}});
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::signalDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].signalDeclarations[0]),
|
|
|
|
|
Eq(types[0].signalDeclarations[1]),
|
|
|
|
|
Eq(types[0].signalDeclarations[2]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddEnumerationDeclarations)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::enumerationDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].enumerationDeclarations[0]),
|
|
|
|
|
Eq(types[0].enumerationDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesEnumerationDeclarationName)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].enumerationDeclarations[1].name = "Name";
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::enumerationDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].enumerationDeclarations[0]),
|
|
|
|
|
Eq(types[0].enumerationDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesEnumerationDeclarationPopEnumeratorDeclaration)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].enumerationDeclarations[1].enumeratorDeclarations.pop_back();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::enumerationDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].enumerationDeclarations[0]),
|
|
|
|
|
Eq(types[0].enumerationDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesEnumerationDeclarationAppendEnumeratorDeclaration)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].enumerationDeclarations[1].enumeratorDeclarations.push_back(
|
|
|
|
|
Storage::EnumeratorDeclaration{"Haa", 54});
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::enumerationDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].enumerationDeclarations[0]),
|
|
|
|
|
Eq(types[0].enumerationDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesEnumerationDeclarationChangeEnumeratorDeclarationName)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].enumerationDeclarations[1].enumeratorDeclarations[0].name = "Hoo";
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::enumerationDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].enumerationDeclarations[0]),
|
|
|
|
|
Eq(types[0].enumerationDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangesEnumerationDeclarationChangeEnumeratorDeclarationValue)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].enumerationDeclarations[1].enumeratorDeclarations[1].value = 11;
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::enumerationDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].enumerationDeclarations[0]),
|
|
|
|
|
Eq(types[0].enumerationDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage,
|
2021-05-06 15:52:20 +02:00
|
|
|
SynchronizeTypesChangesEnumerationDeclarationAddThatEnumeratorDeclarationHasValue)
|
|
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].enumerationDeclarations[1].enumeratorDeclarations[0].value = 11;
|
|
|
|
|
types[0].enumerationDeclarations[1].enumeratorDeclarations[0].hasValue = true;
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::enumerationDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].enumerationDeclarations[0]),
|
|
|
|
|
Eq(types[0].enumerationDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage,
|
2021-05-06 15:52:20 +02:00
|
|
|
SynchronizeTypesChangesEnumerationDeclarationRemoveThatEnumeratorDeclarationHasValue)
|
|
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].enumerationDeclarations[1].enumeratorDeclarations[0].hasValue = false;
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::enumerationDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].enumerationDeclarations[0]),
|
|
|
|
|
Eq(types[0].enumerationDeclarations[1]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesRemovesEnumerationDeclaration)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].enumerationDeclarations.pop_back();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::enumerationDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].enumerationDeclarations[0]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddEnumerationDeclaration)
|
2021-05-06 15:52:20 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-05-06 15:52:20 +02:00
|
|
|
types[0].enumerationDeclarations.push_back(
|
|
|
|
|
Storage::EnumerationDeclaration{"name", {Storage::EnumeratorDeclaration{"Foo", 98, true}}});
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-05-06 15:52:20 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-03 13:06:23 +02:00
|
|
|
"QQuickItem",
|
2021-06-07 16:16:24 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-03 13:06:23 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::enumerationDeclarations,
|
|
|
|
|
UnorderedElementsAre(Eq(types[0].enumerationDeclarations[0]),
|
|
|
|
|
Eq(types[0].enumerationDeclarations[1]),
|
|
|
|
|
Eq(types[0].enumerationDeclarations[2]))))));
|
2021-05-06 15:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeModulesAddModules)
|
2021-06-01 17:46:49 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::Modules modules{createModules()};
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules, {}, {}, {moduleSourceId1, moduleSourceId2, moduleSourceId5}, {});
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
ASSERT_THAT(storage.fetchAllModules(),
|
2021-08-24 16:49:42 +02:00
|
|
|
UnorderedElementsAre(IsModule("Qml", moduleSourceId1),
|
|
|
|
|
IsModule("QtQuick", moduleSourceId2),
|
|
|
|
|
IsModule("/path/to", moduleSourceId3)));
|
2021-06-01 17:46:49 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeModulesAddModulesAgain)
|
2021-06-01 17:46:49 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::Modules modules{createModules()};
|
|
|
|
|
storage.synchronize(modules, {}, {}, {moduleSourceId1, moduleSourceId2, moduleSourceId3}, {});
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules, {}, {}, {moduleSourceId1, moduleSourceId2, moduleSourceId3}, {});
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
ASSERT_THAT(storage.fetchAllModules(),
|
2021-08-24 16:49:42 +02:00
|
|
|
UnorderedElementsAre(IsModule("Qml", moduleSourceId1),
|
|
|
|
|
IsModule("QtQuick", moduleSourceId2),
|
|
|
|
|
IsModule("/path/to", moduleSourceId3)));
|
2021-06-01 17:46:49 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeModulesUpdateToMoreModules)
|
2021-06-01 17:46:49 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::Modules modules{createModules()};
|
|
|
|
|
storage.synchronize(modules, {}, {}, {moduleSourceId1, moduleSourceId2, moduleSourceId3}, {});
|
|
|
|
|
modules.push_back(Storage::Module{"QtQuick.Foo", moduleSourceId4});
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
2021-07-21 14:53:14 +02:00
|
|
|
{},
|
|
|
|
|
{},
|
2021-08-24 16:49:42 +02:00
|
|
|
{moduleSourceId1, moduleSourceId2, moduleSourceId3, moduleSourceId4},
|
2021-08-03 15:03:36 +02:00
|
|
|
{});
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
ASSERT_THAT(storage.fetchAllModules(),
|
2021-08-24 16:49:42 +02:00
|
|
|
UnorderedElementsAre(IsModule("Qml", moduleSourceId1),
|
|
|
|
|
IsModule("QtQuick", moduleSourceId2),
|
|
|
|
|
IsModule("/path/to", moduleSourceId3),
|
|
|
|
|
IsModule("QtQuick.Foo", moduleSourceId4)));
|
2021-07-21 14:53:14 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeModulesAddOneMoreModules)
|
2021-07-21 14:53:14 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::Modules modules{createModules()};
|
|
|
|
|
storage.synchronize(modules, {}, {}, {moduleSourceId1, moduleSourceId2, moduleSourceId3}, {});
|
|
|
|
|
auto newModule = Storage::Module{"QtQuick.Foo", moduleSourceId4};
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({newModule}, {}, {}, {moduleSourceId4}, {});
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
ASSERT_THAT(storage.fetchAllModules(),
|
2021-08-24 16:49:42 +02:00
|
|
|
UnorderedElementsAre(IsModule("Qml", moduleSourceId1),
|
|
|
|
|
IsModule("QtQuick", moduleSourceId2),
|
|
|
|
|
IsModule("/path/to", moduleSourceId3),
|
|
|
|
|
IsModule("QtQuick.Foo", moduleSourceId4)));
|
2021-06-01 17:46:49 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeModulesRemoveModule)
|
2021-06-01 17:46:49 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::Modules modules{createModules()};
|
|
|
|
|
storage.synchronize(modules, {}, {}, {moduleSourceId1, moduleSourceId2, moduleSourceId3}, {});
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, {}, {}, {moduleSourceId3}, {});
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
ASSERT_THAT(storage.fetchAllModules(),
|
2021-08-24 16:49:42 +02:00
|
|
|
UnorderedElementsAre(IsModule("Qml", moduleSourceId1),
|
|
|
|
|
IsModule("QtQuick", moduleSourceId2)));
|
2021-06-01 17:46:49 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeModulesChangeSourceId)
|
2021-06-01 17:46:49 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::Modules modules{createModules()};
|
|
|
|
|
storage.synchronize(modules, {}, {}, {moduleSourceId1, moduleSourceId2, moduleSourceId3}, {});
|
|
|
|
|
modules[1].sourceId = moduleSourceId4;
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({modules[1]}, {}, {}, {moduleSourceId2, moduleSourceId4}, {});
|
2021-07-21 14:53:14 +02:00
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
ASSERT_THAT(storage.fetchAllModules(),
|
2021-08-24 16:49:42 +02:00
|
|
|
UnorderedElementsAre(IsModule("Qml", moduleSourceId1),
|
|
|
|
|
IsModule("QtQuick", moduleSourceId4),
|
|
|
|
|
IsModule("/path/to", moduleSourceId3)));
|
2021-07-21 14:53:14 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeModulesChangeName)
|
2021-07-21 14:53:14 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::Modules modules{createModules()};
|
|
|
|
|
storage.synchronize(modules, {}, {}, {moduleSourceId1, moduleSourceId2, moduleSourceId3}, {});
|
|
|
|
|
modules[0].name = "Qml2";
|
2021-07-21 14:53:14 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules, {}, {}, {moduleSourceId1, moduleSourceId2, moduleSourceId3}, {});
|
2021-07-21 14:53:14 +02:00
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
ASSERT_THAT(storage.fetchAllModules(),
|
2021-08-24 16:49:42 +02:00
|
|
|
UnorderedElementsAre(IsModule("Qml2", moduleSourceId1),
|
|
|
|
|
IsModule("QtQuick", moduleSourceId2),
|
|
|
|
|
IsModule("/path/to", moduleSourceId3)));
|
2021-07-21 14:53:14 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, RemovingModuleRemovesDependentTypesToo)
|
2021-07-21 14:53:14 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::Types types{createTypes()};
|
|
|
|
|
types[0].prototype = Storage::NativeType{""};
|
|
|
|
|
types[0].propertyDeclarations.clear();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
2021-08-03 15:03:36 +02:00
|
|
|
{});
|
2021-07-21 14:53:14 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, {}, {}, {moduleSourceId2, moduleSourceId3}, {});
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
UnorderedElementsAre(IsStorageType(Storage::Module{"Qml"},
|
|
|
|
|
"QObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2)));
|
2021-06-01 17:46:49 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, RemovingModuleThrowsForMissingType)
|
2021-06-01 17:46:49 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::Types types{createTypes()};
|
|
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId2);
|
|
|
|
|
types[0].prototype = Storage::NativeType{""};
|
|
|
|
|
types[0].propertyDeclarations.clear();
|
|
|
|
|
types[1].prototype = Storage::ImportedType{"Item"};
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
2021-08-03 15:03:36 +02:00
|
|
|
{});
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize({}, {}, {}, {moduleSourceId2, moduleSourceId3}, {}),
|
|
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
2021-06-01 17:46:49 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, FetchTypeIdByModuleIdAndName)
|
2021-06-01 17:46:49 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::Types types{createTypes()};
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
auto qmlModuleId = storage.fetchModuleId("Qml");
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
auto typeId = storage.fetchTypeIdByName(qmlModuleId, "QObject");
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypeIdByExportedName("Object"), Eq(typeId));
|
2021-06-01 17:46:49 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, FetchTypeIdByExportedName)
|
2021-06-01 17:46:49 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::Types types{createTypes()};
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
2021-08-03 15:03:36 +02:00
|
|
|
{});
|
2021-08-24 16:49:42 +02:00
|
|
|
auto qmlModuleId = storage.fetchModuleId("Qml");
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
auto typeId = storage.fetchTypeIdByExportedName("Object");
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THAT(storage.fetchTypeIdByName(qmlModuleId, "QObject"), Eq(typeId));
|
2021-06-01 17:46:49 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, FetchTypeIdByImporIdsAndExportedName)
|
2021-06-01 17:46:49 +02:00
|
|
|
{
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::Types types{createTypes()};
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
2021-08-03 15:03:36 +02:00
|
|
|
{});
|
2021-08-24 16:49:42 +02:00
|
|
|
auto qmlModuleId = storage.fetchModuleId("Qml");
|
|
|
|
|
auto qtQuickModuleId = storage.fetchModuleId("QtQuick");
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
auto typeId = storage.fetchTypeIdByModuleIdsAndExportedName({qmlModuleId, qtQuickModuleId},
|
|
|
|
|
"Object");
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THAT(storage.fetchTypeIdByName(qmlModuleId, "QObject"), Eq(typeId));
|
|
|
|
|
}
|
2021-06-01 17:46:49 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, FetchInvalidTypeIdByImporIdsAndExportedNameIfModuleIdsAreEmpty)
|
|
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
2021-08-03 15:03:36 +02:00
|
|
|
{});
|
2021-08-24 16:49:42 +02:00
|
|
|
auto typeId = storage.fetchTypeIdByModuleIdsAndExportedName({}, "Object");
|
2021-06-07 10:51:25 +02:00
|
|
|
|
|
|
|
|
ASSERT_FALSE(typeId.isValid());
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
TEST_F(ProjectStorage, FetchInvalidTypeIdByImporIdsAndExportedNameIfModuleIdsAreInvalid)
|
2021-06-07 10:51:25 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-08-24 11:53:15 +02:00
|
|
|
auto typeId = storage.fetchTypeIdByModuleIdsAndExportedName({ModuleId{}}, "Object");
|
2021-06-07 10:51:25 +02:00
|
|
|
|
|
|
|
|
ASSERT_FALSE(typeId.isValid());
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
TEST_F(ProjectStorage, FetchInvalidTypeIdByImporIdsAndExportedNameIfNotInModule)
|
2021-06-07 10:51:25 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
auto qtQuickModuleId = storage.fetchModuleId("QtQuick");
|
|
|
|
|
auto typeId = storage.fetchTypeIdByModuleIdsAndExportedName({qtQuickModuleId}, "Object");
|
2021-06-07 10:51:25 +02:00
|
|
|
|
|
|
|
|
ASSERT_FALSE(typeId.isValid());
|
2021-06-03 13:06:23 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddAliasDeclarations)
|
2021-06-09 17:56:34 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-09 17:56:34 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(AllOf(
|
2021-08-24 11:53:15 +02:00
|
|
|
IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-09 17:56:34 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
2021-06-10 16:39:29 +02:00
|
|
|
sourceId3),
|
2021-06-09 17:56:34 +02:00
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("items",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("objects",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddAliasDeclarationsAgain)
|
2021-06-09 17:56:34 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
|
|
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-09 17:56:34 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(AllOf(
|
2021-08-24 11:53:15 +02:00
|
|
|
IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-09 17:56:34 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
2021-06-10 16:39:29 +02:00
|
|
|
sourceId3),
|
2021-06-09 17:56:34 +02:00
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("items",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("objects",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesRemoveAliasDeclarations)
|
2021-06-09 17:56:34 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-07 16:38:08 +02:00
|
|
|
types[2].propertyDeclarations.pop_back();
|
2021-06-09 17:56:34 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId3, {types[2]}, {sourceId3}, {});
|
2021-06-09 17:56:34 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(AllOf(
|
2021-08-24 11:53:15 +02:00
|
|
|
IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-09 17:56:34 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
2021-06-10 16:39:29 +02:00
|
|
|
sourceId3),
|
2021-06-09 17:56:34 +02:00
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("items",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddAliasDeclarationsThrowsForWrongTypeName)
|
2021-06-09 17:56:34 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
2021-07-07 16:38:08 +02:00
|
|
|
types[2].propertyDeclarations[1].typeName = Storage::NativeType{"QQuickItemWrong"};
|
2021-06-09 17:56:34 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(modules, importsSourceId4, {types[2]}, {sourceId4}, {}),
|
2021-06-10 16:39:29 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
2021-06-09 17:56:34 +02:00
|
|
|
}
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesAddAliasDeclarationsThrowsForWrongPropertyName)
|
2021-06-09 17:56:34 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
2021-07-07 16:38:08 +02:00
|
|
|
types[2].propertyDeclarations[1].aliasPropertyName = "childrenWrong";
|
2021-06-09 17:56:34 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(modules, imports, types, {sourceId4}, {}),
|
2021-07-15 13:46:17 +02:00
|
|
|
QmlDesigner::PropertyNameDoesNotExists);
|
2021-06-09 17:56:34 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangeAliasDeclarationsTypeName)
|
2021-06-09 17:56:34 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
types[2].propertyDeclarations[2].typeName = Storage::ImportedType{"Obj2"};
|
|
|
|
|
importsSourceId3.emplace_back("/path/to", Storage::Version{}, sourceId3);
|
2021-06-09 17:56:34 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId3, {types[2]}, {sourceId3}, {});
|
2021-06-09 17:56:34 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(AllOf(
|
2021-08-24 11:53:15 +02:00
|
|
|
IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-09 17:56:34 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
2021-06-10 16:39:29 +02:00
|
|
|
sourceId3),
|
2021-06-09 17:56:34 +02:00
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("items",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("objects",
|
2021-06-10 16:39:29 +02:00
|
|
|
Storage::NativeType{"QObject"},
|
2021-06-09 17:56:34 +02:00
|
|
|
Storage::PropertyDeclarationTraits::IsList),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangeAliasDeclarationsPropertyName)
|
2021-06-09 17:56:34 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-07 16:38:08 +02:00
|
|
|
types[2].propertyDeclarations[2].aliasPropertyName = "children";
|
2021-06-09 17:56:34 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId3, {types[2]}, {sourceId3}, {});
|
2021-06-09 17:56:34 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(
|
|
|
|
|
storage.fetchTypes(),
|
|
|
|
|
Contains(
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-09 17:56:34 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
2021-06-10 16:39:29 +02:00
|
|
|
sourceId3),
|
2021-06-09 17:56:34 +02:00
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("items",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("objects",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangeAliasDeclarationsToPropertyDeclaration)
|
2021-06-09 17:56:34 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-07 16:38:08 +02:00
|
|
|
types[2].propertyDeclarations.pop_back();
|
2021-06-09 17:56:34 +02:00
|
|
|
types[2].propertyDeclarations.push_back(
|
|
|
|
|
Storage::PropertyDeclaration{"objects",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly});
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId3, {types[2]}, {sourceId3}, {});
|
2021-06-09 17:56:34 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(
|
|
|
|
|
storage.fetchTypes(),
|
|
|
|
|
Contains(
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-09 17:56:34 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
2021-06-10 16:39:29 +02:00
|
|
|
sourceId3),
|
2021-06-09 17:56:34 +02:00
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("items",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("objects",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangePropertyDeclarationsToAliasDeclaration)
|
2021-06-09 17:56:34 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
|
|
|
|
auto typesChanged = types;
|
2021-07-07 16:38:08 +02:00
|
|
|
typesChanged[2].propertyDeclarations.pop_back();
|
2021-06-09 17:56:34 +02:00
|
|
|
typesChanged[2].propertyDeclarations.push_back(
|
|
|
|
|
Storage::PropertyDeclaration{"objects",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly});
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
typesChanged,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-09 17:56:34 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, imports, types, {sourceId1, sourceId2, sourceId3, sourceId4}, {});
|
2021-06-09 17:56:34 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(AllOf(
|
2021-08-24 11:53:15 +02:00
|
|
|
IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-09 17:56:34 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
2021-06-10 16:39:29 +02:00
|
|
|
sourceId3),
|
2021-06-09 17:56:34 +02:00
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("items",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("objects",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangeAliasTargetPropertyDeclarationTraits)
|
2021-06-10 16:39:29 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-10 16:39:29 +02:00
|
|
|
types[1].propertyDeclarations[0].traits = Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly;
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId2, {types[1]}, {sourceId2}, {});
|
2021-06-10 16:39:29 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(
|
|
|
|
|
storage.fetchTypes(),
|
|
|
|
|
Contains(
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-10 16:39:29 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("items",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("objects",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesChangeAliasTargetPropertyDeclarationTypeName)
|
2021-06-10 16:39:29 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
types[1].propertyDeclarations[0].typeName = Storage::ImportedType{"Item"};
|
|
|
|
|
importsSourceId2.emplace_back("QtQuick", Storage::Version{}, sourceId2);
|
2021-06-10 16:39:29 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId2, {types[1]}, {sourceId2}, {});
|
2021-06-10 16:39:29 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(AllOf(
|
2021-08-24 11:53:15 +02:00
|
|
|
IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-10 16:39:29 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("items",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("objects",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesRemovePropertyDeclarationWithAnAliasThrows)
|
2021-06-10 16:39:29 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-10 16:39:29 +02:00
|
|
|
types[1].propertyDeclarations.pop_back();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize({}, importsSourceId2, {types[1]}, {sourceId2}, {}),
|
2021-06-10 16:39:29 +02:00
|
|
|
Sqlite::ConstraintPreventsModification);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesRemovePropertyDeclarationAndAlias)
|
2021-06-10 16:39:29 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-10 16:39:29 +02:00
|
|
|
types[1].propertyDeclarations.pop_back();
|
2021-07-07 16:38:08 +02:00
|
|
|
types[2].propertyDeclarations.pop_back();
|
2021-06-10 16:39:29 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({},
|
|
|
|
|
importsSourceId2 + importsSourceId3,
|
|
|
|
|
{types[1], types[2]},
|
|
|
|
|
{sourceId2, sourceId3},
|
|
|
|
|
{});
|
2021-06-10 16:39:29 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(AllOf(
|
2021-08-24 11:53:15 +02:00
|
|
|
IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-10 16:39:29 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("items",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesRemoveTypeWithAliasTargetPropertyDeclarationThrows)
|
2021-06-10 16:39:29 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[2].propertyDeclarations[2].typeName = Storage::ImportedType{"Object2"};
|
|
|
|
|
imports.emplace_back("/path/to", Storage::Version{}, sourceId3);
|
|
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-10 16:39:29 +02:00
|
|
|
|
2021-08-03 15:03:36 +02:00
|
|
|
ASSERT_THROW(storage.synchronize({}, {}, {}, {sourceId4}, {}), QmlDesigner::TypeNameDoesNotExists);
|
2021-06-10 16:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesRemoveTypeAndAliasPropertyDeclaration)
|
2021-06-10 16:39:29 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[2].propertyDeclarations[2].typeName = Storage::ImportedType{"Object2"};
|
|
|
|
|
imports.emplace_back("/path/to", Storage::Version{}, sourceId3);
|
|
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-07 16:38:08 +02:00
|
|
|
types[2].propertyDeclarations.pop_back();
|
2021-06-10 16:39:29 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({},
|
|
|
|
|
importsSourceId1 + importsSourceId3,
|
|
|
|
|
{types[0], types[2]},
|
|
|
|
|
{sourceId1, sourceId3},
|
|
|
|
|
{});
|
2021-06-10 16:39:29 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(AllOf(
|
2021-08-24 11:53:15 +02:00
|
|
|
IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-10 16:39:29 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("items",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, UpdateAliasPropertyIfPropertyIsOverloaded)
|
2021-06-15 12:32:55 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-15 12:32:55 +02:00
|
|
|
types[0].propertyDeclarations.push_back(
|
|
|
|
|
Storage::PropertyDeclaration{"objects",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly});
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-06-15 12:32:55 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(
|
|
|
|
|
storage.fetchTypes(),
|
|
|
|
|
Contains(
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-15 12:32:55 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("items",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("objects",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, AliasPropertyIsOverloaded)
|
2021-06-15 12:32:55 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
|
|
|
|
types[0].propertyDeclarations.push_back(
|
|
|
|
|
Storage::PropertyDeclaration{"objects",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly});
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-15 12:32:55 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(
|
|
|
|
|
storage.fetchTypes(),
|
|
|
|
|
Contains(
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-15 12:32:55 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("items",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("objects",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, UpdateAliasPropertyIfOverloadedPropertyIsRemoved)
|
2021-06-15 12:32:55 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
|
|
|
|
types[0].propertyDeclarations.push_back(
|
|
|
|
|
Storage::PropertyDeclaration{"objects",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly});
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-06-15 12:32:55 +02:00
|
|
|
types[0].propertyDeclarations.pop_back();
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-06-15 12:32:55 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(AllOf(
|
2021-08-24 11:53:15 +02:00
|
|
|
IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-15 12:32:55 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("items",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("objects",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, RelinkAliasProperty)
|
2021-06-15 12:32:55 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
|
|
|
|
types[1].propertyDeclarations[0].typeName = Storage::NativeType{"QObject2"};
|
2021-08-24 16:49:42 +02:00
|
|
|
imports.emplace_back("/path/to", Storage::Version{}, sourceId2);
|
|
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId2);
|
|
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-08-24 11:53:15 +02:00
|
|
|
types[3].module = Storage::Module{"QtQuick"};
|
2021-06-15 12:32:55 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId4, {types[3]}, {sourceId4}, {});
|
2021-06-15 12:32:55 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(AllOf(
|
2021-08-24 11:53:15 +02:00
|
|
|
IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-22 17:26:53 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("items",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("objects",
|
|
|
|
|
Storage::NativeType{"QObject2"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, DoNotRelinkAliasPropertyForQualifiedImportedTypeName)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[1].propertyDeclarations[0].typeName = Storage::QualifiedImportedType{
|
|
|
|
|
"Object2", Storage::Import{"/path/to", Storage::Version{}, sourceId2}};
|
|
|
|
|
imports.emplace_back("/path/to", Storage::Version{}, sourceId2);
|
|
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-08-24 11:53:15 +02:00
|
|
|
types[3].module = Storage::Module{"QtQuick"};
|
2021-08-24 16:49:42 +02:00
|
|
|
importsSourceId4.emplace_back("QtQuick", Storage::Version{}, sourceId4);
|
2021-07-22 17:26:53 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize({}, importsSourceId4, {types[3]}, {sourceId4}, {}),
|
2021-07-22 17:26:53 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage,
|
2021-08-24 16:49:42 +02:00
|
|
|
DoRelinkAliasPropertyForQualifiedImportedTypeNameEvenIfAnOtherSimilarTimeNameExists)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[1].propertyDeclarations[0].typeName = Storage::QualifiedImportedType{
|
|
|
|
|
"Object2", Storage::Import{"/path/to", Storage::Version{}, sourceId2}};
|
|
|
|
|
imports.emplace_back("/path/to", Storage::Version{}, sourceId2);
|
2021-08-24 11:53:15 +02:00
|
|
|
types.push_back(Storage::Type{Storage::Module{"QtQuick"},
|
2021-07-22 17:26:53 +02:00
|
|
|
"QObject2",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId5,
|
|
|
|
|
{Storage::ExportedType{"Object2"}, Storage::ExportedType{"Obj2"}}});
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1,
|
|
|
|
|
sourceId2,
|
|
|
|
|
sourceId3,
|
|
|
|
|
sourceId4,
|
|
|
|
|
sourceId5,
|
|
|
|
|
moduleSourceId1,
|
|
|
|
|
moduleSourceId2,
|
|
|
|
|
moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-22 17:26:53 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(AllOf(
|
2021-08-24 11:53:15 +02:00
|
|
|
IsStorageType(Storage::Module{"QtQuick"},
|
2021-06-15 12:32:55 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("items",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("objects",
|
|
|
|
|
Storage::NativeType{"QObject2"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, RelinkAliasPropertyReactToTypeNameChange)
|
2021-07-01 10:42:38 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases2()};
|
2021-07-07 16:38:08 +02:00
|
|
|
types[2].propertyDeclarations.push_back(
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::PropertyDeclaration{"items", Storage::ImportedType{"Item"}, "children"});
|
|
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-01 10:42:38 +02:00
|
|
|
types[0].typeName = "QQuickItem2";
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-07-01 10:42:38 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(AllOf(
|
2021-08-24 11:53:15 +02:00
|
|
|
IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-01 10:42:38 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
UnorderedElementsAre(
|
|
|
|
|
IsPropertyDeclaration("items",
|
|
|
|
|
Storage::NativeType{"QQuickItem2"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly),
|
|
|
|
|
IsPropertyDeclaration("objects",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList),
|
|
|
|
|
IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, DoNotRelinkAliasPropertyForDeletedType)
|
2021-07-01 10:42:38 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
|
|
|
|
types[1].propertyDeclarations[0].typeName = Storage::NativeType{"QObject2"};
|
2021-08-24 16:49:42 +02:00
|
|
|
imports.emplace_back("/path/to", Storage::Version{}, sourceId2);
|
|
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId2);
|
|
|
|
|
|
|
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
types[3].module = Storage::Module{"QtQuick"};
|
2021-07-01 10:42:38 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId4, {types[3]}, {sourceId3, sourceId4}, {});
|
2021-07-01 10:42:38 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Not(Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-01 10:42:38 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3)))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, DoNotRelinkAliasPropertyForDeletedTypeAndPropertyType)
|
2021-07-01 10:42:38 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
|
|
|
|
types[1].propertyDeclarations[0].typeName = Storage::NativeType{"QObject2"};
|
2021-08-24 16:49:42 +02:00
|
|
|
imports.emplace_back("/path/to", Storage::Version{}, sourceId2);
|
|
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
types[0].prototype = Storage::NativeType{};
|
|
|
|
|
importsSourceId1.emplace_back("/path/to", Storage::Version{}, sourceId1);
|
|
|
|
|
importsSourceId4.emplace_back("QtQuick", Storage::Version{}, sourceId4);
|
|
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::ImportedType{"Object2"};
|
|
|
|
|
types[3].propertyDeclarations[0].typeName = Storage::ImportedType{"Item"};
|
|
|
|
|
|
|
|
|
|
storage.synchronize({},
|
|
|
|
|
importsSourceId1 + importsSourceId4,
|
|
|
|
|
{types[0], types[3]},
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4},
|
|
|
|
|
{});
|
2021-07-01 10:42:38 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(), SizeIs(2));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, DoNotRelinkAliasPropertyForDeletedTypeAndPropertyTypeNameChange)
|
2021-07-01 10:42:38 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
|
|
|
|
types[1].propertyDeclarations[0].typeName = Storage::NativeType{"QObject2"};
|
2021-08-24 16:49:42 +02:00
|
|
|
imports.emplace_back("/path/to", Storage::Version{}, sourceId2);
|
|
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
types[3].module = Storage::Module{"QtQuick"};
|
2021-07-01 10:42:38 +02:00
|
|
|
types[1].propertyDeclarations[0].typeName = Storage::NativeType{"QObject"};
|
2021-08-24 16:49:42 +02:00
|
|
|
importsSourceId4.emplace_back("QtQuick", Storage::Version{}, sourceId4);
|
2021-07-01 10:42:38 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({},
|
|
|
|
|
importsSourceId2 + importsSourceId4,
|
|
|
|
|
{types[1], types[3]},
|
|
|
|
|
{sourceId2, sourceId3, sourceId4},
|
|
|
|
|
{});
|
2021-07-01 10:42:38 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 16:49:42 +02:00
|
|
|
Not(Contains(IsStorageType(Storage::Module{"QtQuick"},
|
|
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3))));
|
2021-07-01 10:42:38 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, DoNotRelinkPropertyTypeDoesNotExists)
|
2021-07-01 10:42:38 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
|
|
|
|
types[1].propertyDeclarations[0].typeName = Storage::NativeType{"QObject2"};
|
2021-08-24 16:49:42 +02:00
|
|
|
imports.emplace_back("/path/to", Storage::Version{}, sourceId2);
|
|
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId2);
|
|
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-01 10:42:38 +02:00
|
|
|
types.pop_back();
|
|
|
|
|
|
2021-08-03 15:03:36 +02:00
|
|
|
ASSERT_THROW(storage.synchronize({}, {}, {}, {sourceId4}, {}), QmlDesigner::TypeNameDoesNotExists);
|
2021-07-01 10:42:38 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, DoNotRelinkAliasPropertyTypeDoesNotExists)
|
2021-07-01 10:42:38 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases2()};
|
|
|
|
|
types[1].propertyDeclarations[0].typeName = Storage::NativeType{"QObject2"};
|
2021-08-24 16:49:42 +02:00
|
|
|
imports.emplace_back("/path/to", Storage::Version{}, sourceId2);
|
|
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-01 10:42:38 +02:00
|
|
|
|
2021-08-03 15:03:36 +02:00
|
|
|
ASSERT_THROW(storage.synchronize({}, {}, {}, {sourceId1}, {}), QmlDesigner::TypeNameDoesNotExists);
|
2021-07-01 10:42:38 +02:00
|
|
|
}
|
2021-07-01 16:28:02 +02:00
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, ChangePrototypeTypeName)
|
2021-07-01 16:28:02 +02:00
|
|
|
{
|
2021-07-07 16:38:08 +02:00
|
|
|
Storage::Types types{createTypesWithExportedTypeNamesOnly()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-01 16:28:02 +02:00
|
|
|
types[1].typeName = "QObject3";
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId2, {types[1]}, {sourceId2}, {});
|
2021-07-01 16:28:02 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-01 16:28:02 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject3"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1)));
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
TEST_F(ProjectStorage, ChangePrototypeTypeModuleId)
|
2021-07-01 16:28:02 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-08-24 11:53:15 +02:00
|
|
|
types[1].module = Storage::Module{"QtQuick"};
|
2021-07-01 16:28:02 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId2, {types[1]}, {sourceId2}, {});
|
2021-07-01 16:28:02 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-22 17:26:53 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1)));
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, ChangeQualifiedPrototypeTypeModuleIdThows)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].prototype = Storage::QualifiedImportedType{"Object",
|
|
|
|
|
Storage::Import{"Qml",
|
|
|
|
|
Storage::Version{},
|
|
|
|
|
sourceId1}};
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-08-24 11:53:15 +02:00
|
|
|
types[1].module = Storage::Module{"QtQuick"};
|
2021-07-22 17:26:53 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize({}, importsSourceId2, {types[1]}, {sourceId2}, {}),
|
2021-07-22 17:26:53 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, ChangeQualifiedPrototypeTypeModuleId)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].prototype = Storage::QualifiedImportedType{"Object",
|
|
|
|
|
Storage::Import{"Qml",
|
|
|
|
|
Storage::Version{},
|
|
|
|
|
sourceId1}};
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-08-24 11:53:15 +02:00
|
|
|
types[1].module = Storage::Module{"QtQuick"};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].prototype = Storage::QualifiedImportedType{"Object",
|
|
|
|
|
Storage::Import{"QtQuick",
|
|
|
|
|
Storage::Version{},
|
|
|
|
|
sourceId1}};
|
|
|
|
|
|
|
|
|
|
storage.synchronize({},
|
|
|
|
|
importsSourceId1 + importsSourceId2,
|
|
|
|
|
{types[0], types[1]},
|
|
|
|
|
{sourceId1, sourceId2},
|
|
|
|
|
{});
|
2021-07-22 17:26:53 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-01 16:28:02 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1)));
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 11:53:15 +02:00
|
|
|
TEST_F(ProjectStorage, ChangePrototypeTypeNameAndModuleId)
|
2021-07-01 16:28:02 +02:00
|
|
|
{
|
2021-07-07 16:38:08 +02:00
|
|
|
Storage::Types types{createTypesWithExportedTypeNamesOnly()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-08-24 11:53:15 +02:00
|
|
|
types[1].module = Storage::Module{"QtQuick"};
|
2021-07-01 16:28:02 +02:00
|
|
|
types[1].typeName = "QObject3";
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId2, {types[1]}, {sourceId2}, {});
|
2021-07-01 16:28:02 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-01 16:28:02 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject3"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1)));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, ChangePrototypeTypeNameThrowsForWrongNativePrototupeTypeName)
|
2021-07-01 16:28:02 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::ImportedType{"Object"};
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-01 16:28:02 +02:00
|
|
|
types[1].typeName = "QObject3";
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize({}, importsSourceId2, {types[1]}, {sourceId2}, {}),
|
2021-07-01 16:28:02 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, ThrowForPrototypeChainCycles)
|
2021-07-06 15:45:10 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[1].prototype = Storage::ImportedType{"Object2"};
|
2021-08-24 11:53:15 +02:00
|
|
|
types.push_back(Storage::Type{Storage::Module{"/path/to"},
|
2021-07-06 15:45:10 +02:00
|
|
|
"QObject2",
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::ImportedType{"Item"},
|
2021-07-06 15:45:10 +02:00
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3,
|
|
|
|
|
{Storage::ExportedType{"Object2"}, Storage::ExportedType{"Obj2"}}});
|
2021-08-24 16:49:42 +02:00
|
|
|
imports.emplace_back("/path/to", Storage::Version{}, sourceId2);
|
|
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId3);
|
|
|
|
|
imports.emplace_back("/path/to", Storage::Version{}, sourceId3);
|
2021-07-06 15:45:10 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{}),
|
2021-07-06 15:45:10 +02:00
|
|
|
QmlDesigner::PrototypeChainCycle);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, ThrowForTypeIdAndPrototypeIdAreTheSame)
|
2021-07-06 15:45:10 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[1].prototype = Storage::ImportedType{"Object"};
|
2021-07-06 15:45:10 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{}),
|
2021-07-06 15:45:10 +02:00
|
|
|
QmlDesigner::PrototypeChainCycle);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, ThrowForTypeIdAndPrototypeIdAreTheSameForRelinking)
|
2021-07-06 15:45:10 +02:00
|
|
|
{
|
2021-07-07 16:38:08 +02:00
|
|
|
Storage::Types types{createTypesWithExportedTypeNamesOnly()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
types[1].prototype = Storage::ImportedType{"Item"};
|
2021-07-06 15:45:10 +02:00
|
|
|
types[1].typeName = "QObject2";
|
2021-08-24 16:49:42 +02:00
|
|
|
importsSourceId2.emplace_back("QtQuick", Storage::Version{}, sourceId2);
|
2021-07-06 15:45:10 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize({}, importsSourceId2, {types[1]}, {sourceId2}, {}),
|
2021-07-15 13:46:17 +02:00
|
|
|
QmlDesigner::PrototypeChainCycle);
|
2021-07-06 15:45:10 +02:00
|
|
|
}
|
2021-07-07 16:38:08 +02:00
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, RecursiveAliases)
|
2021-07-07 16:38:08 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithRecursiveAliases()};
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1,
|
|
|
|
|
sourceId2,
|
|
|
|
|
sourceId3,
|
|
|
|
|
sourceId4,
|
|
|
|
|
sourceId5,
|
|
|
|
|
moduleSourceId1,
|
|
|
|
|
moduleSourceId2,
|
|
|
|
|
moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-07 16:38:08 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-07 16:38:08 +02:00
|
|
|
"QAliasItem2",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId5),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
ElementsAre(IsPropertyDeclaration(
|
|
|
|
|
"objects",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, RecursiveAliasesChangePropertyType)
|
2021-07-07 16:38:08 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithRecursiveAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1,
|
|
|
|
|
sourceId2,
|
|
|
|
|
sourceId3,
|
|
|
|
|
sourceId4,
|
|
|
|
|
sourceId5,
|
|
|
|
|
moduleSourceId1,
|
|
|
|
|
moduleSourceId2,
|
|
|
|
|
moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
types[1].propertyDeclarations[0].typeName = Storage::ImportedType{"Object2"};
|
|
|
|
|
importsSourceId2.emplace_back("/path/to", Storage::Version{}, sourceId2);
|
2021-07-07 16:38:08 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId2, {types[1]}, {sourceId2}, {});
|
2021-07-07 16:38:08 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-07 16:38:08 +02:00
|
|
|
"QAliasItem2",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId5),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
ElementsAre(IsPropertyDeclaration(
|
|
|
|
|
"objects",
|
|
|
|
|
Storage::NativeType{"QObject2"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, UpdateAliasesAfterInjectingProperty)
|
2021-07-07 16:38:08 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithRecursiveAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1,
|
|
|
|
|
sourceId2,
|
|
|
|
|
sourceId3,
|
|
|
|
|
sourceId4,
|
|
|
|
|
sourceId5,
|
|
|
|
|
moduleSourceId1,
|
|
|
|
|
moduleSourceId2,
|
|
|
|
|
moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-07 16:38:08 +02:00
|
|
|
types[0].propertyDeclarations.push_back(
|
|
|
|
|
Storage::PropertyDeclaration{"objects",
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::ImportedType{"Item"},
|
2021-07-07 16:38:08 +02:00
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly});
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId1, {types[0]}, {sourceId1}, {});
|
2021-07-07 16:38:08 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-07 16:38:08 +02:00
|
|
|
"QAliasItem2",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId5),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
ElementsAre(IsPropertyDeclaration(
|
|
|
|
|
"objects",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, UpdateAliasesAfterChangeAliasToProperty)
|
2021-07-07 16:38:08 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithRecursiveAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1,
|
|
|
|
|
sourceId2,
|
|
|
|
|
sourceId3,
|
|
|
|
|
sourceId4,
|
|
|
|
|
sourceId5,
|
|
|
|
|
moduleSourceId1,
|
|
|
|
|
moduleSourceId2,
|
|
|
|
|
moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-07 16:38:08 +02:00
|
|
|
types[2].propertyDeclarations.clear();
|
|
|
|
|
types[2].propertyDeclarations.push_back(
|
|
|
|
|
Storage::PropertyDeclaration{"objects",
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::ImportedType{"Item"},
|
2021-07-07 16:38:08 +02:00
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly});
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId3, {types[2]}, {sourceId3}, {});
|
2021-07-07 16:38:08 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
AllOf(Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-07 16:38:08 +02:00
|
|
|
"QAliasItem2",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId5),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
ElementsAre(IsPropertyDeclaration(
|
|
|
|
|
"objects",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly,
|
|
|
|
|
"objects"))))),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-07 16:38:08 +02:00
|
|
|
"QAliasItem",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
ElementsAre(IsPropertyDeclaration(
|
|
|
|
|
"objects",
|
|
|
|
|
Storage::NativeType{"QQuickItem"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly,
|
|
|
|
|
"")))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, UpdateAliasesAfterChangePropertyToAlias)
|
2021-07-07 16:38:08 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithRecursiveAliases()};
|
|
|
|
|
types[3].propertyDeclarations[0].traits = Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly;
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1,
|
|
|
|
|
sourceId2,
|
|
|
|
|
sourceId3,
|
|
|
|
|
sourceId4,
|
|
|
|
|
sourceId5,
|
|
|
|
|
moduleSourceId1,
|
|
|
|
|
moduleSourceId2,
|
|
|
|
|
moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-07 16:38:08 +02:00
|
|
|
types[1].propertyDeclarations.clear();
|
|
|
|
|
types[1].propertyDeclarations.push_back(
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::PropertyDeclaration{"objects", Storage::ImportedType{"Object2"}, "objects"});
|
|
|
|
|
importsSourceId2.emplace_back("/path/to", Storage::Version{}, sourceId2);
|
2021-07-07 16:38:08 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId2, {types[1]}, {sourceId2}, {});
|
2021-07-07 16:38:08 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-07 16:38:08 +02:00
|
|
|
"QAliasItem2",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId5),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
ElementsAre(IsPropertyDeclaration(
|
|
|
|
|
"objects",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList
|
|
|
|
|
| Storage::PropertyDeclarationTraits::IsReadOnly,
|
|
|
|
|
"objects"))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, CheckForProtoTypeCycleThrows)
|
2021-07-15 10:21:56 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithRecursiveAliases()};
|
|
|
|
|
types[1].propertyDeclarations.clear();
|
|
|
|
|
types[1].propertyDeclarations.push_back(
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::PropertyDeclaration{"objects", Storage::ImportedType{"AliasItem2"}, "objects"});
|
|
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId2);
|
2021-07-15 10:21:56 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1,
|
|
|
|
|
sourceId2,
|
|
|
|
|
sourceId3,
|
|
|
|
|
sourceId4,
|
|
|
|
|
sourceId5,
|
|
|
|
|
moduleSourceId1,
|
|
|
|
|
moduleSourceId2,
|
|
|
|
|
moduleSourceId3},
|
|
|
|
|
{}),
|
2021-07-15 10:21:56 +02:00
|
|
|
QmlDesigner::AliasChainCycle);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, CheckForProtoTypeCycleAfterUpdateThrows)
|
2021-07-15 10:21:56 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithRecursiveAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1,
|
|
|
|
|
sourceId2,
|
|
|
|
|
sourceId3,
|
|
|
|
|
sourceId4,
|
|
|
|
|
sourceId5,
|
|
|
|
|
moduleSourceId1,
|
|
|
|
|
moduleSourceId2,
|
|
|
|
|
moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-15 10:21:56 +02:00
|
|
|
types[1].propertyDeclarations.clear();
|
|
|
|
|
types[1].propertyDeclarations.push_back(
|
2021-08-24 16:49:42 +02:00
|
|
|
Storage::PropertyDeclaration{"objects", Storage::ImportedType{"AliasItem2"}, "objects"});
|
|
|
|
|
importsSourceId2.emplace_back("QtQuick", Storage::Version{}, sourceId2);
|
2021-07-15 10:21:56 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize({}, importsSourceId2, {types[1]}, {sourceId2}, {}),
|
2021-08-03 15:03:36 +02:00
|
|
|
QmlDesigner::AliasChainCycle);
|
2021-07-15 10:21:56 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, QualifiedPrototype)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].prototype = Storage::QualifiedImportedType{"Object",
|
|
|
|
|
Storage::Import{"Qml",
|
|
|
|
|
Storage::Version{},
|
|
|
|
|
sourceId1}};
|
2021-08-24 11:53:15 +02:00
|
|
|
types.push_back(Storage::Type{Storage::Module{"QtQuick"},
|
2021-07-22 17:26:53 +02:00
|
|
|
"QQuickObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3,
|
|
|
|
|
{Storage::ExportedType{"Object"}}});
|
2021-08-24 16:49:42 +02:00
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId3);
|
2021-07-22 17:26:53 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-22 17:26:53 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-22 17:26:53 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1)));
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, QualifiedPrototypeUpperDownTheModuleChainThrows)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].prototype = Storage::QualifiedImportedType{"Object",
|
|
|
|
|
Storage::Import{"QtQuick",
|
|
|
|
|
Storage::Version{},
|
|
|
|
|
sourceId1}};
|
2021-07-22 17:26:53 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{}),
|
2021-07-22 17:26:53 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, QualifiedPrototypeUpperInTheModuleChain)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].prototype = Storage::QualifiedImportedType{"Object",
|
|
|
|
|
Storage::Import{"QtQuick",
|
|
|
|
|
Storage::Version{},
|
|
|
|
|
sourceId1}};
|
2021-08-24 11:53:15 +02:00
|
|
|
types.push_back(Storage::Type{Storage::Module{"QtQuick"},
|
2021-07-22 17:26:53 +02:00
|
|
|
"QQuickObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3,
|
|
|
|
|
{Storage::ExportedType{"Object"}}});
|
2021-08-24 16:49:42 +02:00
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId3);
|
2021-07-22 17:26:53 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-22 17:26:53 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-22 17:26:53 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QQuickObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1)));
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, QualifiedPrototypeWithWrongVersionThrows)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].prototype = Storage::QualifiedImportedType{"Object",
|
|
|
|
|
Storage::Import{"Qml",
|
|
|
|
|
Storage::Version{4},
|
|
|
|
|
sourceId1}};
|
2021-08-24 11:53:15 +02:00
|
|
|
types.push_back(Storage::Type{Storage::Module{"QtQuick"},
|
2021-07-22 17:26:53 +02:00
|
|
|
"QQuickObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3,
|
|
|
|
|
{Storage::ExportedType{"Object"}}});
|
2021-08-24 16:49:42 +02:00
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId3);
|
2021-07-22 17:26:53 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{}),
|
2021-07-22 17:26:53 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, QualifiedPrototypeWithVersion)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
imports[0].version = Storage::Version{2};
|
|
|
|
|
types[0].prototype = Storage::QualifiedImportedType{"Object", imports[0]};
|
2021-08-24 11:53:15 +02:00
|
|
|
types.push_back(Storage::Type{Storage::Module{"QtQuick"},
|
2021-07-22 17:26:53 +02:00
|
|
|
"QQuickObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3,
|
|
|
|
|
{Storage::ExportedType{"Object"}}});
|
2021-08-24 16:49:42 +02:00
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId3);
|
2021-07-22 17:26:53 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-22 17:26:53 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-22 17:26:53 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1)));
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, QualifiedPrototypeWithVersionInTheProtoTypeChain)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
imports[2].version = Storage::Version{2};
|
|
|
|
|
types[0].prototype = Storage::QualifiedImportedType{"Object", imports[2]};
|
|
|
|
|
types[0].exportedTypes[0].version = Storage::Version{2};
|
2021-08-24 11:53:15 +02:00
|
|
|
types.push_back(Storage::Type{Storage::Module{"QtQuick"},
|
2021-07-22 17:26:53 +02:00
|
|
|
"QQuickObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3,
|
2021-08-24 16:49:42 +02:00
|
|
|
{Storage::ExportedType{"Object", Storage::Version{2}}}});
|
|
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId3);
|
2021-07-22 17:26:53 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
2021-07-22 17:26:53 +02:00
|
|
|
types,
|
2021-08-24 16:49:42 +02:00
|
|
|
{sourceId1, sourceId2, sourceId3, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
2021-08-03 15:03:36 +02:00
|
|
|
{});
|
2021-07-22 17:26:53 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 16:49:42 +02:00
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-22 17:26:53 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QQuickObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1)));
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, QualifiedPrototypeWithVersionDownTheProtoTypeChainThrows)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].prototype = Storage::QualifiedImportedType{"Object",
|
|
|
|
|
Storage::Import{"QtQuick",
|
|
|
|
|
Storage::Version{2},
|
|
|
|
|
sourceId1}};
|
2021-07-22 17:26:53 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{}),
|
2021-07-22 17:26:53 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, QualifiedPropertyDeclarationTypeName)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::QualifiedImportedType{
|
|
|
|
|
"Object", Storage::Import{"Qml", Storage::Version{}, sourceId1}};
|
2021-08-24 11:53:15 +02:00
|
|
|
types.push_back(Storage::Type{Storage::Module{"QtQuick"},
|
2021-07-22 17:26:53 +02:00
|
|
|
"QQuickObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3,
|
|
|
|
|
{Storage::ExportedType{"Object"}}});
|
2021-08-24 16:49:42 +02:00
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId3);
|
2021-07-22 17:26:53 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-22 17:26:53 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
Contains(IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList)))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, QualifiedPropertyDeclarationTypeNameDownTheModuleChainThrows)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::QualifiedImportedType{
|
|
|
|
|
"Object", Storage::Import{"QtQuick", Storage::Version{}, sourceId1}};
|
2021-07-22 17:26:53 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{}),
|
2021-07-22 17:26:53 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, QualifiedPropertyDeclarationTypeNameInTheModuleChain)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::QualifiedImportedType{
|
|
|
|
|
"Object", Storage::Import{"QtQuick", Storage::Version{}, sourceId1}};
|
2021-08-24 11:53:15 +02:00
|
|
|
types.push_back(Storage::Type{Storage::Module{"QtQuick"},
|
2021-07-22 17:26:53 +02:00
|
|
|
"QQuickObject",
|
|
|
|
|
Storage::NativeType{},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId3,
|
|
|
|
|
{Storage::ExportedType{"Object"}}});
|
2021-08-24 16:49:42 +02:00
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId3);
|
2021-07-22 17:26:53 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-22 17:26:53 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
Contains(IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QQuickObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList)))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, QualifiedPropertyDeclarationTypeNameWithVersion)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::QualifiedImportedType{
|
|
|
|
|
"Object", Storage::Import{"Qml", Storage::Version{2}, sourceId1}};
|
|
|
|
|
imports.emplace_back("Qml", Storage::Version{2}, sourceId1);
|
2021-07-22 17:26:53 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-07-22 17:26:53 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
Contains(IsPropertyDeclaration("data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList)))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, ChangePropertyTypeModuleIdWithQualifiedTypeThrows)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::QualifiedImportedType{
|
|
|
|
|
"Object", Storage::Import{"Qml", Storage::Version{}, sourceId1}};
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-08-24 11:53:15 +02:00
|
|
|
types[1].module = Storage::Module{"QtQuick"};
|
2021-07-22 17:26:53 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
ASSERT_THROW(storage.synchronize({}, importsSourceId2, {types[1]}, {sourceId2}, {}),
|
2021-07-22 17:26:53 +02:00
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, ChangePropertyTypeModuleIdWithQualifiedType)
|
2021-07-22 17:26:53 +02:00
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypes()};
|
2021-08-24 16:49:42 +02:00
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::QualifiedImportedType{
|
|
|
|
|
"Object", Storage::Import{"Qml", Storage::Version{}, sourceId1}};
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
types[0].propertyDeclarations[0].typeName = Storage::QualifiedImportedType{
|
|
|
|
|
"Object", Storage::Import{"QtQuick", Storage::Version{}, sourceId1}};
|
2021-08-24 11:53:15 +02:00
|
|
|
types[1].module = Storage::Module{"QtQuick"};
|
2021-08-24 16:49:42 +02:00
|
|
|
imports.emplace_back("QtQuick", Storage::Version{}, sourceId2);
|
2021-07-22 17:26:53 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, imports, types, {sourceId1, sourceId2}, {});
|
2021-07-22 17:26:53 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"QtQuick"},
|
2021-07-22 17:26:53 +02:00
|
|
|
"QQuickItem",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1),
|
|
|
|
|
Field(&Storage::Type::propertyDeclarations,
|
|
|
|
|
Contains(IsPropertyDeclaration(
|
|
|
|
|
"data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, AddFileStatuses)
|
2021-08-03 15:03:36 +02:00
|
|
|
{
|
|
|
|
|
FileStatus fileStatus1{sourceId1, 100, 100};
|
|
|
|
|
FileStatus fileStatus2{sourceId2, 101, 101};
|
|
|
|
|
|
|
|
|
|
storage.synchronize({}, {}, {}, {sourceId1, sourceId2}, {fileStatus1, fileStatus2});
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(convert(storage.fetchAllFileStatuses()),
|
|
|
|
|
UnorderedElementsAre(fileStatus1, fileStatus2));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, RemoveFileStatus)
|
2021-08-03 15:03:36 +02:00
|
|
|
{
|
|
|
|
|
FileStatus fileStatus1{sourceId1, 100, 100};
|
|
|
|
|
FileStatus fileStatus2{sourceId2, 101, 101};
|
|
|
|
|
storage.synchronize({}, {}, {}, {sourceId1, sourceId2}, {fileStatus1, fileStatus2});
|
|
|
|
|
|
|
|
|
|
storage.synchronize({}, {}, {}, {sourceId1, sourceId2}, {fileStatus1});
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(convert(storage.fetchAllFileStatuses()), UnorderedElementsAre(fileStatus1));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, UpdateFileStatus)
|
2021-08-03 15:03:36 +02:00
|
|
|
{
|
|
|
|
|
FileStatus fileStatus1{sourceId1, 100, 100};
|
|
|
|
|
FileStatus fileStatus2{sourceId2, 101, 101};
|
|
|
|
|
FileStatus fileStatus2b{sourceId2, 102, 102};
|
|
|
|
|
storage.synchronize({}, {}, {}, {sourceId1, sourceId2}, {fileStatus1, fileStatus2});
|
|
|
|
|
|
|
|
|
|
storage.synchronize({}, {}, {}, {sourceId1, sourceId2}, {fileStatus1, fileStatus2b});
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(convert(storage.fetchAllFileStatuses()),
|
|
|
|
|
UnorderedElementsAre(fileStatus1, fileStatus2b));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, ThrowForInvalidSourceId)
|
2021-08-03 15:03:36 +02:00
|
|
|
{
|
|
|
|
|
FileStatus fileStatus1{SourceId{}, 100, 100};
|
|
|
|
|
|
|
|
|
|
ASSERT_THROW(storage.synchronize({}, {}, {}, {sourceId1}, {fileStatus1}),
|
|
|
|
|
Sqlite::ConstraintPreventsModification);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchAllFileStatuses)
|
2021-08-03 17:13:29 +02:00
|
|
|
{
|
|
|
|
|
FileStatus fileStatus1{sourceId1, 100, 100};
|
|
|
|
|
FileStatus fileStatus2{sourceId2, 101, 101};
|
|
|
|
|
storage.synchronize({}, {}, {}, {sourceId1, sourceId2}, {fileStatus1, fileStatus2});
|
|
|
|
|
|
|
|
|
|
auto fileStatuses = convert(storage.fetchAllFileStatuses());
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(fileStatuses, ElementsAre(fileStatus1, fileStatus2));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchAllFileStatusesReverse)
|
2021-08-03 17:13:29 +02:00
|
|
|
{
|
|
|
|
|
FileStatus fileStatus1{sourceId1, 100, 100};
|
|
|
|
|
FileStatus fileStatus2{sourceId2, 101, 101};
|
|
|
|
|
storage.synchronize({}, {}, {}, {sourceId1, sourceId2}, {fileStatus2, fileStatus1});
|
|
|
|
|
|
|
|
|
|
auto fileStatuses = convert(storage.fetchAllFileStatuses());
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(fileStatuses, ElementsAre(fileStatus1, fileStatus2));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:19:56 +02:00
|
|
|
TEST_F(ProjectStorage, FetchFileStatus)
|
|
|
|
|
{
|
|
|
|
|
FileStatus fileStatus1{sourceId1, 100, 100};
|
|
|
|
|
FileStatus fileStatus2{sourceId2, 101, 101};
|
|
|
|
|
storage.synchronize({}, {}, {}, {sourceId1, sourceId2}, {fileStatus1, fileStatus2});
|
|
|
|
|
|
|
|
|
|
auto fileStatus = storage.fetchFileStatus(sourceId1);
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(fileStatus, Eq(fileStatus1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, SynchronizeTypesWithoutTypeName)
|
|
|
|
|
{
|
|
|
|
|
Storage::Types types{createTypesWithAliases()};
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize(
|
|
|
|
|
modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, sourceId3, sourceId4, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
2021-09-16 17:19:56 +02:00
|
|
|
types[3].typeName.clear();
|
2021-08-24 11:53:15 +02:00
|
|
|
types[3].module.name.clear();
|
2021-08-24 16:49:42 +02:00
|
|
|
types[3].prototype = Storage::ImportedType{"Object"};
|
2021-09-16 17:19:56 +02:00
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
storage.synchronize({}, importsSourceId4, {types[3]}, {sourceId4}, {});
|
2021-09-16 17:19:56 +02:00
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
2021-08-24 11:53:15 +02:00
|
|
|
Contains(AllOf(IsStorageType(Storage::Module{"/path/to"},
|
2021-09-16 17:19:56 +02:00
|
|
|
"QObject2",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId4),
|
|
|
|
|
Field(&Storage::Type::exportedTypes,
|
|
|
|
|
UnorderedElementsAre(IsExportedType("Object2"),
|
|
|
|
|
IsExportedType("Obj2"))))));
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 16:49:42 +02:00
|
|
|
TEST_F(ProjectStorage, FetchByMajorVersionForImportedType)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::ImportedType{"Object"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{1}, sourceId2};
|
|
|
|
|
|
|
|
|
|
storage.synchronize({}, {import}, {type}, {sourceId2}, {});
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, FetchByMajorVersionForQualifiedImportedType)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{1}, sourceId2};
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::QualifiedImportedType{"Object", import},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
|
|
|
|
|
storage.synchronize({}, {import}, {type}, {sourceId2}, {});
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, FetchByMajorVersionAndMinorVersionForImportedType)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::ImportedType{"Obj"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{1, 2}, sourceId2};
|
|
|
|
|
|
|
|
|
|
storage.synchronize({}, {import}, {type}, {sourceId2}, {});
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, FetchByMajorVersionAndMinorVersionForQualifiedImportedType)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{1, 2}, sourceId2};
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::QualifiedImportedType{"Obj", import},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
|
|
|
|
|
storage.synchronize({}, {import}, {type}, {sourceId2}, {});
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage,
|
|
|
|
|
FetchByMajorVersionAndMinorVersionForImportedTypeIfMinorVersionIsNotExportedThrows)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::ImportedType{"Object"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{1, 1}, sourceId2};
|
|
|
|
|
|
|
|
|
|
ASSERT_THROW(storage.synchronize({}, {import}, {type}, {sourceId2}, {}),
|
|
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage,
|
|
|
|
|
FetchByMajorVersionAndMinorVersionForQualifiedImportedTypeIfMinorVersionIsNotExportedThrows)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{1, 1}, sourceId2};
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::QualifiedImportedType{"Object", import},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
|
|
|
|
|
ASSERT_THROW(storage.synchronize({}, {import}, {type}, {sourceId2}, {}),
|
|
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, FetchLowMinorVersionForImportedTypeThrows)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::ImportedType{"Obj"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{1, 1}, sourceId2};
|
|
|
|
|
|
|
|
|
|
ASSERT_THROW(storage.synchronize({}, {import}, {type}, {sourceId2}, {}),
|
|
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, FetchLowMinorVersionForQualifiedImportedTypeThrows)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{1, 1}, sourceId2};
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::QualifiedImportedType{"Obj", import},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
|
|
|
|
|
ASSERT_THROW(storage.synchronize({}, {import}, {type}, {sourceId2}, {}),
|
|
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, FetchHigherMinorVersionForImportedType)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::ImportedType{"Obj"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{1, 3}, sourceId2};
|
|
|
|
|
|
|
|
|
|
storage.synchronize({}, {import}, {type}, {sourceId2}, {});
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, FetchHigherMinorVersionForQualifiedImportedType)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{1, 3}, sourceId2};
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::QualifiedImportedType{"Obj", import},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
|
|
|
|
|
storage.synchronize({}, {import}, {type}, {sourceId2}, {});
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, FetchDifferentMajorVersionForImportedTypeThrows)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::ImportedType{"Obj"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{3, 1}, sourceId2};
|
|
|
|
|
|
|
|
|
|
ASSERT_THROW(storage.synchronize({}, {import}, {type}, {sourceId2}, {}),
|
|
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, FetchDifferentMajorVersionForQualifiedImportedTypeThrows)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{3, 1}, sourceId2};
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::QualifiedImportedType{"Obj", import},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
|
|
|
|
|
ASSERT_THROW(storage.synchronize({}, {import}, {type}, {sourceId2}, {}),
|
|
|
|
|
QmlDesigner::TypeNameDoesNotExists);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, FetchOtherTypeByDifferentVersionForImportedType)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::ImportedType{"Obj"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{2, 3}, sourceId2};
|
|
|
|
|
|
|
|
|
|
storage.synchronize({}, {import}, {type}, {sourceId2}, {});
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::NativeType{"QObject2"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, FetchOtherTypeByDifferentVersionForQualifiedImportedType)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{2, 3}, sourceId2};
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::QualifiedImportedType{"Obj", import},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
|
|
|
|
|
storage.synchronize({}, {import}, {type}, {sourceId2}, {});
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::NativeType{"QObject2"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, FetchHighestVersionForImportWithoutVersionForImportedType)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::ImportedType{"Obj"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{}, sourceId2};
|
|
|
|
|
|
|
|
|
|
storage.synchronize({}, {import}, {type}, {sourceId2}, {});
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::NativeType{"QObject4"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, FetchHighestVersionForImportWithoutVersionForQualifiedImportedType)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{}, sourceId2};
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::QualifiedImportedType{"Obj", import},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
|
|
|
|
|
storage.synchronize({}, {import}, {type}, {sourceId2}, {});
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::NativeType{"QObject4"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, FetchHighestVersionForImportWithMajorVersionForImportedType)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::ImportedType{"Obj"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{2}, sourceId2};
|
|
|
|
|
|
|
|
|
|
storage.synchronize({}, {import}, {type}, {sourceId2}, {});
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::NativeType{"QObject3"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, FetchHighestVersionForImportWithMajorVersionForQualifiedImportedType)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{2}, sourceId2};
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::QualifiedImportedType{"Obj", import},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
|
|
|
|
|
storage.synchronize({}, {import}, {type}, {sourceId2}, {});
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::NativeType{"QObject3"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, FetchExportedTypeWithoutVersionFirstForImportedType)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::ImportedType{"BuiltInObj"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{}, sourceId2};
|
|
|
|
|
|
|
|
|
|
storage.synchronize({}, {import}, {type}, {sourceId2}, {});
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, FetchExportedTypeWithoutVersionFirstForQualifiedImportedType)
|
|
|
|
|
{
|
|
|
|
|
auto types = createVersionedTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{}, sourceId2};
|
|
|
|
|
Storage::Type type{Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::QualifiedImportedType{"BuiltInObj", import},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2,
|
|
|
|
|
{Storage::ExportedType{"Item", Storage::Version{}}}};
|
|
|
|
|
|
|
|
|
|
storage.synchronize({}, {import}, {type}, {sourceId2}, {});
|
|
|
|
|
|
|
|
|
|
ASSERT_THAT(storage.fetchTypes(),
|
|
|
|
|
Contains(IsStorageType(Storage::Module{"QtQuick"},
|
|
|
|
|
"Item",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId2)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, EnsureThatPropertiesForRemovedTypesAreNotAnymoreRelinked)
|
|
|
|
|
{
|
|
|
|
|
Storage::Type type{Storage::Module{"Qml"},
|
|
|
|
|
"QObject",
|
|
|
|
|
Storage::NativeType{""},
|
|
|
|
|
TypeAccessSemantics::Reference,
|
|
|
|
|
sourceId1,
|
|
|
|
|
{Storage::ExportedType{"Object", Storage::Version{}}},
|
|
|
|
|
{Storage::PropertyDeclaration{"data",
|
|
|
|
|
Storage::NativeType{"QObject"},
|
|
|
|
|
Storage::PropertyDeclarationTraits::IsList}}};
|
|
|
|
|
Storage::Import import{"Qml", Storage::Version{}, sourceId1};
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
{import},
|
|
|
|
|
{type},
|
|
|
|
|
{sourceId1, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(storage.synchronize({}, {}, {}, {sourceId1}, {}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ProjectStorage, EnsureThatPrototypesForRemovedTypesAreNotAnymoreRelinked)
|
|
|
|
|
{
|
|
|
|
|
auto types = createTypes();
|
|
|
|
|
storage.synchronize(modules,
|
|
|
|
|
imports,
|
|
|
|
|
types,
|
|
|
|
|
{sourceId1, sourceId2, moduleSourceId1, moduleSourceId2, moduleSourceId3},
|
|
|
|
|
{});
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(storage.synchronize({}, {}, {}, {sourceId1, sourceId2}, {}));
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-28 16:18:59 +02:00
|
|
|
} // namespace
|