forked from qt-creator/qt-creator
UnitTests: Add fixture for property editor panes
Improves the clarity, readability, and overall understanding of the tests, making them easier to maintain and work with. Change-Id: I7c7277f83b1b777c0b2e00402ec204e171184df7 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -4508,10 +4508,10 @@ TEST_F(ProjectStorageUpdater, watcher_dont_watches_directories_after_qmltypes_ch
|
|||||||
{{qmltypesProjectChunkId, {qmltypesPathSourceId, qmltypes2PathSourceId}}});
|
{{qmltypesProjectChunkId, {qmltypesPathSourceId, qmltypes2PathSourceId}}});
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString propertyEditorQmlPath = QDir::cleanPath(
|
class ProjectStorageUpdater_property_editor_panes : public BaseProjectStorageUpdater
|
||||||
UNITTEST_DIR "/../../../../share/qtcreator/qmldesigner/propertyEditorQmlSources/");
|
{
|
||||||
|
public:
|
||||||
TEST_F(ProjectStorageUpdater, update_property_editor_panes)
|
ProjectStorageUpdater_property_editor_panes()
|
||||||
{
|
{
|
||||||
ON_CALL(fileSystemMock, fileStatus(_)).WillByDefault([](SourceId sourceId) {
|
ON_CALL(fileSystemMock, fileStatus(_)).WillByDefault([](SourceId sourceId) {
|
||||||
return FileStatus{sourceId, 1, 21};
|
return FileStatus{sourceId, 1, 21};
|
||||||
@@ -4519,23 +4519,41 @@ TEST_F(ProjectStorageUpdater, update_property_editor_panes)
|
|||||||
ON_CALL(projectStorageMock, fetchFileStatus(_)).WillByDefault([](SourceId sourceId) {
|
ON_CALL(projectStorageMock, fetchFileStatus(_)).WillByDefault([](SourceId sourceId) {
|
||||||
return FileStatus{sourceId, 1, 21};
|
return FileStatus{sourceId, 1, 21};
|
||||||
});
|
});
|
||||||
auto sourceId = sourcePathCache.sourceId(
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
const QString propertyEditorQmlPath = QDir::cleanPath(
|
||||||
|
UNITTEST_DIR "/../../../../share/qtcreator/qmldesigner/propertyEditorQmlSources/");
|
||||||
|
SourceId sourceId = sourcePathCache.sourceId(
|
||||||
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QML/QtObjectPane.qml"});
|
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QML/QtObjectPane.qml"});
|
||||||
auto directoryId = sourcePathCache.directoryPathId(
|
DirectoryPathId directoryId = sourcePathCache.directoryPathId(
|
||||||
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QML"});
|
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QML"});
|
||||||
auto directorySourceId = SourceId::create(directoryId, QmlDesigner::FileNameId{});
|
SourceId directorySourceId = SourceId::create(directoryId, QmlDesigner::FileNameId{});
|
||||||
|
SourceId textSourceId = sourcePathCache.sourceId(
|
||||||
|
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick/TextSpecifics.qml"});
|
||||||
|
DirectoryPathId qtQuickDirectoryId = sourcePathCache.directoryPathId(
|
||||||
|
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick"});
|
||||||
|
SourceId qtQuickDirectorySourceId = SourceId::create(qtQuickDirectoryId,
|
||||||
|
QmlDesigner::FileNameId{});
|
||||||
|
SourceId buttonSourceId = sourcePathCache.sourceId(
|
||||||
|
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick/Controls/ButtonSpecifics.qml"});
|
||||||
|
DirectoryPathId controlsDirectoryId = sourcePathCache.directoryPathId(
|
||||||
|
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick/Controls"});
|
||||||
|
SourceId controlsDirectorySourceId = SourceId::create(controlsDirectoryId,
|
||||||
|
QmlDesigner::FileNameId{});
|
||||||
|
ModuleId qtQuickModuleId = storage.moduleId("QtQuick", ModuleKind::QmlLibrary);
|
||||||
|
ModuleId controlsModuleId = storage.moduleId("QtQuick.Controls", ModuleKind::QmlLibrary);
|
||||||
|
ModuleId qmlModuleId = storage.moduleId("QML", ModuleKind::QmlLibrary);
|
||||||
|
Update update = {.propertyEditorResourcesPath = propertyEditorQmlPath};
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(ProjectStorageUpdater_property_editor_panes, update)
|
||||||
|
{
|
||||||
setFilesChanged({directorySourceId});
|
setFilesChanged({directorySourceId});
|
||||||
auto qmlModuleId = storage.moduleId("QML", ModuleKind::QmlLibrary);
|
|
||||||
|
|
||||||
EXPECT_CALL(projectStorageMock,
|
EXPECT_CALL(projectStorageMock,
|
||||||
synchronize(
|
synchronize(
|
||||||
AllOf(Field("SynchronizationPackage::fileStatuses",
|
AllOf(Field("SynchronizationPackage::propertyEditorQmlPaths",
|
||||||
&SynchronizationPackage::fileStatuses,
|
|
||||||
UnorderedElementsAre(IsFileStatus(directorySourceId, 1, 21))),
|
|
||||||
Field("SynchronizationPackage::updatedFileStatusSourceIds",
|
|
||||||
&SynchronizationPackage::updatedFileStatusSourceIds,
|
|
||||||
UnorderedElementsAre(directorySourceId)),
|
|
||||||
Field("SynchronizationPackage::propertyEditorQmlPaths",
|
|
||||||
&SynchronizationPackage::propertyEditorQmlPaths,
|
&SynchronizationPackage::propertyEditorQmlPaths,
|
||||||
Contains(IsPropertyEditorQmlPath(
|
Contains(IsPropertyEditorQmlPath(
|
||||||
qmlModuleId, "QtObject", sourceId, directoryId))),
|
qmlModuleId, "QtObject", sourceId, directoryId))),
|
||||||
@@ -4543,30 +4561,12 @@ TEST_F(ProjectStorageUpdater, update_property_editor_panes)
|
|||||||
&SynchronizationPackage::updatedPropertyEditorQmlPathDirectoryIds,
|
&SynchronizationPackage::updatedPropertyEditorQmlPathDirectoryIds,
|
||||||
ElementsAre(directoryId)))));
|
ElementsAre(directoryId)))));
|
||||||
|
|
||||||
updater.update({.propertyEditorResourcesPath = propertyEditorQmlPath});
|
updater.update(update);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectStorageUpdater, update_property_editor_specifics)
|
TEST_F(ProjectStorageUpdater_property_editor_panes, specifics)
|
||||||
{
|
{
|
||||||
ON_CALL(fileSystemMock, fileStatus(_)).WillByDefault([](SourceId sourceId) {
|
|
||||||
return FileStatus{sourceId, 1, 21};
|
|
||||||
});
|
|
||||||
ON_CALL(projectStorageMock, fetchFileStatus(_)).WillByDefault([](SourceId sourceId) {
|
|
||||||
return FileStatus{sourceId, 1, 21};
|
|
||||||
});
|
|
||||||
auto textSourceId = sourcePathCache.sourceId(
|
|
||||||
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick/TextSpecifics.qml"});
|
|
||||||
auto qtQuickDirectoryId = sourcePathCache.directoryPathId(
|
|
||||||
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick"});
|
|
||||||
auto qtQuickDirectorySourceId = SourceId::create(qtQuickDirectoryId, QmlDesigner::FileNameId{});
|
|
||||||
auto buttonSourceId = sourcePathCache.sourceId(
|
|
||||||
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick/Controls/ButtonSpecifics.qml"});
|
|
||||||
auto controlsDirectoryId = sourcePathCache.directoryPathId(
|
|
||||||
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick/Controls"});
|
|
||||||
auto controlsDirectorySourceId = SourceId::create(controlsDirectoryId, QmlDesigner::FileNameId{});
|
|
||||||
setFilesChanged({qtQuickDirectorySourceId, controlsDirectorySourceId});
|
setFilesChanged({qtQuickDirectorySourceId, controlsDirectorySourceId});
|
||||||
auto qtQuickModuleId = storage.moduleId("QtQuick", ModuleKind::QmlLibrary);
|
|
||||||
auto controlsModuleId = storage.moduleId("QtQuick.Controls", ModuleKind::QmlLibrary);
|
|
||||||
|
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
projectStorageMock,
|
projectStorageMock,
|
||||||
@@ -4581,22 +4581,16 @@ TEST_F(ProjectStorageUpdater, update_property_editor_specifics)
|
|||||||
&SynchronizationPackage::updatedPropertyEditorQmlPathDirectoryIds,
|
&SynchronizationPackage::updatedPropertyEditorQmlPathDirectoryIds,
|
||||||
ElementsAre(qtQuickDirectoryId, controlsDirectoryId)))));
|
ElementsAre(qtQuickDirectoryId, controlsDirectoryId)))));
|
||||||
|
|
||||||
updater.update({.propertyEditorResourcesPath = propertyEditorQmlPath});
|
updater.update(update);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectStorageUpdater, update_property_editor_panes_is_empty_if_directory_has_not_changed)
|
TEST_F(ProjectStorageUpdater_property_editor_panes, is_empty_if_directory_has_not_changed)
|
||||||
{
|
{
|
||||||
updater.update({.propertyEditorResourcesPath = propertyEditorQmlPath});
|
updater.update(update);
|
||||||
ON_CALL(fileSystemMock, fileStatus(_)).WillByDefault([](SourceId sourceId) {
|
|
||||||
return FileStatus{sourceId, 1, 21};
|
|
||||||
});
|
|
||||||
ON_CALL(projectStorageMock, fetchFileStatus(_)).WillByDefault([](SourceId sourceId) {
|
|
||||||
return FileStatus{sourceId, 1, 21};
|
|
||||||
});
|
|
||||||
|
|
||||||
EXPECT_CALL(projectStorageMock, synchronize(PackageIsEmpty()));
|
EXPECT_CALL(projectStorageMock, synchronize(PackageIsEmpty()));
|
||||||
|
|
||||||
updater.update({.propertyEditorResourcesPath = propertyEditorQmlPath});
|
updater.update(update);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectStorageUpdater, update_type_annotations)
|
TEST_F(ProjectStorageUpdater, update_type_annotations)
|
||||||
|
Reference in New Issue
Block a user