diff options
author | Thomas Hartmann <Thomas.Hartmann@theqtcompany.com> | 2016-06-14 16:42:13 +0200 |
---|---|---|
committer | Thomas Hartmann <Thomas.Hartmann@theqtcompany.com> | 2016-06-14 15:43:12 +0000 |
commit | d7f24031dc10f9e120372c14e89baf029b4664f1 (patch) | |
tree | 0364903d0316843c2e9a28430bbcbd1597a8183a /tests | |
parent | 1d0b45b8819e0e2119c8fd4718ca92831bea59e5 (diff) | |
download | qt-creator-d7f24031dc10f9e120372c14e89baf029b4664f1.tar.gz |
Adding test for standard issues with QtQuick Controls 2
This test is covering the standard issues we had with the
code model regarding QtQuick Controls (2).
We check if ApplicationWindow is derived from QtQuick.Window
and if Button is derived from QtQuick.Item.
Change-Id: I1a2ed894daeb06743fb950bf629a8dcf2b9a78e6
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp | 62 | ||||
-rw-r--r-- | tests/auto/qml/qmldesigner/coretests/tst_testcore.h | 1 |
2 files changed, 63 insertions, 0 deletions
diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp index 049b9b2548..96ad5e8da0 100644 --- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp +++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp @@ -4259,6 +4259,68 @@ void tst_TestCore::testQtQuick20BasicRectangle() QCOMPARE(rootModelNode.majorVersion(), 2); } +void tst_TestCore::testQtQuickControls2() +{ + + const char* qmlString + = "import QtQuick 2.7\n" + "import QtQuick.Controls 2.0\n" + "import QtQuick.Layouts 1.0\n" + "\n" + "ApplicationWindow {\n" + "visible: true\n" + "width: 640\n" + "height: 480\n" + "title: qsTr(\"Hello World\")\n" + "Button {\n" + "}\n" + "Layout {\n" + "}\n" + "}\n"; + + QPlainTextEdit textEdit; + textEdit.setPlainText(QLatin1String(qmlString)); + NotIndentingTextEditModifier modifier(&textEdit); + + QScopedPointer<Model> model(Model::create("QtQuick.Item")); + QVERIFY(model.data()); + QScopedPointer<TestView> view(new TestView(model.data())); + QVERIFY(view.data()); + model->attachView(view.data()); + + TestRewriterView *testRewriterView = new TestRewriterView(model.data()); + testRewriterView->setTextModifier(&modifier); + model->attachView(testRewriterView); + + QVERIFY(testRewriterView->errors().isEmpty()); + + ModelNode rootModelNode(view->rootModelNode()); + + QVERIFY(rootModelNode.isValid()); + + QVERIFY(rootModelNode.metaInfo().isGraphicalItem()); + QVERIFY(rootModelNode.isSubclassOf("QtQuick.Window.Window", -1, -1)); + + QVERIFY(!rootModelNode.metaInfo().directPropertyNames().contains("visible")); + QVERIFY(rootModelNode.metaInfo().propertyNames().contains("visible")); + + QVERIFY(!rootModelNode.allSubModelNodes().isEmpty()); + ModelNode button = rootModelNode.allSubModelNodes().first(); + QVERIFY(button.isValid()); + QVERIFY(button.metaInfo().isValid()); + QVERIFY(button.metaInfo().isGraphicalItem()); + QVERIFY(button.isSubclassOf("QtQuick.Controls.Button", 2, -1)); + QVERIFY(button.isSubclassOf("QtQuick.Item", 2, -1)); + + QCOMPARE(rootModelNode.allSubModelNodes().count(), 2); + ModelNode layout = rootModelNode.allSubModelNodes().last(); + QVERIFY(layout.isValid()); + QVERIFY(layout.metaInfo().isValid()); + QVERIFY(layout.metaInfo().isGraphicalItem()); + QVERIFY(layout.isSubclassOf("QtQuick.Layout", -1, -1)); + QVERIFY(layout.isSubclassOf("QtQuick.Item", 2, -1)); +} + void tst_TestCore::testStatesRewriter() { QPlainTextEdit textEdit; diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.h b/tests/auto/qml/qmldesigner/coretests/tst_testcore.h index fdb09811c9..56c9eb4c0d 100644 --- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.h +++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.h @@ -61,6 +61,7 @@ private slots: void testMetaInfoListProperties(); void testQtQuick20Basic(); void testQtQuick20BasicRectangle(); + void testQtQuickControls2(); // // unit tests Model, ModelNode, NodeProperty, AbstractView |