summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hartmann <thomas.hartmann@qt.io>2016-10-25 15:18:13 +0200
committerTim Jenssen <tim.jenssen@qt.io>2016-10-25 13:36:27 +0000
commite9b4cab80798e71b6d24c5df0e14b228b046b184 (patch)
treeba52d8341c65fe5bd3eeb653e5136327f72df915
parente9aaf017c200b393668e3b4aa1456e355f07bcb6 (diff)
downloadqt-creator-e9b4cab80798e71b6d24c5df0e14b228b046b184.tar.gz
QmlDesigner: Adding manual test for cpp mockups
This is a typical test case for mocking cpp types. Change-Id: Ibd76429c3d1190c46a223062d77d676f728fec77 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
-rw-r--r--tests/manual/qml/testprojects/cppmockup/MainForm.ui.qml60
-rw-r--r--tests/manual/qml/testprojects/cppmockup/MyComponent.qml51
-rw-r--r--tests/manual/qml/testprojects/cppmockup/cppmockup.pro22
-rw-r--r--tests/manual/qml/testprojects/cppmockup/main.cpp42
-rw-r--r--tests/manual/qml/testprojects/cppmockup/main.qml41
-rw-r--r--tests/manual/qml/testprojects/cppmockup/mockups/MyPlugin/MyObject.qml5
-rw-r--r--tests/manual/qml/testprojects/cppmockup/mockups/MyPlugin/qmldir2
-rw-r--r--tests/manual/qml/testprojects/cppmockup/mybackendobject.cpp41
-rw-r--r--tests/manual/qml/testprojects/cppmockup/mybackendobject.h47
-rw-r--r--tests/manual/qml/testprojects/cppmockup/qml.qrc7
10 files changed, 318 insertions, 0 deletions
diff --git a/tests/manual/qml/testprojects/cppmockup/MainForm.ui.qml b/tests/manual/qml/testprojects/cppmockup/MainForm.ui.qml
new file mode 100644
index 0000000000..14aa092833
--- /dev/null
+++ b/tests/manual/qml/testprojects/cppmockup/MainForm.ui.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** 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.
+**
+****************************************************************************/
+
+import QtQuick 2.7
+
+Rectangle {
+ property alias mouseArea: mouseArea
+ property alias textEdit: textEdit
+
+ width: 360
+ height: 360
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+
+ MyComponent {
+ id: myComponent
+ x: 174
+ y: 180
+ }
+ }
+
+ TextEdit {
+ id: textEdit
+ text: qsTr("Enter some text...")
+ verticalAlignment: Text.AlignVCenter
+ anchors.top: parent.top
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.topMargin: 20
+ Rectangle {
+ anchors.fill: parent
+ anchors.margins: -10
+ color: "transparent"
+ border.width: 1
+ }
+ }
+}
diff --git a/tests/manual/qml/testprojects/cppmockup/MyComponent.qml b/tests/manual/qml/testprojects/cppmockup/MyComponent.qml
new file mode 100644
index 0000000000..3e6cf1694c
--- /dev/null
+++ b/tests/manual/qml/testprojects/cppmockup/MyComponent.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** 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.
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import MyPlugin 1.0
+
+Item {
+ width: 40
+ height: 40
+ MyObject {
+ test: true
+ }
+ Rectangle {
+ anchors.fill: parent
+ gradient: Gradient {
+ GradientStop {
+ position: 0
+ color: "#ffffff"
+ }
+
+ GradientStop {
+ position: 1
+ color: "#000000"
+ }
+ }
+
+ }
+
+}
diff --git a/tests/manual/qml/testprojects/cppmockup/cppmockup.pro b/tests/manual/qml/testprojects/cppmockup/cppmockup.pro
new file mode 100644
index 0000000000..1f8ea65d42
--- /dev/null
+++ b/tests/manual/qml/testprojects/cppmockup/cppmockup.pro
@@ -0,0 +1,22 @@
+TEMPLATE = app
+
+QT += qml quick
+CONFIG += c++11
+
+SOURCES += main.cpp \
+ mybackendobject.cpp
+
+RESOURCES += qml.qrc
+
+# Additional import path used to resolve QML modules in Qt Creator's code model
+### QML_IMPORT_PATH = $$PWD/mockups
+QML_DESIGNER_IMPORT_PATH = $$PWD/mockups
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
+
+HEADERS += \
+ mybackenmodel.h \
+ mybackendobject.h
diff --git a/tests/manual/qml/testprojects/cppmockup/main.cpp b/tests/manual/qml/testprojects/cppmockup/main.cpp
new file mode 100644
index 0000000000..32c7a2d472
--- /dev/null
+++ b/tests/manual/qml/testprojects/cppmockup/main.cpp
@@ -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.
+**
+****************************************************************************/
+
+#include <mybackendobject.h>
+
+#include <QGuiApplication>
+#include <QtQml>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+ qmlRegisterType<MyBackendObject>("MyPlugin", 1, 0, "MyObject");
+
+ return app.exec();
+}
diff --git a/tests/manual/qml/testprojects/cppmockup/main.qml b/tests/manual/qml/testprojects/cppmockup/main.qml
new file mode 100644
index 0000000000..aff0f6ae26
--- /dev/null
+++ b/tests/manual/qml/testprojects/cppmockup/main.qml
@@ -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.
+**
+****************************************************************************/
+
+import QtQuick 2.7
+import QtQuick.Window 2.2
+
+Window {
+ visible: true
+ width: 640
+ height: 480
+ title: qsTr("Hello World")
+
+ MainForm {
+ anchors.fill: parent
+ mouseArea.onClicked: {
+ console.log(qsTr('Clicked on background. Text: "' + textEdit.text + '"'))
+ }
+ }
+}
diff --git a/tests/manual/qml/testprojects/cppmockup/mockups/MyPlugin/MyObject.qml b/tests/manual/qml/testprojects/cppmockup/mockups/MyPlugin/MyObject.qml
new file mode 100644
index 0000000000..0df2d30206
--- /dev/null
+++ b/tests/manual/qml/testprojects/cppmockup/mockups/MyPlugin/MyObject.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.6
+
+QtObject {
+ property bool test
+}
diff --git a/tests/manual/qml/testprojects/cppmockup/mockups/MyPlugin/qmldir b/tests/manual/qml/testprojects/cppmockup/mockups/MyPlugin/qmldir
new file mode 100644
index 0000000000..2ee4872b4b
--- /dev/null
+++ b/tests/manual/qml/testprojects/cppmockup/mockups/MyPlugin/qmldir
@@ -0,0 +1,2 @@
+module MyPlugin
+MyObject 1.0 MyObject.qml
diff --git a/tests/manual/qml/testprojects/cppmockup/mybackendobject.cpp b/tests/manual/qml/testprojects/cppmockup/mybackendobject.cpp
new file mode 100644
index 0000000000..ea93896af0
--- /dev/null
+++ b/tests/manual/qml/testprojects/cppmockup/mybackendobject.cpp
@@ -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.
+**
+****************************************************************************/
+
+#include "mybackendobject.h"
+
+MyBackendObject::MyBackendObject(QObject *parent) : QObject(parent)
+{
+
+}
+
+bool MyBackendObject::test() const
+{
+ return false;
+}
+
+void MyBackendObject::setTest(bool)
+{
+
+}
diff --git a/tests/manual/qml/testprojects/cppmockup/mybackendobject.h b/tests/manual/qml/testprojects/cppmockup/mybackendobject.h
new file mode 100644
index 0000000000..e637ac12a6
--- /dev/null
+++ b/tests/manual/qml/testprojects/cppmockup/mybackendobject.h
@@ -0,0 +1,47 @@
+
+/****************************************************************************
+**
+** 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.
+**
+****************************************************************************/
+
+#ifndef MYBACKENDOBJECT_H
+#define MYBACKENDOBJECT_H
+
+#include <QObject>
+
+class MyBackendObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool test READ test write setTest)
+
+public:
+ explicit MyBackendObject(QObject *parent = 0);
+
+ bool test() const;
+ void setTest(bool b);
+
+public slots:
+};
+
+#endif // MYBACKENDOBJECT_H
diff --git a/tests/manual/qml/testprojects/cppmockup/qml.qrc b/tests/manual/qml/testprojects/cppmockup/qml.qrc
new file mode 100644
index 0000000000..cabeffdb5a
--- /dev/null
+++ b/tests/manual/qml/testprojects/cppmockup/qml.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>MainForm.ui.qml</file>
+ <file>MyComponent.qml</file>
+ </qresource>
+</RCC>