diff options
author | Marco Bubke <marco.bubke@qt.io> | 2020-06-11 17:25:46 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2020-06-30 09:52:34 +0000 |
commit | 36b72e2bab6a5baddc9de21a25b4498dc66f2dc0 (patch) | |
tree | 23814632ec9a18fee7633ef6eef4e3167815561e /tests | |
parent | 4d17a2c50a0dc9b4009091d3b887943c9f2f5897 (diff) | |
download | qt-creator-36b72e2bab6a5baddc9de21a25b4498dc66f2dc0.tar.gz |
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 <thomas.hartmann@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'tests')
16 files changed, 935 insertions, 1 deletions
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 <QString> + +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 <QString> + +#include <functional> + +namespace Core { + +class IContext +{ +public: + using HelpCallback = std::function<void(const QString &)>; +}; + +} // 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 <qmldesignercorelib_global.h> + +#include <QCoreApplication> +#include <QUrl> + +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 <QIcon> + +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<ItemLibraryEntry> entries() const { return {}; } + QList<ItemLibraryEntry> 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 <QObject> +#include <QSize> +#include <QString> +#include <QVariant> + +#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 <QSharedPointer> +#include <QStringList> + +#include "itemlibraryinfo.h" +#include <nodemetainfo.h> + +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<AbstractProperty> &propertyList) override {} + void propertiesRemoved(const QList<AbstractProperty> &propertyList) override {} + void variantPropertiesChanged(const QList<VariantProperty> &propertyList, + PropertyChangeFlags propertyChange) override + {} + void bindingPropertiesChanged(const QList<BindingProperty> &propertyList, + PropertyChangeFlags propertyChange) override + {} + void signalHandlerPropertiesChanged(const QVector<SignalHandlerProperty> &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<ModelNode> &nodeList, + const QList<QVariant> &data) override + {} + + void rewriterBeginTransaction() override {} + void rewriterEndTransaction() override {} + + void importsChanged(const QList<Import> &addedImports, const QList<Import> &removedImports) override + {} + + void sendToken(const QString &token, int number, const QVector<ModelNode> &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 <QIcon> +#include <QList> +#include <QString> +#include <QVariant> + +#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<NodeMetaInfo> classHierarchy() const { return {}; } + QList<NodeMetaInfo> 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 <modelnode.h> +#include <qmldesignercorelib_global.h> + +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 <qmldesignercorelib_global.h> + +#include <nodeinstance.h> + +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 <qmldesignercorelib_global.h> + +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<AbstractProperty> &) override {} + void propertiesRemoved(const QList<AbstractProperty> &) override {} + void variantPropertiesChanged(const QList<VariantProperty> &, PropertyChangeFlags) override {} + void bindingPropertiesChanged(const QList<BindingProperty> &, PropertyChangeFlags) override {} + void signalHandlerPropertiesChanged(const QVector<SignalHandlerProperty> &, + 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<ModelNode> &, + const QList<QVariant> &) override + {} + + void rewriterBeginTransaction() override {} + void rewriterEndTransaction() override {} + + void importsChanged(const QList<Import> &, const QList<Import> &) 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<DocumentMessage> warnings() const { return {}; } + QList<DocumentMessage> errors() const { return {}; } + void clearErrorAndWarnings() {} + void setErrors(const QList<DocumentMessage> &) {} + void setWarnings(const QList<DocumentMessage> &) {} + 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<ModelNode, QString> extractText(const QList<ModelNode> &) 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<QPair<QString, QString>> qrcMapping() const { return {}; } + + void moveToComponent(const ModelNode &) {} + + QStringList autoComplete(const QString &, int, bool = true) { return {}; } + + QList<CppTypeData> getCppTypes() { return {}; } + + void setWidgetStatusCallback(std::function<void(bool)> 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 <qmldesigner/components/listmodeleditor/listmodeleditormodel.h> +#include <qmldesigner/components/listmodeleditor/listmodeleditorview.h> +#include <qmldesigner/designercore/include/model.h> + +namespace { + +class ListModelEditor : public testing::Test +{ +public: + ListModelEditor() { designerModel->attachView(&view); } + +protected: + std::unique_ptr<QmlDesigner::Model> 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 += \ |