forked from qt-creator/qt-creator
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>
This commit is contained in:
committed by
Tim Jenssen
parent
e9aaf017c2
commit
e9b4cab807
60
tests/manual/qml/testprojects/cppmockup/MainForm.ui.qml
Normal file
60
tests/manual/qml/testprojects/cppmockup/MainForm.ui.qml
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
51
tests/manual/qml/testprojects/cppmockup/MyComponent.qml
Normal file
51
tests/manual/qml/testprojects/cppmockup/MyComponent.qml
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
22
tests/manual/qml/testprojects/cppmockup/cppmockup.pro
Normal file
22
tests/manual/qml/testprojects/cppmockup/cppmockup.pro
Normal file
@@ -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
|
42
tests/manual/qml/testprojects/cppmockup/main.cpp
Normal file
42
tests/manual/qml/testprojects/cppmockup/main.cpp
Normal file
@@ -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();
|
||||
}
|
41
tests/manual/qml/testprojects/cppmockup/main.qml
Normal file
41
tests/manual/qml/testprojects/cppmockup/main.qml
Normal file
@@ -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 + '"'))
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
import QtQuick 2.6
|
||||
|
||||
QtObject {
|
||||
property bool test
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
module MyPlugin
|
||||
MyObject 1.0 MyObject.qml
|
41
tests/manual/qml/testprojects/cppmockup/mybackendobject.cpp
Normal file
41
tests/manual/qml/testprojects/cppmockup/mybackendobject.cpp
Normal file
@@ -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)
|
||||
{
|
||||
|
||||
}
|
47
tests/manual/qml/testprojects/cppmockup/mybackendobject.h
Normal file
47
tests/manual/qml/testprojects/cppmockup/mybackendobject.h
Normal file
@@ -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
|
7
tests/manual/qml/testprojects/cppmockup/qml.qrc
Normal file
7
tests/manual/qml/testprojects/cppmockup/qml.qrc
Normal file
@@ -0,0 +1,7 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>main.qml</file>
|
||||
<file>MainForm.ui.qml</file>
|
||||
<file>MyComponent.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
Reference in New Issue
Block a user