forked from qt-creator/qt-creator
QmlDesigner: Parameterize project storage watcher updater test
Using parameters allows for generating more test combinations. This reduces the amount of test code needed while increasing coverage. However, it can also make the test logic more complex. Fixes: QDS-15280 Change-Id: Iccc018903be4baf0e8e40581c8ae166a529be730 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -413,6 +413,7 @@ std::string_view directoryName(std::string_view directoryPath)
|
||||
|
||||
void ProjectStorageUpdater::updateDirectoryChanged(Utils::SmallStringView directoryPath,
|
||||
Utils::SmallStringView annotationDirectoryPath,
|
||||
FileState directoryState,
|
||||
FileState qmldirState,
|
||||
FileState annotationDirectoryState,
|
||||
SourcePath qmldirSourcePath,
|
||||
@@ -466,6 +467,7 @@ void ProjectStorageUpdater::updateDirectoryChanged(Utils::SmallStringView direct
|
||||
toImportNames(imports),
|
||||
directoryId,
|
||||
directoryPathAsQString,
|
||||
directoryState,
|
||||
cppModuleId,
|
||||
package,
|
||||
notUpdatedSourceIds,
|
||||
@@ -481,10 +483,12 @@ void ProjectStorageUpdater::updateDirectoryChanged(Utils::SmallStringView direct
|
||||
package,
|
||||
notUpdatedSourceIds,
|
||||
WatchedSourceIds,
|
||||
directoryState,
|
||||
qmldirState,
|
||||
qmldirSourceId,
|
||||
isInsideProject);
|
||||
tracer.tick("append updated directory source id", keyValue("module id", moduleId));
|
||||
if (isChanged(directoryState))
|
||||
package.updatedDirectoryInfoDirectoryIds.push_back(directoryId);
|
||||
|
||||
if (isInsideProject == IsInsideProject::Yes) {
|
||||
@@ -689,6 +693,7 @@ void ProjectStorageUpdater::updateDirectory(const Utils::PathString &directoryPa
|
||||
tracer.tick("update directory changed");
|
||||
updateDirectoryChanged(directoryPath,
|
||||
annotationDirectoryPath,
|
||||
directoryState,
|
||||
qmldirState,
|
||||
annotationDirectoryState,
|
||||
qmldirPath,
|
||||
@@ -1027,6 +1032,7 @@ void ProjectStorageUpdater::pathsWithIdsChanged(const std::vector<IdPaths> &chan
|
||||
category(),
|
||||
keyValue("id paths", changedIdPaths)};
|
||||
|
||||
try {
|
||||
m_changedIdPaths.insert(m_changedIdPaths.end(), changedIdPaths.begin(), changedIdPaths.end());
|
||||
|
||||
Storage::Synchronization::SynchronizationPackage package;
|
||||
@@ -1048,7 +1054,8 @@ void ProjectStorageUpdater::pathsWithIdsChanged(const std::vector<IdPaths> &chan
|
||||
}
|
||||
|
||||
auto updateDirectory = [&](const SourceIds &directorySourceIds,
|
||||
WatchedSourceIds &watchedSourceIds) {
|
||||
WatchedSourceIds &watchedSourceIds,
|
||||
IsInsideProject isInsideProject) {
|
||||
auto directoryIds = filterUniqueDirectoryPathIds(directorySourceIds);
|
||||
for (auto directoryId : directoryIds) {
|
||||
Utils::PathString directory = m_pathCache.directoryPath(directoryId);
|
||||
@@ -1057,14 +1064,16 @@ void ProjectStorageUpdater::pathsWithIdsChanged(const std::vector<IdPaths> &chan
|
||||
package,
|
||||
notUpdatedSourceIds,
|
||||
watchedSourceIds,
|
||||
IsInsideProject::No);
|
||||
isInsideProject);
|
||||
}
|
||||
|
||||
return directoryIds;
|
||||
};
|
||||
|
||||
auto qtDirectoryIds = updateDirectory(qt.directory, watchedQtSourceIds);
|
||||
auto projectDirectoryIds = updateDirectory(project.directory, watchedProjectSourceIds);
|
||||
auto qtDirectoryIds = updateDirectory(qt.directory, watchedQtSourceIds, IsInsideProject::No);
|
||||
auto projectDirectoryIds = updateDirectory(project.directory,
|
||||
watchedProjectSourceIds,
|
||||
IsInsideProject::Yes);
|
||||
|
||||
auto parseQmlComponent = [&](SourceIds qmlDocumentSourceIds,
|
||||
const DirectoryPathIds &directoryIds,
|
||||
@@ -1095,12 +1104,8 @@ void ProjectStorageUpdater::pathsWithIdsChanged(const std::vector<IdPaths> &chan
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
parseTypeInfo(std::move(qt.qmltypes), qtDirectoryIds, IsInsideProject::No);
|
||||
parseTypeInfo(std::move(project.qmltypes), projectDirectoryIds, IsInsideProject::Yes);
|
||||
} catch (const QmlDesigner::CannotParseQmlTypesFile &) {
|
||||
return;
|
||||
}
|
||||
|
||||
package.updatedSourceIds = filterNotUpdatedSourceIds(std::move(package.updatedSourceIds),
|
||||
std::move(notUpdatedSourceIds.sourceIds));
|
||||
@@ -1108,11 +1113,7 @@ void ProjectStorageUpdater::pathsWithIdsChanged(const std::vector<IdPaths> &chan
|
||||
std::move(package.updatedFileStatusSourceIds),
|
||||
std::move(notUpdatedSourceIds.fileStatusSourceIds));
|
||||
|
||||
try {
|
||||
m_projectStorage.synchronize(std::move(package));
|
||||
} catch (const ProjectStorageError &) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto directoryIdsSize = projectDirectoryIds.size() + qtDirectoryIds.size();
|
||||
if (directoryIdsSize > 0) {
|
||||
@@ -1128,6 +1129,9 @@ void ProjectStorageUpdater::pathsWithIdsChanged(const std::vector<IdPaths> &chan
|
||||
}
|
||||
|
||||
m_changedIdPaths.clear();
|
||||
|
||||
} catch (...) {
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectStorageUpdater::pathsChanged(const SourceIds &) {}
|
||||
@@ -1137,6 +1141,7 @@ void ProjectStorageUpdater::parseTypeInfos(const QStringList &typeInfos,
|
||||
const std::vector<Utils::PathString> &qmldirImports,
|
||||
DirectoryPathId directoryId,
|
||||
const QString &directoryPath,
|
||||
FileState directoryState,
|
||||
ModuleId moduleId,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
@@ -1179,7 +1184,7 @@ void ProjectStorageUpdater::parseTypeInfos(const QStringList &typeInfos,
|
||||
notUpdatedSourceIds,
|
||||
isInsideProject);
|
||||
|
||||
if (isExisting(state)) {
|
||||
if (isExisting(state) && isChanged(directoryState)) {
|
||||
package.directoryInfos.push_back(directoryInfo);
|
||||
tracer.tick("append directory info", keyValue("source id", directoryInfo.sourceId));
|
||||
}
|
||||
@@ -1262,6 +1267,7 @@ void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFil
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
WatchedSourceIds &watchedSourceIds,
|
||||
FileState directoryState,
|
||||
FileState qmldirState,
|
||||
SourceId qmldirSourceId,
|
||||
IsInsideProject isInsideProject)
|
||||
@@ -1319,9 +1325,11 @@ void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFil
|
||||
break;
|
||||
}
|
||||
|
||||
if (isChanged(directoryState)) {
|
||||
const auto &directoryInfo = package.directoryInfos.emplace_back(
|
||||
directoryId, sourceId, ModuleId{}, Storage::Synchronization::FileType::QmlDocument);
|
||||
tracer.tick("append directory info", keyValue("project data", directoryInfo));
|
||||
}
|
||||
|
||||
tracer.tick("append updated source id", keyValue("source id", sourceId));
|
||||
package.updatedSourceIds.push_back(sourceId);
|
||||
@@ -1430,6 +1438,7 @@ void ProjectStorageUpdater::parseQmlComponents(Components components,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
WatchedSourceIds &WatchedSourceIds,
|
||||
FileState directoryState,
|
||||
FileState qmldirState,
|
||||
SourceId qmldirSourceId,
|
||||
IsInsideProject isInsideProject)
|
||||
@@ -1454,6 +1463,7 @@ void ProjectStorageUpdater::parseQmlComponents(Components components,
|
||||
package,
|
||||
notUpdatedSourceIds,
|
||||
WatchedSourceIds,
|
||||
directoryState,
|
||||
qmldirState,
|
||||
qmldirSourceId,
|
||||
isInsideProject);
|
||||
|
@@ -157,6 +157,7 @@ private:
|
||||
IsInsideProject isInsideProject);
|
||||
void updateDirectoryChanged(Utils::SmallStringView directoryPath,
|
||||
Utils::SmallStringView annotationDirectoryPath,
|
||||
FileState directoryState,
|
||||
FileState qmldirState,
|
||||
FileState annotationDirectoryState,
|
||||
SourcePath qmldirSourcePath,
|
||||
@@ -213,6 +214,7 @@ private:
|
||||
const std::vector<Utils::PathString> &qmldirImports,
|
||||
DirectoryPathId directoryId,
|
||||
const QString &directoryPath,
|
||||
FileState directoryState,
|
||||
ModuleId moduleId,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
@@ -233,6 +235,7 @@ private:
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
WatchedSourceIds &WatchedSourceIds,
|
||||
FileState directoryState,
|
||||
FileState qmldirState,
|
||||
SourceId qmldirSourceId,
|
||||
IsInsideProject isInsideProject);
|
||||
@@ -243,6 +246,7 @@ private:
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
WatchedSourceIds &WatchedSourceIds,
|
||||
FileState directoryState,
|
||||
FileState qmldirState,
|
||||
SourceId qmldirSourceId,
|
||||
IsInsideProject isInsideProject);
|
||||
|
@@ -878,7 +878,7 @@ std::ostream &operator<<(std::ostream &out, const SynchronizationPackage &packag
|
||||
<< package.updatedPropertyEditorQmlPathDirectoryIds
|
||||
<< ",\n\t\ttypeAnnotations: " << package.typeAnnotations
|
||||
<< ",\n\t\tupdatedTypeAnnotationSourceIds: " << package.updatedTypeAnnotationSourceIds
|
||||
<< ",\n\t\ttmoduleDependencies: " << package.moduleDependencies
|
||||
<< ",\n\t\tmoduleDependencies: " << package.moduleDependencies
|
||||
<< ",\n\t\tupdatedTypeAnnotationSourceIds: " << package.updatedModuleDependencySourceIds
|
||||
<< ",\n\t\tmoduleExportedImports: " << package.moduleExportedImports
|
||||
<< ",\n\t\tupdatedModuleIds: " << package.updatedModuleIds << "\n)";
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,7 @@ using testing::AtMost;
|
||||
using testing::Between;
|
||||
using testing::ByMove;
|
||||
using testing::ByRef;
|
||||
using testing::Combine;
|
||||
using testing::Conditional;
|
||||
using testing::ContainerEq;
|
||||
using testing::Contains;
|
||||
@@ -62,5 +63,6 @@ using testing::Throw;
|
||||
using testing::TypedEq;
|
||||
using testing::UnorderedElementsAre;
|
||||
using testing::UnorderedElementsAreArray;
|
||||
using testing::Values;
|
||||
using testing::VariantWith;
|
||||
using testing::WithArg;
|
||||
|
Reference in New Issue
Block a user