Commit d7f24031 authored by Thomas Hartmann's avatar Thomas Hartmann

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: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
Reviewed-by: default avatarMarco Benelli <marco.benelli@qt.io>
parent 1d0b45b8
......@@ -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;
......
......@@ -61,6 +61,7 @@ private slots:
void testMetaInfoListProperties();
void testQtQuick20Basic();
void testQtQuick20BasicRectangle();
void testQtQuickControls2();
//
// unit tests Model, ModelNode, NodeProperty, AbstractView
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment