QmlDesigner: Introduce origin flags

metaInfo.isProjectComponent() is signaling if a file component is
directly part of the project. metaInfo.isInProjectModule() otherwise
shows if a type is inside of the project as a qmldir module. Both cannot
be true. If a type is not part of either it is a system type.

Task-number: QDS-10251
Change-Id: Iae2270827a500ad6393e3751b3af276f9b030679
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2023-07-06 13:16:34 +02:00
parent e1171359ab
commit 8ab4968278
4 changed files with 89 additions and 1 deletions
@@ -155,6 +155,72 @@ TEST_F(NodeMetaInfo, component_is_file_component)
ASSERT_TRUE(isFileComponent);
}
TEST_F(NodeMetaInfo, is_project_component)
{
using QmlDesigner::Storage::TypeTraits;
auto moduleId = projectStorageMock.createModule("/path/to/project");
auto typeId = projectStorageMock.createType(moduleId, "Foo", TypeTraits::IsProjectComponent);
QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock};
bool isProjectComponent = metaInfo.isProjectComponent();
ASSERT_TRUE(isProjectComponent);
}
TEST_F(NodeMetaInfo, is_not_project_component)
{
using QmlDesigner::Storage::TypeTraits;
auto moduleId = projectStorageMock.createModule("/path/to/project");
auto typeId = projectStorageMock.createType(moduleId, "Foo", {});
QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock};
bool isProjectComponent = metaInfo.isProjectComponent();
ASSERT_FALSE(isProjectComponent);
}
TEST_F(NodeMetaInfo, invalid_is_not_project_component)
{
QmlDesigner::NodeMetaInfo metaInfo;
bool isProjectComponent = metaInfo.isProjectComponent();
ASSERT_FALSE(isProjectComponent);
}
TEST_F(NodeMetaInfo, is_in_project_module)
{
using QmlDesigner::Storage::TypeTraits;
auto moduleId = projectStorageMock.createModule("/path/to/project");
auto typeId = projectStorageMock.createType(moduleId, "Foo", TypeTraits::IsInProjectModule);
QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock};
bool isInProjectModule = metaInfo.isInProjectModule();
ASSERT_TRUE(isInProjectModule);
}
TEST_F(NodeMetaInfo, is_not_in_project_module)
{
using QmlDesigner::Storage::TypeTraits;
auto moduleId = projectStorageMock.createModule("/path/to/project");
auto typeId = projectStorageMock.createType(moduleId, "Foo", {});
QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock};
bool isInProjectModule = metaInfo.isInProjectModule();
ASSERT_FALSE(isInProjectModule);
}
TEST_F(NodeMetaInfo, invalid_is_not_in_project_module)
{
QmlDesigner::NodeMetaInfo metaInfo;
bool isInProjectModule = metaInfo.isInProjectModule();
ASSERT_FALSE(isInProjectModule);
}
TEST_F(NodeMetaInfo, has_property)
{
auto node = model.createModelNode("Item");