UnitTests: Merge MockListModelEditorView into AbstractViewMock

It was an AbstractView mock too.

Change-Id: Ida971a3468df1b14b1f8bd900817ff9fe74e0767
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
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-08-22 15:53:04 +02:00
parent 28a288d1ac
commit 76a798992a
6 changed files with 49 additions and 64 deletions

View File

@@ -11,7 +11,6 @@ add_qtc_library(TestMocks OBJECT
imagecachecollectormock.h
mockimagecachegenerator.h
mockimagecachestorage.h
mocklistmodeleditorview.h
mockmutex.h
mockqfilesystemwatcher.h
mocksqlitestatement.h

View File

@@ -7,6 +7,8 @@
#include <designercore/include/abstractview.h>
#include <designercore/include/variantproperty.h>
class AbstractViewMock : public QmlDesigner::AbstractView
{
public:
@@ -14,4 +16,44 @@ public:
: QmlDesigner::AbstractView{*externalDependencies}
{}
MOCK_METHOD(void, nodeOrderChanged, (const QmlDesigner::NodeListProperty &listProperty), (override));
MOCK_METHOD(void,
variantPropertiesChanged,
(const QList<QmlDesigner::VariantProperty> &propertyList,
PropertyChangeFlags propertyChange),
(override));
MOCK_METHOD(void, nodeCreated, (const QmlDesigner::ModelNode &createdNode), (override));
MOCK_METHOD(void,
nodeReparented,
(const QmlDesigner::ModelNode &node,
const QmlDesigner::NodeAbstractProperty &newPropertyParent,
const QmlDesigner::NodeAbstractProperty &oldPropertyParent,
AbstractView::PropertyChangeFlags propertyChange),
(override));
MOCK_METHOD(void,
propertiesRemoved,
(const QList<QmlDesigner::AbstractProperty> &propertyList),
(override));
MOCK_METHOD(void,
propertiesAboutToBeRemoved,
(const QList<QmlDesigner::AbstractProperty> &propertyList),
(override));
MOCK_METHOD(void,
bindingPropertiesChanged,
(const QList<QmlDesigner::BindingProperty> &propertyList,
PropertyChangeFlags propertyChange),
(override));
MOCK_METHOD(void,
bindingPropertiesAboutToBeChanged,
(const QList<QmlDesigner::BindingProperty> &propertyList),
(override));
MOCK_METHOD(void,
nodeRemoved,
(const QmlDesigner::ModelNode &removedNode,
const QmlDesigner::NodeAbstractProperty &parentProperty,
AbstractView::PropertyChangeFlags propertyChange),
(override));
MOCK_METHOD(void, nodeAboutToBeRemoved, (const QmlDesigner::ModelNode &removedNode), (override));
};

View File

@@ -1,56 +0,0 @@
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include "../utils/googletest.h"
#include <designercore/include/abstractview.h>
class MockListModelEditorView : public QmlDesigner::AbstractView
{
public:
MockListModelEditorView(QmlDesigner::ExternalDependenciesInterface *externalDependencies = nullptr)
: AbstractView{*externalDependencies}
{}
MOCK_METHOD(void,
variantPropertiesChanged,
(const QList<QmlDesigner::VariantProperty> &propertyList,
PropertyChangeFlags propertyChange),
(override));
MOCK_METHOD(void, nodeCreated, (const QmlDesigner::ModelNode &createdNode), (override));
MOCK_METHOD(void,
nodeReparented,
(const QmlDesigner::ModelNode &node,
const QmlDesigner::NodeAbstractProperty &newPropertyParent,
const QmlDesigner::NodeAbstractProperty &oldPropertyParent,
AbstractView::PropertyChangeFlags propertyChange),
(override));
MOCK_METHOD(void,
propertiesRemoved,
(const QList<QmlDesigner::AbstractProperty> &propertyList),
(override));
MOCK_METHOD(void,
propertiesAboutToBeRemoved,
(const QList<QmlDesigner::AbstractProperty> &propertyList),
(override));
MOCK_METHOD(void,
bindingPropertiesChanged,
(const QList<QmlDesigner::BindingProperty> &propertyList,
PropertyChangeFlags propertyChange),
(override));
MOCK_METHOD(void,
bindingPropertiesAboutToBeChanged,
(const QList<QmlDesigner::BindingProperty> &propertyList),
(override));
MOCK_METHOD(void,
nodeRemoved,
(const QmlDesigner::ModelNode &removedNode,
const QmlDesigner::NodeAbstractProperty &parentProperty,
AbstractView::PropertyChangeFlags propertyChange),
(override));
MOCK_METHOD(void, nodeAboutToBeRemoved, (const QmlDesigner::ModelNode &removedNode), (override));
};

View File

@@ -3,7 +3,7 @@
#include "../utils/googletest.h"
#include <mocks/mocklistmodeleditorview.h>
#include <mocks/abstractviewmock.h>
#include <mocks/projectstoragemock.h>
#include <mocks/sourcepathcachemock.h>
@@ -193,7 +193,7 @@ protected:
{QmlDesigner::Import::createLibraryImport("QtQml.Models"),
QmlDesigner::Import::createLibraryImport("QtQuick")},
pathCacheMock.path.toQString())};
NiceMock<MockListModelEditorView> mockView;
NiceMock<AbstractViewMock> mockView;
QmlDesigner::ListModelEditorModel model{[&] { return mockView.createModelNode("ListModel"); },
[&] { return mockView.createModelNode("ListElement"); },
goIntoComponentMock.AsStdFunction()};
@@ -209,7 +209,7 @@ protected:
{QmlDesigner::Import::createLibraryImport("QtQml.Models"),
QmlDesigner::Import::createLibraryImport("QtQuick")},
pathCacheMock.path.toQString())};
NiceMock<MockListModelEditorView> mockComponentView;
NiceMock<AbstractViewMock> mockComponentView;
ModelNode componentElement;
};

View File

@@ -4,7 +4,7 @@
#include "../utils/googletest.h"
#include <matchers/import-matcher.h>
#include <mocks/mocklistmodeleditorview.h>
#include <mocks/abstractviewmock.h>
#include <mocks/modelresourcemanagementmock.h>
#include <mocks/projectstoragemock.h>
#include <mocks/sourcepathcachemock.h>
@@ -77,7 +77,7 @@ protected:
}
protected:
NiceMock<MockListModelEditorView> viewMock;
NiceMock<AbstractViewMock> viewMock;
NiceMock<SourcePathCacheMockWithPaths> pathCacheMock{"/path/foo.qml"};
NiceMock<ProjectStorageMockWithQtQtuick> projectStorageMock{pathCacheMock.sourceId};
NiceMock<ModelResourceManagementMock> resourceManagementMock;

View File

@@ -3,7 +3,7 @@
#include "../../utils/googletest.h"
#include "../mocks/mocklistmodeleditorview.h"
#include "../mocks/abstractviewmock.h"
#include "../mocks/modelresourcemanagementmock.h"
#include "../mocks/projectstoragemock.h"
#include "../mocks/sourcepathcachemock.h"
@@ -70,7 +70,7 @@ protected:
}
protected:
NiceMock<MockListModelEditorView> viewMock;
NiceMock<AbstractViewMock> viewMock;
NiceMock<SourcePathCacheMockWithPaths> pathCacheMock{"/path/foo.qml"};
NiceMock<ProjectStorageMockWithQtQtuick> projectStorageMock{pathCacheMock.sourceId};
QmlDesigner::ModelResourceManagement management;