forked from qt-creator/qt-creator
UnitTests: Refactor parse qml types
Change-Id: I668bf93e0e0c8cca099d4a19010d01be46422910 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -588,16 +588,34 @@ TEST_F(ProjectStorageUpdater_get_content_for_qml_types, removed_qml_types_file_n
|
|||||||
updater.update({.qtDirectories = directories});
|
updater.update({.qtDirectories = directories});
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectStorageUpdater, parse_qml_types)
|
class ProjectStorageUpdater_parse_qml_types : public BaseProjectStorageUpdater
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
ProjectStorageUpdater_parse_qml_types()
|
||||||
|
{
|
||||||
QString qmldir{R"(module Example
|
QString qmldir{R"(module Example
|
||||||
typeinfo example.qmltypes
|
typeinfo example.qmltypes
|
||||||
typeinfo example2.qmltypes)"};
|
typeinfo example2.qmltypes)"};
|
||||||
setContent(u"/path/qmldir", qmldir);
|
setContent(u"/root/path/qmldir", qmldir);
|
||||||
|
setContent(u"/root/path/example.qmltypes", qmltypes);
|
||||||
|
setContent(u"/root/path/example2.qmltypes", qmltypes2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
QString qmltypes{"Module {\ndependencies: []}"};
|
QString qmltypes{"Module {\ndependencies: []}"};
|
||||||
QString qmltypes2{"Module {\ndependencies: [foo]}"};
|
QString qmltypes2{"Module {\ndependencies: [foo]}"};
|
||||||
setContent(u"/path/example.qmltypes", qmltypes);
|
ModuleId exampleCppNativeModuleId{storage.moduleId("Example", ModuleKind::CppLibrary)};
|
||||||
setContent(u"/path/example2.qmltypes", qmltypes2);
|
SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/root/path/example.qmltypes");
|
||||||
|
SourceId qmltypes2PathSourceId = sourcePathCache.sourceId("/root/path/example2.qmltypes");
|
||||||
|
SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/root/path/qmldir");
|
||||||
|
SourceContextId directoryPathId = qmlDirPathSourceId.contextId();
|
||||||
|
SourceId directoryPathSourceId = SourceId::create(QmlDesigner::SourceNameId{}, directoryPathId);
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(ProjectStorageUpdater_parse_qml_types, add_directory)
|
||||||
|
{
|
||||||
|
setFilesAdded(
|
||||||
|
{directoryPathSourceId, qmlDirPathSourceId, qmltypesPathSourceId, qmltypes2PathSourceId});
|
||||||
|
|
||||||
EXPECT_CALL(qmlTypesParserMock,
|
EXPECT_CALL(qmlTypesParserMock,
|
||||||
parse(qmltypes,
|
parse(qmltypes,
|
||||||
@@ -612,25 +630,17 @@ TEST_F(ProjectStorageUpdater, parse_qml_types)
|
|||||||
Field("DirectoryInfo::moduleId", &DirectoryInfo::moduleId, exampleCppNativeModuleId),
|
Field("DirectoryInfo::moduleId", &DirectoryInfo::moduleId, exampleCppNativeModuleId),
|
||||||
IsInsideProject::No));
|
IsInsideProject::No));
|
||||||
|
|
||||||
updater.update({.qtDirectories = directories});
|
updater.update({.qtDirectories = {"/root/path"}});
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectStorageUpdater, parse_added_qml_types)
|
TEST_F(ProjectStorageUpdater_parse_qml_types, add_qmltypes)
|
||||||
{
|
{
|
||||||
QString qmldir{R"(module Example
|
setDirectoryInfos(
|
||||||
typeinfo example.qmltypes
|
directoryPathId,
|
||||||
typeinfo example2.qmltypes)"};
|
{{directoryPathId, qmltypesPathSourceId, exampleCppNativeModuleId, FileType::QmlTypes},
|
||||||
setContent(u"/path/qmldir", qmldir);
|
{directoryPathId, qmltypes2PathSourceId, exampleCppNativeModuleId, FileType::QmlTypes}});
|
||||||
QString qmltypes{"Module {\ndependencies: []}"};
|
setFilesUnchanged({directoryPathSourceId, qmlDirPathSourceId});
|
||||||
QString qmltypes2{"Module {\ndependencies: [foo]}"};
|
setFilesAdded({qmltypesPathSourceId, qmltypes2PathSourceId});
|
||||||
setContent(u"/path/example.qmltypes", qmltypes);
|
|
||||||
setContent(u"/path/example2.qmltypes", qmltypes2);
|
|
||||||
setFilesAdded({directoryPathSourceId,
|
|
||||||
qmlDirPathSourceId,
|
|
||||||
qmltypesPathSourceId,
|
|
||||||
qmltypes2PathSourceId,
|
|
||||||
qmlDocumentSourceId2,
|
|
||||||
qmlDocumentSourceId3});
|
|
||||||
|
|
||||||
EXPECT_CALL(qmlTypesParserMock,
|
EXPECT_CALL(qmlTypesParserMock,
|
||||||
parse(qmltypes,
|
parse(qmltypes,
|
||||||
@@ -645,32 +655,13 @@ TEST_F(ProjectStorageUpdater, parse_added_qml_types)
|
|||||||
Field("DirectoryInfo::moduleId", &DirectoryInfo::moduleId, exampleCppNativeModuleId),
|
Field("DirectoryInfo::moduleId", &DirectoryInfo::moduleId, exampleCppNativeModuleId),
|
||||||
IsInsideProject::No));
|
IsInsideProject::No));
|
||||||
|
|
||||||
updater.update({.qtDirectories = directories});
|
updater.update({.qtDirectories = {"/root/path"}});
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectStorageUpdater, parse_qml_types_in_project)
|
TEST_F(ProjectStorageUpdater_parse_qml_types, add_directory_inide_project)
|
||||||
{
|
{
|
||||||
QString qmldir{R"(module Example
|
setFilesAdded(
|
||||||
typeinfo example.qmltypes)"};
|
{directoryPathSourceId, qmlDirPathSourceId, qmltypesPathSourceId, qmltypes2PathSourceId});
|
||||||
setContent(u"/path/qmldir", qmldir);
|
|
||||||
QString qmltypes{"Module {\ndependencies: []}"};
|
|
||||||
setContent(u"/path/example.qmltypes", qmltypes);
|
|
||||||
|
|
||||||
EXPECT_CALL(qmlTypesParserMock, parse(qmltypes, _, _, _, IsInsideProject::Yes));
|
|
||||||
|
|
||||||
updater.update({.projectDirectory = "/path"});
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(ProjectStorageUpdater, parse_qml_types_inside_project)
|
|
||||||
{
|
|
||||||
QString qmldir{R"(module Example
|
|
||||||
typeinfo example.qmltypes
|
|
||||||
typeinfo example2.qmltypes)"};
|
|
||||||
setContent(u"/path/qmldir", qmldir);
|
|
||||||
QString qmltypes{"Module {\ndependencies: []}"};
|
|
||||||
QString qmltypes2{"Module {\ndependencies: [foo]}"};
|
|
||||||
setContent(u"/path/example.qmltypes", qmltypes);
|
|
||||||
setContent(u"/path/example2.qmltypes", qmltypes2);
|
|
||||||
|
|
||||||
EXPECT_CALL(qmlTypesParserMock,
|
EXPECT_CALL(qmlTypesParserMock,
|
||||||
parse(qmltypes,
|
parse(qmltypes,
|
||||||
@@ -685,21 +676,14 @@ TEST_F(ProjectStorageUpdater, parse_qml_types_inside_project)
|
|||||||
Field("DirectoryInfo::moduleId", &DirectoryInfo::moduleId, exampleCppNativeModuleId),
|
Field("DirectoryInfo::moduleId", &DirectoryInfo::moduleId, exampleCppNativeModuleId),
|
||||||
IsInsideProject::Yes));
|
IsInsideProject::Yes));
|
||||||
|
|
||||||
updater.update({.projectDirectory = "/path"});
|
updater.update({.projectDirectory = "/root/path"});
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectStorageUpdater, parse_qml_types_in_subdirectories)
|
TEST_F(ProjectStorageUpdater_parse_qml_types, add_subdirectories)
|
||||||
{
|
{
|
||||||
QString qmldir{R"(module Example
|
setFilesAdded(
|
||||||
typeinfo example.qmltypes
|
{directoryPathSourceId, qmlDirPathSourceId, qmltypesPathSourceId, qmltypes2PathSourceId});
|
||||||
typeinfo example2.qmltypes)"};
|
setSubdirectoryPaths(u"/root", {"/root/path"});
|
||||||
setContent(u"/path/qmldir", qmldir);
|
|
||||||
QString qmltypes{"Module {\ndependencies: []}"};
|
|
||||||
QString qmltypes2{"Module {\ndependencies: [foo]}"};
|
|
||||||
setContent(u"/path/example.qmltypes", qmltypes);
|
|
||||||
setContent(u"/path/example2.qmltypes", qmltypes2);
|
|
||||||
QStringList directories = {"/root"};
|
|
||||||
setSubdirectoryPaths(u"/root", {"/path"});
|
|
||||||
|
|
||||||
EXPECT_CALL(qmlTypesParserMock,
|
EXPECT_CALL(qmlTypesParserMock,
|
||||||
parse(qmltypes,
|
parse(qmltypes,
|
||||||
@@ -714,7 +698,7 @@ TEST_F(ProjectStorageUpdater, parse_qml_types_in_subdirectories)
|
|||||||
Field("DirectoryInfo::moduleId", &DirectoryInfo::moduleId, exampleCppNativeModuleId),
|
Field("DirectoryInfo::moduleId", &DirectoryInfo::moduleId, exampleCppNativeModuleId),
|
||||||
IsInsideProject::No));
|
IsInsideProject::No));
|
||||||
|
|
||||||
updater.update({.qtDirectories = directories});
|
updater.update({.qtDirectories = {"/root"}});
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectStorageUpdater, synchronize_is_empty_for_no_change)
|
TEST_F(ProjectStorageUpdater, synchronize_is_empty_for_no_change)
|
||||||
|
Reference in New Issue
Block a user