From 36b72e2bab6a5baddc9de21a25b4498dc66f2dc0 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Thu, 11 Jun 2020 17:25:46 +0200 Subject: QmlDesigner: Break dependencies To get the model under unit tests we have to break every depenedency to code outside of the unit test scope. Change-Id: Ib613c3308e48990c55b2ed0cd42bc4b0e1041a01 Reviewed-by: Thomas Hartmann Reviewed-by: Tim Jenssen --- tests/unit/mockup/coreplugin/helpitem.h | 41 +++++ tests/unit/mockup/coreplugin/icontext.h | 40 +++++ .../designercore/include/documentmessage.h | 70 +++++++++ .../designercore/include/itemlibraryinfo.h | 56 +++++++ .../designercore/include/itemlibraryitem.h | 64 ++++++++ .../qmldesigner/designercore/include/metainfo.h | 63 ++++++++ .../designercore/include/nodeinstanceview.h | 91 +++++++++++ .../designercore/include/nodemetainfo.h | 97 ++++++++++++ .../designercore/include/qmlmodelnodefacade.h | 56 +++++++ .../designercore/include/qmlobjectnode.h | 42 +++++ .../qmldesigner/designercore/include/qmlstate.h | 39 +++++ .../qmldesigner/designercore/include/qmltimeline.h | 46 ++++++ .../designercore/include/rewriterview.h | 175 +++++++++++++++++++++ tests/unit/unittest/creator_dependency.pri | 1 + tests/unit/unittest/listmodeleditor-test.cpp | 47 ++++++ tests/unit/unittest/unittest.pro | 8 +- 16 files changed, 935 insertions(+), 1 deletion(-) create mode 100644 tests/unit/mockup/coreplugin/helpitem.h create mode 100644 tests/unit/mockup/coreplugin/icontext.h create mode 100644 tests/unit/mockup/qmldesigner/designercore/include/documentmessage.h create mode 100644 tests/unit/mockup/qmldesigner/designercore/include/itemlibraryinfo.h create mode 100644 tests/unit/mockup/qmldesigner/designercore/include/itemlibraryitem.h create mode 100644 tests/unit/mockup/qmldesigner/designercore/include/metainfo.h create mode 100644 tests/unit/mockup/qmldesigner/designercore/include/nodeinstanceview.h create mode 100644 tests/unit/mockup/qmldesigner/designercore/include/nodemetainfo.h create mode 100644 tests/unit/mockup/qmldesigner/designercore/include/qmlmodelnodefacade.h create mode 100644 tests/unit/mockup/qmldesigner/designercore/include/qmlobjectnode.h create mode 100644 tests/unit/mockup/qmldesigner/designercore/include/qmlstate.h create mode 100644 tests/unit/mockup/qmldesigner/designercore/include/qmltimeline.h create mode 100644 tests/unit/mockup/qmldesigner/designercore/include/rewriterview.h create mode 100644 tests/unit/unittest/listmodeleditor-test.cpp (limited to 'tests') diff --git a/tests/unit/mockup/coreplugin/helpitem.h b/tests/unit/mockup/coreplugin/helpitem.h new file mode 100644 index 0000000000..7942036c74 --- /dev/null +++ b/tests/unit/mockup/coreplugin/helpitem.h @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "core_global.h" + +#include + +namespace Core { + +class HelpItem +{ +public: + HelpItem() {} + HelpItem(const QString &) {} +}; + +} // namespace Core diff --git a/tests/unit/mockup/coreplugin/icontext.h b/tests/unit/mockup/coreplugin/icontext.h new file mode 100644 index 0000000000..95b55302fb --- /dev/null +++ b/tests/unit/mockup/coreplugin/icontext.h @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include + +#include + +namespace Core { + +class IContext +{ +public: + using HelpCallback = std::function; +}; + +} // namespace Core diff --git a/tests/unit/mockup/qmldesigner/designercore/include/documentmessage.h b/tests/unit/mockup/qmldesigner/designercore/include/documentmessage.h new file mode 100644 index 0000000000..c4edc8e07d --- /dev/null +++ b/tests/unit/mockup/qmldesigner/designercore/include/documentmessage.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "exception.h" + +#include + +#include +#include + +namespace QmlJS { +class DiagnosticMessage; +} + +namespace QmlDesigner { + +class DocumentMessage +{ +public: + enum Type { NoError = 0, InternalError = 1, ParseError = 2 }; + +public: + DocumentMessage() {} + DocumentMessage(const QString &) {} + + Type type() const { return m_type; } + + int line() const { return m_line; } + + int column() const { return m_column; } + + QString description() const { return m_description; } + + QUrl url() const { return m_url; } + + QString toString() const { return {}; } + +private: + Type m_type; + int m_line; + int m_column; + QString m_description; + QUrl m_url; +}; + +} // namespace QmlDesigner diff --git a/tests/unit/mockup/qmldesigner/designercore/include/itemlibraryinfo.h b/tests/unit/mockup/qmldesigner/designercore/include/itemlibraryinfo.h new file mode 100644 index 0000000000..ad854699b4 --- /dev/null +++ b/tests/unit/mockup/qmldesigner/designercore/include/itemlibraryinfo.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "qmldesignercorelib_global.h" + +#include + +namespace QmlDesigner { + +class ItemLibraryEntry +{ +public: + QString name() const { return {}; } + TypeName typeName() const { return {}; } + QIcon typeIcon() const { return {}; } + QString libraryEntryIconPath() const { return {}; } +}; + +class ItemLibraryInfo +{ +public: + QList entries() const { return {}; } + QList entriesForType(const QByteArray &typeName, + int majorVersion, + int minorVersion) const + { + return {}; + } + ItemLibraryEntry entry(const QString &name) const { return {}; } +}; + +} // namespace QmlDesigner diff --git a/tests/unit/mockup/qmldesigner/designercore/include/itemlibraryitem.h b/tests/unit/mockup/qmldesigner/designercore/include/itemlibraryitem.h new file mode 100644 index 0000000000..ccc06640eb --- /dev/null +++ b/tests/unit/mockup/qmldesigner/designercore/include/itemlibraryitem.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include +#include +#include +#include + +#include "itemlibraryinfo.h" + +namespace QmlDesigner { + +class ItemLibraryItem : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QVariant itemLibraryEntry READ itemLibraryEntry FINAL) + Q_PROPERTY(QString itemName READ itemName FINAL) + Q_PROPERTY(QString itemLibraryIconPath READ itemLibraryIconPath FINAL) + Q_PROPERTY(bool itemVisible READ isVisible NOTIFY visibilityChanged FINAL) + +public: + ItemLibraryItem(QObject *) {} + ~ItemLibraryItem() override {} + + QString itemName() const { return {}; } + QString typeName() const { return {}; } + QString itemLibraryIconPath() const { return {}; } + + bool setVisible(bool) { return {}; } + bool isVisible() const { return {}; } + + void setItemLibraryEntry(const ItemLibraryEntry &) {} + QVariant itemLibraryEntry() const { return {}; } + +signals: + void visibilityChanged(); +}; + +} // namespace QmlDesigner diff --git a/tests/unit/mockup/qmldesigner/designercore/include/metainfo.h b/tests/unit/mockup/qmldesigner/designercore/include/metainfo.h new file mode 100644 index 0000000000..22e7c5762d --- /dev/null +++ b/tests/unit/mockup/qmldesigner/designercore/include/metainfo.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "qmldesignercorelib_global.h" + +#include +#include + +#include "itemlibraryinfo.h" +#include + +namespace QmlDesigner { + +class ModelNode; +class AbstractProperty; +class ItemLibraryInfo; + +inline bool operator==(const MetaInfo &first, const MetaInfo &second) +{ + return {}; +} +inline bool operator!=(const MetaInfo &first, const MetaInfo &second) +{ + return {}; +} + +class QMLDESIGNERCORE_EXPORT MetaInfo +{ +public: + ItemLibraryInfo *itemLibraryInfo() const { return {}; } + +public: + static MetaInfo global() { return {}; } + static void clearGlobal() {} + + static void setPluginPaths(const QStringList &paths) {} +}; + +} //namespace QmlDesigner diff --git a/tests/unit/mockup/qmldesigner/designercore/include/nodeinstanceview.h b/tests/unit/mockup/qmldesigner/designercore/include/nodeinstanceview.h new file mode 100644 index 0000000000..246d1ede40 --- /dev/null +++ b/tests/unit/mockup/qmldesigner/designercore/include/nodeinstanceview.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "qmldesignercorelib_global.h" +#include "abstractview.h" + +namespace QmlDesigner { + +class NodeInstanceView : public AbstractView +{ + Q_OBJECT + +public: + NodeInstanceView(QObject *parent) {} + ~NodeInstanceView() override {} + + void modelAttached(Model *model) override {} + void modelAboutToBeDetached(Model *model) override {} + void nodeCreated(const ModelNode &createdNode) override {} + void nodeRemoved(const ModelNode &removedNode, + const NodeAbstractProperty &parentProperty, + PropertyChangeFlags propertyChange) override + {} + void propertiesAboutToBeRemoved(const QList &propertyList) override {} + void propertiesRemoved(const QList &propertyList) override {} + void variantPropertiesChanged(const QList &propertyList, + PropertyChangeFlags propertyChange) override + {} + void bindingPropertiesChanged(const QList &propertyList, + PropertyChangeFlags propertyChange) override + {} + void signalHandlerPropertiesChanged(const QVector &propertyList, + PropertyChangeFlags propertyChange) override + {} + void nodeReparented(const ModelNode &node, + const NodeAbstractProperty &newPropertyParent, + const NodeAbstractProperty &oldPropertyParent, + AbstractView::PropertyChangeFlags propertyChange) override + {} + void nodeIdChanged(const ModelNode &node, const QString &newId, const QString &oldId) override + {} + void nodeOrderChanged(const NodeListProperty &listProperty, + const ModelNode &movedNode, + int oldIndex) override + {} + void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) override {} + void nodeTypeChanged(const ModelNode &node, + const TypeName &type, + int majorVersion, + int minorVersion) override + {} + void customNotification(const AbstractView *view, + const QString &identifier, + const QList &nodeList, + const QList &data) override + {} + + void rewriterBeginTransaction() override {} + void rewriterEndTransaction() override {} + + void importsChanged(const QList &addedImports, const QList &removedImports) override + {} + + void sendToken(const QString &token, int number, const QVector &nodeVector) {} +}; + +} // namespace QmlDesigner diff --git a/tests/unit/mockup/qmldesigner/designercore/include/nodemetainfo.h b/tests/unit/mockup/qmldesigner/designercore/include/nodemetainfo.h new file mode 100644 index 0000000000..ed00f71d98 --- /dev/null +++ b/tests/unit/mockup/qmldesigner/designercore/include/nodemetainfo.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include +#include +#include +#include + +#include "qmldesignercorelib_global.h" + +QT_BEGIN_NAMESPACE +class QDeclarativeContext; +QT_END_NAMESPACE + +namespace QmlDesigner { + +class MetaInfo; +class Model; +class AbstractProperty; + +class NodeMetaInfo +{ +public: + NodeMetaInfo() {} + NodeMetaInfo(Model *, const TypeName &, int, int) {} + + bool isValid() const { return {}; } + bool isFileComponent() const { return {}; } + bool hasProperty(const PropertyName &) const { return {}; } + PropertyNameList propertyNames() const { return {}; } + PropertyNameList signalNames() const { return {}; } + PropertyNameList directPropertyNames() const { return {}; } + PropertyName defaultPropertyName() const { return "data"; } + bool hasDefaultProperty() const { return {}; } + TypeName propertyTypeName(const PropertyName &) const { return {}; } + bool propertyIsWritable(const PropertyName &) const { return {}; } + bool propertyIsListProperty(const PropertyName &) const { return {}; } + bool propertyIsEnumType(const PropertyName &) const { return {}; } + bool propertyIsPrivate(const PropertyName &) const { return {}; } + QString propertyEnumScope(const PropertyName &) const { return {}; } + QStringList propertyKeysForEnum(const PropertyName &) const { return {}; } + QVariant propertyCastedValue(const PropertyName &, const QVariant &) const { return {}; } + + QList classHierarchy() const { return {}; } + QList superClasses() const { return {}; } + NodeMetaInfo directSuperClass() const { return {}; } + + bool defaultPropertyIsComponent() const { return {}; } + + TypeName typeName() const { return {}; } + TypeName simplifiedTypeName() const { return {}; } + int majorVersion() const { return {}; } + int minorVersion() const { return {}; } + + QString componentSource() const { return {}; } + QString componentFileName() const { return {}; } + + bool hasCustomParser() const { return {}; } + + bool availableInVersion(int, int) const { return {}; } + bool isSubclassOf(const TypeName &, int = -1, int = -1) const { return {}; } + + bool isGraphicalItem() const { return {}; } + bool isLayoutable() const { return {}; } + bool isView() const { return {}; } + bool isTabView() const { return {}; } + + QString importDirectoryPath() const { return {}; } + + static void clearCache() {} +}; + +} // namespace QmlDesigner diff --git a/tests/unit/mockup/qmldesigner/designercore/include/qmlmodelnodefacade.h b/tests/unit/mockup/qmldesigner/designercore/include/qmlmodelnodefacade.h new file mode 100644 index 0000000000..3821943d8f --- /dev/null +++ b/tests/unit/mockup/qmldesigner/designercore/include/qmlmodelnodefacade.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include +#include + +namespace QmlDesigner { + +class AbstractView; +class NodeInstanceView; + +class QmlModelNodeFacade +{ +public: + operator ModelNode() const { return {}; } + ModelNode modelNode() { return {}; } + const ModelNode modelNode() const { return {}; } + bool hasModelNode() const { return {}; } + static bool isValidQmlModelNodeFacade(const ModelNode &modelNode) { return {}; } + virtual bool isValid() const { return {}; } + + AbstractView *view() const { return {}; } + static NodeInstanceView *nodeInstanceView(const ModelNode &modelNode) { return {}; } + NodeInstanceView *nodeInstanceView() const { return {}; } + bool isRootNode() const { return {}; } + + QmlModelNodeFacade(const ModelNode &) {} + QmlModelNodeFacade() {} + ~QmlModelNodeFacade(){}; +}; + +} // namespace QmlDesigner diff --git a/tests/unit/mockup/qmldesigner/designercore/include/qmlobjectnode.h b/tests/unit/mockup/qmldesigner/designercore/include/qmlobjectnode.h new file mode 100644 index 0000000000..7e2c118589 --- /dev/null +++ b/tests/unit/mockup/qmldesigner/designercore/include/qmlobjectnode.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "qmlmodelnodefacade.h" +#include + +#include + +namespace QmlDesigner { + +class QMLDESIGNERCORE_EXPORT QmlObjectNode : public QmlModelNodeFacade +{ +public: + QmlObjectNode() {} + QmlObjectNode(const ModelNode &modelNode){}; +}; + +} // namespace QmlDesigner diff --git a/tests/unit/mockup/qmldesigner/designercore/include/qmlstate.h b/tests/unit/mockup/qmldesigner/designercore/include/qmlstate.h new file mode 100644 index 0000000000..50e82596b5 --- /dev/null +++ b/tests/unit/mockup/qmldesigner/designercore/include/qmlstate.h @@ -0,0 +1,39 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "qmlmodelnodefacade.h" + +namespace QmlDesigner { + +class QmlModelState : public QmlModelNodeFacade +{ +public: + QmlModelState(); + QmlModelState(const ModelNode &) {} +}; + +} // namespace QmlDesigner diff --git a/tests/unit/mockup/qmldesigner/designercore/include/qmltimeline.h b/tests/unit/mockup/qmldesigner/designercore/include/qmltimeline.h new file mode 100644 index 0000000000..0d2c05b1b5 --- /dev/null +++ b/tests/unit/mockup/qmldesigner/designercore/include/qmltimeline.h @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "qmlmodelnodefacade.h" +#include + +namespace QmlDesigner { + +class QmlTimeline : public QmlModelNodeFacade +{ +public: + QmlTimeline() {} + QmlTimeline(const ModelNode &) {} + + bool isValid() const override { return {}; } + + void toogleRecording(bool b) const {} + + void resetGroupRecording() const {} +}; + +} // namespace QmlDesigner diff --git a/tests/unit/mockup/qmldesigner/designercore/include/rewriterview.h b/tests/unit/mockup/qmldesigner/designercore/include/rewriterview.h new file mode 100644 index 0000000000..39c19e4e2d --- /dev/null +++ b/tests/unit/mockup/qmldesigner/designercore/include/rewriterview.h @@ -0,0 +1,175 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "qmldesignercorelib_global.h" +#include "abstractview.h" + +namespace QmlJS { +class Document; +class ScopeChain; +} + +namespace QmlDesigner { + +class TextModifier; + +namespace Internal { + +class TextToModelMerger; +class ModelToTextMerger; +class ModelNodePositionStorage; + +} //Internal + +struct CppTypeData +{ + QString superClassName; + QString importUrl; + QString versionString; + QString cppClassName; + QString typeName; + bool isSingleton = false; +}; + +class RewriterView : public AbstractView +{ + Q_OBJECT + +public: + enum DifferenceHandling { + Validate, + Amend + }; + +public: + RewriterView(DifferenceHandling, QObject *) {} + ~RewriterView() override {} + + void modelAttached(Model *) override {} + void modelAboutToBeDetached(Model *) override {} + void nodeCreated(const ModelNode &) override {} + void nodeRemoved(const ModelNode &, const NodeAbstractProperty &, PropertyChangeFlags) override + {} + void propertiesAboutToBeRemoved(const QList &) override {} + void propertiesRemoved(const QList &) override {} + void variantPropertiesChanged(const QList &, PropertyChangeFlags) override {} + void bindingPropertiesChanged(const QList &, PropertyChangeFlags) override {} + void signalHandlerPropertiesChanged(const QVector &, + PropertyChangeFlags) override + {} + void nodeReparented(const ModelNode &, + const NodeAbstractProperty &, + const NodeAbstractProperty &, + AbstractView::PropertyChangeFlags) override + {} + void nodeIdChanged(const ModelNode &, const QString &, const QString &) override {} + void nodeOrderChanged(const NodeListProperty &, const ModelNode &, int) override {} + void rootNodeTypeChanged(const QString &, int, int) override {} + void nodeTypeChanged(const ModelNode &, const TypeName &, int, int) override {} + void customNotification(const AbstractView *, + const QString &, + const QList &, + const QList &) override + {} + + void rewriterBeginTransaction() override {} + void rewriterEndTransaction() override {} + + void importsChanged(const QList &, const QList &) override {} + + TextModifier *textModifier() const { return {}; } + void setTextModifier(TextModifier *) {} + QString textModifierContent() const { return {}; } + + void reactivateTextMofifierChangeSignals() {} + void deactivateTextMofifierChangeSignals() {} + + void auxiliaryDataChanged(const ModelNode &node, const PropertyName &name, const QVariant &data) override + {} + + Internal::ModelNodePositionStorage *positionStorage() const {} + + QList warnings() const { return {}; } + QList errors() const { return {}; } + void clearErrorAndWarnings() {} + void setErrors(const QList &) {} + void setWarnings(const QList &) {} + void setIncompleteTypeInformation(bool) {} + bool hasIncompleteTypeInformation() const { return false; } + void addError(const DocumentMessage &) {} + + void enterErrorState(const QString &) {} + bool inErrorState() const { return false; } + void leaveErrorState() {} + void resetToLastCorrectQml() {} + + QMap extractText(const QList &) const; + int nodeOffset(const ModelNode &) const; + int nodeLength(const ModelNode &) const; + int firstDefinitionInsideOffset(const ModelNode &) const { return {}; } + int firstDefinitionInsideLength(const ModelNode &) const { return {}; } + bool modificationGroupActive() { return {}; } + ModelNode nodeAtTextCursorPosition(int) const { return {}; } + + bool renameId(const QString &, const QString &) { return {}; } + + const QmlJS::Document *document() const { return {}; } + const QmlJS::ScopeChain *scopeChain() const { return {}; } + + QString convertTypeToImportAlias(const QString &) const { return {}; } + + bool checkSemanticErrors() const { return {}; } + + void setCheckSemanticErrors(bool) {} + + QString pathForImport(const Import &) { return {}; } + + QStringList importDirectories() const { return {}; } + + QSet> qrcMapping() const { return {}; } + + void moveToComponent(const ModelNode &) {} + + QStringList autoComplete(const QString &, int, bool = true) { return {}; } + + QList getCppTypes() { return {}; } + + void setWidgetStatusCallback(std::function setWidgetStatusCallback); + + void qmlTextChanged() {} + void delayedSetup() {} + + void writeAuxiliaryData() {} + void restoreAuxiliaryData() {} + + QString getRawAuxiliaryData() const { return {}; } + QString auxiliaryDataAsQML() const { return {}; } + + ModelNode getNodeForCanonicalIndex(int) { return {}; } +}; + +} //QmlDesigner diff --git a/tests/unit/unittest/creator_dependency.pri b/tests/unit/unittest/creator_dependency.pri index 4aaac22a1b..ef00624b95 100644 --- a/tests/unit/unittest/creator_dependency.pri +++ b/tests/unit/unittest/creator_dependency.pri @@ -16,6 +16,7 @@ include($$PWD/../../../src/plugins/clangpchmanager/clangpchmanager-source.pri) include($$PWD/../../../src/plugins/cpptools/cpptoolsunittestfiles.pri) include($$PWD/../../../src/plugins/debugger/debuggerunittestfiles.pri) include($$PWD/../../../src/plugins/compilationdatabaseprojectmanager/compilationdatabaseunittestfiles.pri) +include($$PWD/../../../src/plugins/qmldesigner/qmldesignerunittestfiles.pri) !isEmpty(QTC_UNITTEST_BUILD_CPP_PARSER):include(cplusplus.pri) !isEmpty(LLVM_VERSION) { include($$PWD/../../../src/plugins/clangtools/clangtoolsunittestfiles.pri) diff --git a/tests/unit/unittest/listmodeleditor-test.cpp b/tests/unit/unittest/listmodeleditor-test.cpp new file mode 100644 index 0000000000..7a876890c5 --- /dev/null +++ b/tests/unit/unittest/listmodeleditor-test.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "googletest.h" + +#include +#include +#include + +namespace { + +class ListModelEditor : public testing::Test +{ +public: + ListModelEditor() { designerModel->attachView(&view); } + +protected: + std::unique_ptr designerModel{QmlDesigner::Model::create("QtQuick.Item", 1, 1)}; + QmlDesigner::ListModelEditorView view; + QmlDesigner::ListModelEditorModel model; +}; + +} // namespace diff --git a/tests/unit/unittest/unittest.pro b/tests/unit/unittest/unittest.pro index e9a96ace5f..d40d76db34 100644 --- a/tests/unit/unittest/unittest.pro +++ b/tests/unit/unittest/unittest.pro @@ -1,4 +1,5 @@ INCLUDEPATH += ../mockup +INCLUDEPATH += ../mockup/qmldesigner/designercore/include QT += core network testlib widgets CONFIG += console c++14 testcase @@ -65,6 +66,7 @@ SOURCES += \ gtest-qt-printing.cpp \ lastchangedrowid-test.cpp \ lineprefixer-test.cpp \ + listmodeleditor-test.cpp \ locatorfilter-test.cpp \ mimedatabase-utilities.cpp \ pchmanagerclientserverinprocess-test.cpp \ @@ -288,7 +290,11 @@ HEADERS += \ mockbuilddependencygenerator.h \ mockpchtasksmerger.h \ mockpchtaskqueue.h \ - mockpchtaskgenerator.h + mockpchtaskgenerator.h \ + ../mockup/qmldesigner/designercore/include/nodeinstanceview.h \ + ../mockup/qmldesigner/designercore/include/rewriterview.h \ + ../mockup/qmldesigner/designercore/include/itemlibraryitem.h + !isEmpty(LIBCLANG_LIBS) { HEADERS += \ -- cgit v1.2.1