diff options
author | Thomas Hartmann <Thomas.Hartmann@theqtcompany.com> | 2016-06-14 12:40:30 +0200 |
---|---|---|
committer | Thomas Hartmann <Thomas.Hartmann@theqtcompany.com> | 2016-06-14 14:42:40 +0000 |
commit | 89d22b6eb094260b67a29765cf3f5292b73dca81 (patch) | |
tree | 17b0b6b3a13a9478977fbc4ec8abc3680d37913b /tests/auto | |
parent | 584e0c6b4c997bc8a64ab7816c932762652e8df8 (diff) | |
download | qt-creator-89d22b6eb094260b67a29765cf3f5292b73dca81.tar.gz |
QmlDesigner: Use QtQuick 2 in tests
Also cleaning up some tests.
Change-Id: I531997bc6eb0b9cb8057b7e408bca1c301c88ad0
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
Diffstat (limited to 'tests/auto')
4 files changed, 363 insertions, 543 deletions
diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp index 9a40c3c7dc..657103cd4a 100644 --- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp +++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp @@ -59,6 +59,7 @@ #include <utils/fileutils.h> #include <qmljs/qmljsinterpreter.h> +#include <extensionsystem/pluginmanager.h> #include <QPlainTextEdit> @@ -158,7 +159,7 @@ static QmlDesigner::Model* createModel(const QString &typeName, int major = 2, i modifier->setParent(textEdit); QmlDesigner::RewriterView *rewriterView = new QmlDesigner::RewriterView(QmlDesigner::RewriterView::Validate, model); - rewriterView->setCheckSemanticErrors(false); + //rewriterView->setCheckSemanticErrors(false); rewriterView->setTextModifier(modifier); model->attachView(rewriterView); @@ -177,8 +178,22 @@ void tst_TestCore::initTestCase() { Exception::setShouldAssert(false); + if (!QmlJS::ModelManagerInterface::instance()) + new TestModelManager; + initializeMetaTypeSystem(QLatin1String(QTCREATORDIR "/share/qtcreator")); + QStringList basePaths; + basePaths.append(QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath)); + + QFutureInterface<void> result; + QmlJS::PathsAndLanguages lPaths; + + lPaths.maybeInsert(Utils::FileName::fromString(basePaths.first()), QmlJS::Dialect::Qml); + QmlJS::ModelManagerInterface::importScan(result, QmlJS::ModelManagerInterface::workingCopy(), lPaths, + QmlJS::ModelManagerInterface::instance(), false); + + // Load plugins @@ -192,8 +207,6 @@ void tst_TestCore::initTestCase() Q_ASSERT(QFileInfo(pluginPath).exists()); MetaInfo::setPluginPaths(QStringList() << pluginPath); - new TestModelManager; - QFileInfo builtins(resourcePath() + "/qml-type-descriptions/builtins.qmltypes"); QStringList errors, warnings; QmlJS::CppQmlTypesLoader::defaultQtObjects = QmlJS::CppQmlTypesLoader::loadQmlTypes(QFileInfoList() << builtins, &errors, &warnings); @@ -327,7 +340,7 @@ void tst_TestCore::testRewriterView() void tst_TestCore::testRewriterErrors() { QPlainTextEdit textEdit; - textEdit.setPlainText("import QtQuick 1.1;\n\nItem {\n}\n"); + textEdit.setPlainText("import QtQuick 2.1;\n\nItem {\n}\n"); NotIndentingTextEditModifier textModifier(&textEdit); QScopedPointer<Model> model(Model::create("QtQuick.Item")); @@ -345,12 +358,11 @@ void tst_TestCore::testRewriterErrors() QVERIFY(testRewriterView->errors().isEmpty()); testRewriterView->setCheckSemanticErrors(true); - textEdit.setPlainText("import QtQuick 1.1;\nRectangle {\ntest: blah\n}\n"); + textEdit.setPlainText("import QtQuick 2.1;\nRectangle {\ntest: blah\n}\n"); QVERIFY(!testRewriterView->errors().isEmpty()); - testRewriterView->setCheckSemanticErrors(false); //TODO proper support for QtQuick 2.0 - textEdit.setPlainText("import QtQuick 1.1;\n\nItem {\n}\n"); + textEdit.setPlainText("import QtQuick 2.1;\n\nItem {\n}\n"); QVERIFY(testRewriterView->errors().isEmpty()); } @@ -462,7 +474,7 @@ void tst_TestCore::saveAttributesInCoreModel() void tst_TestCore::testModelCreateRect() { try { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -470,7 +482,7 @@ void tst_TestCore::testModelCreateRect() model->attachView(view.data()); QVERIFY(view->rootModelNode().isValid()); - ModelNode childNode = addNodeListChild(view->rootModelNode(), "QtQuick.Rectangle", 1, 0, "data"); + ModelNode childNode = addNodeListChild(view->rootModelNode(), "QtQuick.Rectangle", 2, 0, "data"); QVERIFY(childNode.isValid()); QVERIFY(view->rootModelNode().directSubModelNodes().contains(childNode)); QVERIFY(childNode.parentProperty().parentModelNode() == view->rootModelNode()); @@ -1072,7 +1084,6 @@ void tst_TestCore::testRewriterForGradientMagic() void tst_TestCore::loadSubItems() { - QSKIP("Currently crashing for unknown reasons", SkipAll); QFile file(QString(QTCREATORDIR) + "/tests/auto/qml/qmldesigner/data/fx/topitem.qml"); QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); @@ -1080,7 +1091,7 @@ void tst_TestCore::loadSubItems() textEdit1.setPlainText(QString::fromUtf8(file.readAll())); NotIndentingTextEditModifier modifier1(&textEdit1); - QScopedPointer<Model> model1(Model::create("QtQuick.Item")); + QScopedPointer<Model> model1(Model::create("QtQuick.Item", 2, 0)); QScopedPointer<TestRewriterView> testRewriterView1(new TestRewriterView()); testRewriterView1->setTextModifier(&modifier1); @@ -1098,7 +1109,7 @@ void tst_TestCore::createInvalidCoreModel() void tst_TestCore::testModelCreateSubNode() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -1110,7 +1121,7 @@ void tst_TestCore::testModelCreateSubNode() QCOMPARE(view->methodCalls(), expectedCalls); QVERIFY(view->rootModelNode().isValid()); - ModelNode childNode = addNodeListChild(view->rootModelNode(), "QtQuick.Rectangle", 1, 0, "data"); + ModelNode childNode = addNodeListChild(view->rootModelNode(), "QtQuick.Rectangle", 2, 0, "data"); QVERIFY(childNode.isValid()); QVERIFY(view->rootModelNode().directSubModelNodes().contains(childNode)); QVERIFY(childNode.parentProperty().parentModelNode() == view->rootModelNode()); @@ -1145,7 +1156,7 @@ void tst_TestCore::testModelCreateSubNode() void tst_TestCore::testTypicalRewriterOperations() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -1174,7 +1185,7 @@ void tst_TestCore::testTypicalRewriterOperations() QCOMPARE(rootModelNode.bindingProperty("x").expression(), QString("parent.x")); - ModelNode childNode(addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1 ,0, "data")); + ModelNode childNode(addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2 ,0, "data")); rootModelNode.nodeListProperty("data").reparentHere(childNode); QCOMPARE(childNode.parentProperty(), rootModelNode.nodeAbstractProperty("data")); QVERIFY(rootModelNode.property("data").isNodeAbstractProperty()); @@ -1194,7 +1205,7 @@ void tst_TestCore::testTypicalRewriterOperations() void tst_TestCore::testBasicStates() { - char qmlString[] = "import QtQuick 1.1\n" + char qmlString[] = "import QtQuick 2.1\n" "Rectangle {\n" "id: root;\n" "Rectangle {\n" @@ -1281,7 +1292,7 @@ void tst_TestCore::testBasicStates() QCOMPARE(state1.propertyChanges().count(), 2); QCOMPARE(state2.propertyChanges().count(), 2); - QVERIFY(state1.propertyChanges().first().modelNode().metaInfo().isSubclassOf("<cpp>.QDeclarativeStateOperation", -1, -1)); + QVERIFY(state1.propertyChanges().first().modelNode().metaInfo().isSubclassOf("<cpp>.QQuickStateOperation", -1, -1)); QVERIFY(!state1.hasPropertyChanges(rootModelNode)); QVERIFY(state1.propertyChanges(rect1).isValid()); @@ -1408,7 +1419,7 @@ void tst_TestCore::testBasicStatesQtQuick20() void tst_TestCore::testModelBasicOperations() { - QScopedPointer<Model> model(createModel("QtQuick.Flipable")); + QScopedPointer<Model> model(createModel("QtQuick.Flipable", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -1429,8 +1440,8 @@ void tst_TestCore::testModelBasicOperations() QVERIFY(!rootModelNode.hasProperty("width")); QVERIFY(!rootModelNode.hasProperty("children")); - ModelNode childNode1(addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "children")); - ModelNode childNode2(addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data")); + ModelNode childNode1(addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "children")); + ModelNode childNode2(addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data")); QVERIFY(childNode1.isValid()); QVERIFY(childNode2.isValid()); @@ -1468,7 +1479,7 @@ void tst_TestCore::testModelBasicOperations() void tst_TestCore::testModelResolveIds() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -1478,9 +1489,9 @@ void tst_TestCore::testModelResolveIds() ModelNode rootNode = view->rootModelNode(); rootNode.setIdWithoutRefactoring("rootNode"); - ModelNode childNode1(addNodeListChild(rootNode, "QtQuick.Rectangle", 1, 0, "children")); + ModelNode childNode1(addNodeListChild(rootNode, "QtQuick.Rectangle", 2, 0, "children")); - ModelNode childNode2(addNodeListChild(childNode1, "QtQuick.Flipable", 1, 0, "children")); + ModelNode childNode2(addNodeListChild(childNode1, "QtQuick.Flipable", 2, 0, "children")); childNode2.setIdWithoutRefactoring("childNode2"); childNode2.bindingProperty("anchors.fill").setExpression("parent.parent"); @@ -1491,7 +1502,7 @@ void tst_TestCore::testModelResolveIds() childNode2.bindingProperty("anchors.fill").setExpression("rootNode"); QCOMPARE(childNode2.bindingProperty("anchors.fill").resolveToModelNode(), rootNode); - ModelNode childNode3(addNodeListChild(childNode2, "QtQuick.Rectangle", 1, 0, "children")); + ModelNode childNode3(addNodeListChild(childNode2, "QtQuick.Rectangle", 2, 0, "children")); childNode3.setIdWithoutRefactoring("childNode3"); childNode2.nodeProperty("front").setModelNode(childNode3); childNode2.bindingProperty("anchors.fill").setExpression("childNode3.parent"); @@ -1526,7 +1537,7 @@ void tst_TestCore::testModelNodeListProperty() // // Test NodeListProperty API // - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -1544,7 +1555,7 @@ void tst_TestCore::testModelNodeListProperty() QVERIFY(!rootChildren.isNodeListProperty()); QVERIFY(rootChildren.isEmpty()); - ModelNode rectNode = view->createModelNode("QtQuick.Rectangle", 1, 0); + ModelNode rectNode = view->createModelNode("QtQuick.Rectangle", 2, 0); rootChildren.reparentHere(rectNode); // @@ -1555,7 +1566,7 @@ void tst_TestCore::testModelNodeListProperty() QVERIFY(rootChildren.isNodeListProperty()); QVERIFY(!rootChildren.isEmpty()); - ModelNode mouseAreaNode = view->createModelNode("QtQuick.Item", 1, 1); + ModelNode mouseAreaNode = view->createModelNode("QtQuick.Item", 2, 0); NodeListProperty rectChildren = rectNode.nodeListProperty("children"); rectChildren.reparentHere(mouseAreaNode); @@ -1583,7 +1594,7 @@ void tst_TestCore::testModelNodeListProperty() void tst_TestCore::testBasicOperationsWithView() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -1610,8 +1621,8 @@ void tst_TestCore::testBasicOperationsWithView() //QCOMPARE(rootInstance.size().width(), 10.0); //QCOMPARE(rootInstance.size().height(), 10.0); - ModelNode childNode(addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data")); - ModelNode childNode2(addNodeListChild(childNode, "QtQuick.Rectangle", 1, 0, "data")); + ModelNode childNode(addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data")); + ModelNode childNode2(addNodeListChild(childNode, "QtQuick.Rectangle", 2, 0, "data")); QVERIFY(childNode2.parentProperty().parentModelNode() == childNode); QVERIFY(childNode.isValid()); @@ -1652,10 +1663,10 @@ void tst_TestCore::testBasicOperationsWithView() */ } - childNode = addNodeListChild(rootModelNode, "QtQuick.Image", 1, 0, "data"); + childNode = addNodeListChild(rootModelNode, "QtQuick.Image", 2, 0, "data"); QVERIFY(childNode.isValid()); QCOMPARE(childNode.type(), QmlDesigner::TypeName("QtQuick.Image")); - childNode2 = addNodeListChild(childNode, "QtQuick.Rectangle", 1, 0, "data"); + childNode2 = addNodeListChild(childNode, "QtQuick.Rectangle", 2, 0, "data"); QVERIFY(childNode2.isValid()); childNode2.setParentProperty(rootModelNode, "data"); QVERIFY(childNode2.isValid()); @@ -1698,7 +1709,7 @@ void tst_TestCore::testBasicOperationsWithView() void tst_TestCore::testQmlModelView() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); TestView *view = new TestView(model.data()); @@ -1719,7 +1730,7 @@ void tst_TestCore::testQmlModelView() propertyList.append(qMakePair(QmlDesigner::PropertyName("width"), QVariant(20))); propertyList.append(qMakePair(QmlDesigner::PropertyName("height"), QVariant(20))); - QmlObjectNode node1 = view->createQmlObjectNode("QtQuick.Rectangle", 1, 0, propertyList); + QmlObjectNode node1 = view->createQmlObjectNode("QtQuick.Rectangle", 2, 0, propertyList); QVERIFY(node1.isValid()); QVERIFY(!node1.hasNodeParent()); @@ -1728,7 +1739,7 @@ void tst_TestCore::testQmlModelView() QVERIFY(node1.hasNodeParent()); - QmlObjectNode node2 = view->createQmlObjectNode("QtQuick.Rectangle", 1, 0, propertyList); + QmlObjectNode node2 = view->createQmlObjectNode("QtQuick.Rectangle", 2, 0, propertyList); QVERIFY(node2.isValid()); QVERIFY(!node2.hasNodeParent()); @@ -1752,12 +1763,12 @@ void tst_TestCore::testQmlModelView() //QCOMPARE(node1.instanceValue("x").toInt(), 2); - QmlObjectNode node3 = view->createQmlObjectNode("QtQuick.Rectangle", 1, 0, propertyList); - QmlObjectNode node4 = view->createQmlObjectNode("QtQuick.Rectangle", 1, 0, propertyList); - QmlObjectNode node5 = view->createQmlObjectNode("QtQuick.Rectangle", 1, 0, propertyList); - QmlObjectNode node6 = view->createQmlObjectNode("QtQuick.Rectangle", 1, 0, propertyList); - QmlObjectNode node7 = view->createQmlObjectNode("QtQuick.Rectangle", 1, 0, propertyList); - QmlObjectNode node8 = view->createQmlObjectNode("QtQuick.Rectangle", 1, 0, propertyList); + QmlObjectNode node3 = view->createQmlObjectNode("QtQuick.Rectangle", 2, 0, propertyList); + QmlObjectNode node4 = view->createQmlObjectNode("QtQuick.Rectangle", 2, 0, propertyList); + QmlObjectNode node5 = view->createQmlObjectNode("QtQuick.Rectangle", 2, 0, propertyList); + QmlObjectNode node6 = view->createQmlObjectNode("QtQuick.Rectangle", 2, 0, propertyList); + QmlObjectNode node7 = view->createQmlObjectNode("QtQuick.Rectangle", 2, 0, propertyList); + QmlObjectNode node8 = view->createQmlObjectNode("QtQuick.Rectangle", 2, 0, propertyList); node3.setParentProperty(node2.nodeAbstractProperty("children")); node4.setParentProperty(node3.nodeAbstractProperty("children")); @@ -1785,12 +1796,12 @@ void tst_TestCore::testQmlModelView() //QCOMPARE(node2.instanceValue("x").toInt(), 10); // is this right? or should it be a invalid qvariant? - node1 = view->createQmlObjectNode("QtQuick.Rectangle", 1, 0, propertyList); + node1 = view->createQmlObjectNode("QtQuick.Rectangle", 2, 0, propertyList); node1.setId("node1"); //QCOMPARE(node2.instanceValue("x").toInt(), 20); - node3 = view->createQmlObjectNode("QtQuick.Rectangle", 1, 0, propertyList); + node3 = view->createQmlObjectNode("QtQuick.Rectangle", 2, 0, propertyList); node3.setParentProperty(node2.nodeAbstractProperty("children")); //QCOMPARE(node3.instanceValue("width").toInt(), 20); node3.setVariantProperty("width", 0); @@ -1811,7 +1822,7 @@ void tst_TestCore::testQmlModelView() void tst_TestCore::testModelRemoveNode() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -1824,7 +1835,7 @@ void tst_TestCore::testModelRemoveNode() QCOMPARE(view->rootModelNode().directSubModelNodes().count(), 0); - ModelNode childNode = addNodeListChild(view->rootModelNode(), "QtQuick.Rectangle", 1, 0, "data"); + ModelNode childNode = addNodeListChild(view->rootModelNode(), "QtQuick.Rectangle", 2, 0, "data"); QVERIFY(childNode.isValid()); QCOMPARE(view->rootModelNode().directSubModelNodes().count(), 1); QVERIFY(view->rootModelNode().directSubModelNodes().contains(childNode)); @@ -1836,7 +1847,7 @@ void tst_TestCore::testModelRemoveNode() //#### QVERIFY(childInstance.parentId() == view->rootModelNode().internalId()); } - ModelNode subChildNode = addNodeListChild(childNode, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode subChildNode = addNodeListChild(childNode, "QtQuick.Rectangle", 2, 0, "data"); QVERIFY(subChildNode.isValid()); QCOMPARE(childNode.directSubModelNodes().count(), 1); QVERIFY(childNode.directSubModelNodes().contains(subChildNode)); @@ -1875,7 +1886,7 @@ void tst_TestCore::testModelRemoveNode() void tst_TestCore::reparentingNode() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); @@ -1892,7 +1903,7 @@ void tst_TestCore::reparentingNode() //NodeInstanceView *nodeInstanceView = new NodeInstanceView(model.data(), NodeInstanceServerInterface::TestModus); //model->attachView(nodeInstanceView); - ModelNode childNode = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode childNode = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); QCOMPARE(childNode.parentProperty().parentModelNode(), rootModelNode); QVERIFY(rootModelNode.directSubModelNodes().contains(childNode)); @@ -1902,7 +1913,7 @@ void tst_TestCore::reparentingNode() //QVERIFY(childInstance.parentId() == view->rootModelNode().internalId()); } - ModelNode childNode2 = addNodeListChild(rootModelNode, "QtQuick.Item", 1, 1, "data"); + ModelNode childNode2 = addNodeListChild(rootModelNode, "QtQuick.Item", 2, 0, "data"); QCOMPARE(childNode2.parentProperty().parentModelNode(), rootModelNode); QVERIFY(rootModelNode.directSubModelNodes().contains(childNode2)); @@ -2069,7 +2080,7 @@ void tst_TestCore::reparentingNodeLikeDragAndDrop() void tst_TestCore::testModelReorderSiblings() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -2082,11 +2093,11 @@ void tst_TestCore::testModelReorderSiblings() ModelNode rootModelNode = view->rootModelNode(); QVERIFY(rootModelNode.isValid()); - ModelNode a = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode a = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); QVERIFY(a.isValid()); - ModelNode b = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode b = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); QVERIFY(b.isValid()); - ModelNode c = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode c = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); QVERIFY(c.isValid()); { @@ -2124,7 +2135,7 @@ void tst_TestCore::testModelReorderSiblings() void tst_TestCore::testModelRootNode() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -2135,10 +2146,10 @@ void tst_TestCore::testModelRootNode() ModelNode rootModelNode = view->rootModelNode(); QVERIFY(rootModelNode.isValid()); QVERIFY(rootModelNode.isRootNode()); - ModelNode topChildNode = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode topChildNode = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); QVERIFY(topChildNode.isValid()); QVERIFY(rootModelNode.isRootNode()); - ModelNode childNode = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode childNode = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); QVERIFY(childNode.isValid()); QVERIFY(rootModelNode.isValid()); QVERIFY(rootModelNode.isRootNode()); @@ -2156,15 +2167,15 @@ void tst_TestCore::testModelRootNode() void tst_TestCore::reparentingNodeInModificationGroup() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); QVERIFY(view.data()); model->attachView(view.data()); - ModelNode childNode = addNodeListChild(view->rootModelNode(), "QtQuick.Rectangle", 1, 0, "data"); - ModelNode childNode2 = addNodeListChild(view->rootModelNode(), "QtQuick.Item", 1, 1, "data"); + ModelNode childNode = addNodeListChild(view->rootModelNode(), "QtQuick.Rectangle", 2, 0, "data"); + ModelNode childNode2 = addNodeListChild(view->rootModelNode(), "QtQuick.Item", 2, 0, "data"); childNode.variantProperty("x").setValue(10); childNode.variantProperty("y").setValue(10); @@ -2212,6 +2223,7 @@ void tst_TestCore::testModelAddAndRemoveProperty() QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); + model->rewriterView()->setCheckSemanticErrors(false); //This test needs this QVERIFY(view.data()); model->attachView(view.data()); @@ -2252,7 +2264,7 @@ void tst_TestCore::testModelAddAndRemoveProperty() void tst_TestCore::testModelViewNotification() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view1(new TestView(model.data())); @@ -2274,7 +2286,7 @@ void tst_TestCore::testModelViewNotification() QCOMPARE(view1->methodCalls(), expectedCalls); QCOMPARE(view2->methodCalls(), expectedCalls); - ModelNode childNode = addNodeListChild(view2->rootModelNode(), "QtQuick.Rectangle", 1, 0, "data"); + ModelNode childNode = addNodeListChild(view2->rootModelNode(), "QtQuick.Rectangle", 2, 0, "data"); expectedCalls << TestView::MethodCall("nodeCreated", QStringList() << ""); expectedCalls << TestView::MethodCall("nodeAboutToBeReparented", QStringList() << "" << "data" << "" << "PropertiesAdded"); expectedCalls << TestView::MethodCall("nodeReparented", QStringList() << "" << "data" << "" << "PropertiesAdded"); @@ -2331,7 +2343,7 @@ void tst_TestCore::testModelViewNotification() void tst_TestCore::testRewriterTransaction() { - QScopedPointer<Model> model(Model::create("QtQuick.Item")); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -2341,7 +2353,7 @@ void tst_TestCore::testRewriterTransaction() RewriterTransaction transaction = view->beginRewriterTransaction("TEST"); QVERIFY(transaction.isValid()); - ModelNode childNode = addNodeListChild(view->rootModelNode(), "QtQuick.Rectangle", 1, 0, "data"); + ModelNode childNode = addNodeListChild(view->rootModelNode(), "QtQuick.Rectangle", 2, 0, "data"); QVERIFY(childNode.isValid()); childNode.destroy(); @@ -2351,7 +2363,7 @@ void tst_TestCore::testRewriterTransaction() RewriterTransaction transaction2 = view->beginRewriterTransaction("TEST"); QVERIFY(transaction2.isValid()); - ModelNode childNode = addNodeListChild(view->rootModelNode(), "QtQuick.Rectangle", 1, 0, "data"); + ModelNode childNode = addNodeListChild(view->rootModelNode(), "QtQuick.Rectangle", 2, 0, "data"); QVERIFY(childNode.isValid()); childNode.destroy(); @@ -2422,7 +2434,7 @@ void tst_TestCore::testRewriterId() void tst_TestCore::testRewriterNodeReparentingTransaction1() { - char qmlString[] = "import QtQuick 1.1\n" + char qmlString[] = "import QtQuick 2.0\n" "Rectangle {\n" "}\n"; @@ -2430,7 +2442,7 @@ void tst_TestCore::testRewriterNodeReparentingTransaction1() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item")); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -2447,12 +2459,12 @@ void tst_TestCore::testRewriterNodeReparentingTransaction1() QVERIFY(rootModelNode.isValid()); - ModelNode childNode1 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); - ModelNode childNode2 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); - ModelNode childNode3 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); - ModelNode childNode4 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode childNode1 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); + ModelNode childNode2 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); + ModelNode childNode3 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); + ModelNode childNode4 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); - ModelNode reparentNode = addNodeListChild(childNode1, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode reparentNode = addNodeListChild(childNode1, "QtQuick.Rectangle", 2, 0, "data"); RewriterTransaction rewriterTransaction = view->beginRewriterTransaction("TEST"); @@ -2467,7 +2479,7 @@ void tst_TestCore::testRewriterNodeReparentingTransaction1() void tst_TestCore::testRewriterNodeReparentingTransaction2() { - char qmlString[] = "import QtQuick 1.1\n" + char qmlString[] = "import QtQuick 2.0\n" "Rectangle {\n" "}\n"; @@ -2475,7 +2487,7 @@ void tst_TestCore::testRewriterNodeReparentingTransaction2() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item")); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -2492,8 +2504,8 @@ void tst_TestCore::testRewriterNodeReparentingTransaction2() QVERIFY(rootModelNode.isValid()); - ModelNode childNode1 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); - ModelNode childNode2 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode childNode1 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); + ModelNode childNode2 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); childNode2.variantProperty("x").setValue(200); childNode2.variantProperty("y").setValue(50); @@ -2533,7 +2545,7 @@ void tst_TestCore::testRewriterNodeReparentingTransaction2() void tst_TestCore::testRewriterNodeReparentingTransaction3() { - char qmlString[] = "import QtQuick 1.1\n" + char qmlString[] = "import QtQuick 2.0\n" "Rectangle {\n" "}\n"; @@ -2541,7 +2553,7 @@ void tst_TestCore::testRewriterNodeReparentingTransaction3() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item")); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -2558,10 +2570,10 @@ void tst_TestCore::testRewriterNodeReparentingTransaction3() QVERIFY(rootModelNode.isValid()); - ModelNode childNode1 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); - ModelNode childNode2 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); - ModelNode childNode3 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); - ModelNode childNode4 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode childNode1 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); + ModelNode childNode2 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); + ModelNode childNode3 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); + ModelNode childNode4 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); RewriterTransaction rewriterTransaction = view->beginRewriterTransaction("TEST"); @@ -2583,7 +2595,7 @@ void tst_TestCore::testRewriterNodeReparentingTransaction3() void tst_TestCore::testRewriterNodeReparentingTransaction4() { - char qmlString[] = "import QtQuick 1.1\n" + char qmlString[] = "import QtQuick 2.0\n" "Rectangle {\n" "}\n"; @@ -2591,7 +2603,7 @@ void tst_TestCore::testRewriterNodeReparentingTransaction4() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item")); + QScopedPointer<Model> model(Model::create("QtQuick.Item",2,0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -2608,11 +2620,11 @@ void tst_TestCore::testRewriterNodeReparentingTransaction4() QVERIFY(rootModelNode.isValid()); - ModelNode childNode1 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); - ModelNode childNode2 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); - ModelNode childNode3 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); - ModelNode childNode4 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); - ModelNode childNode5 = addNodeListChild(childNode2, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode childNode1 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); + ModelNode childNode2 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); + ModelNode childNode3 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); + ModelNode childNode4 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); + ModelNode childNode5 = addNodeListChild(childNode2, "QtQuick.Rectangle", 2, 0, "data"); RewriterTransaction rewriterTransaction = view->beginRewriterTransaction("TEST"); @@ -2634,7 +2646,7 @@ void tst_TestCore::testRewriterNodeReparentingTransaction4() void tst_TestCore::testRewriterAddNodeTransaction() { - char qmlString[] = "import QtQuick 1.1\n" + char qmlString[] = "import QtQuick 2.0\n" "Rectangle {\n" "}\n"; @@ -2642,7 +2654,7 @@ void tst_TestCore::testRewriterAddNodeTransaction() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item")); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -2660,11 +2672,11 @@ void tst_TestCore::testRewriterAddNodeTransaction() QVERIFY(rootModelNode.isValid()); - ModelNode childNode = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode childNode = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); RewriterTransaction rewriterTransaction = view->beginRewriterTransaction("TEST"); - ModelNode newNode = view->createModelNode("QtQuick.Rectangle", 1, 0); + ModelNode newNode = view->createModelNode("QtQuick.Rectangle", 2, 0); newNode.variantProperty("x").setValue(100); newNode.variantProperty("y").setValue(100); @@ -2676,7 +2688,7 @@ void tst_TestCore::testRewriterAddNodeTransaction() void tst_TestCore::testRewriterComponentId() { - char qmlString[] = "import QtQuick 1.1\n" + char qmlString[] = "import QtQuick 2.0\n" "Rectangle {\n" " Component {\n" " id: testComponent\n" @@ -2689,7 +2701,7 @@ void tst_TestCore::testRewriterComponentId() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item")); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -2712,7 +2724,7 @@ void tst_TestCore::testRewriterComponentId() void tst_TestCore::testRewriterTransactionRewriter() { - char qmlString[] = "import QtQuick 1.1\n" + char qmlString[] = "import QtQuick 2.0\n" "Rectangle {\n" "}\n"; @@ -2720,7 +2732,7 @@ void tst_TestCore::testRewriterTransactionRewriter() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item")); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -2742,7 +2754,7 @@ void tst_TestCore::testRewriterTransactionRewriter() { RewriterTransaction transaction = view->beginRewriterTransaction("TEST"); - childNode1 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); + childNode1 = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); childNode1.variantProperty("x").setValue(10); childNode1.variantProperty("y").setValue(10); } @@ -2754,7 +2766,7 @@ void tst_TestCore::testRewriterTransactionRewriter() { RewriterTransaction transaction = view->beginRewriterTransaction("TEST"); - childNode2 = addNodeListChild(childNode1, "QtQuick.Rectangle", 1, 0, "data"); + childNode2 = addNodeListChild(childNode1, "QtQuick.Rectangle", 2, 0, "data"); childNode2.destroy(); } @@ -3074,7 +3086,7 @@ void tst_TestCore::testRewriterComponentTextModifier() void tst_TestCore::testRewriterPreserveType() { - const QString qmlString("import QtQuick 1.1\n" + const QString qmlString("import QtQuick 2.1\n" "Rectangle {\n" " id: root\n" " Text {\n" @@ -3087,7 +3099,7 @@ void tst_TestCore::testRewriterPreserveType() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -3109,7 +3121,7 @@ void tst_TestCore::testRewriterPreserveType() textNode.variantProperty("font.bold").setValue(QVariant(true)); textNode.variantProperty("font.pointSize").setValue(QVariant(13.0)); - ModelNode newTextNode = addNodeListChild(rootNode, "QtQuick.Text", 1, 1, "data"); + ModelNode newTextNode = addNodeListChild(rootNode, "QtQuick.Text", 2, 0, "data"); newTextNode.variantProperty("font.bold").setValue(QVariant(true)); newTextNode.variantProperty("font.pointSize").setValue(QVariant(13.0)); @@ -3121,7 +3133,7 @@ void tst_TestCore::testRewriterPreserveType() void tst_TestCore::testRewriterForArrayMagic() { try { - const QLatin1String qmlString("import QtQuick 1.1\n" + const QLatin1String qmlString("import QtQuick 2.1\n" "\n" "Rectangle {\n" " states: State {\n" @@ -3132,7 +3144,7 @@ void tst_TestCore::testRewriterForArrayMagic() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -3154,7 +3166,7 @@ void tst_TestCore::testRewriterForArrayMagic() QmlModelState state1(rootItem.states().addState("s2")); QCOMPARE(state1.modelNode().type(), QmlDesigner::TypeName("QtQuick.State")); - const QLatin1String expected("import QtQuick 1.1\n" + const QLatin1String expected("import QtQuick 2.1\n" "\n" "Rectangle {\n" " states: [\n" @@ -3260,7 +3272,7 @@ void tst_TestCore::testRewriterNodeSliding() void tst_TestCore::testRewriterExceptionHandling() { //Does fail because we do not support QtQuick 1 anymore and generate an explicit semantic error - const QLatin1String qmlString("import QtQuick 1.1\n" + const QLatin1String qmlString("import QtQuick 2.1\n" "Text {\n" "}"); @@ -3268,7 +3280,7 @@ void tst_TestCore::testRewriterExceptionHandling() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Text", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Text", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -3294,9 +3306,9 @@ void tst_TestCore::testRewriterExceptionHandling() } catch (RewritingException &) { QVERIFY(rootNode.isValid()); QCOMPARE(rootNode.type(), QmlDesigner::TypeName("QtQuick.Text")); - //TODO rollback will fail because of QtQuick 1.1 - //QVERIFY(!rootNode.hasProperty("bla")); - //QVERIFY(!rootNode.hasProperty("text")); + + QVERIFY(!rootNode.hasProperty("bla")); + QVERIFY(!rootNode.hasProperty("text")); } } @@ -3627,7 +3639,7 @@ void tst_TestCore::testCopyModelRewriter2() void tst_TestCore::testSubComponentManager() { - const QString qmlString("import QtQuick 1.1\n" + const QString qmlString("import QtQuick 2.1\n" "Rectangle {\n" " id: root\n" " x: 10;\n" @@ -3672,7 +3684,7 @@ void tst_TestCore::testSubComponentManager() QVERIFY(model->metaInfo("QtQuick.Rectangle").propertyNames().contains("border.width")); - QVERIFY(model->metaInfo("<cpp>.QDeclarativePen").isValid()); + QVERIFY(model->metaInfo("<cpp>.QQuickPen").isValid()); QSKIP("File components not working TODO", SkipAll); NodeMetaInfo myButtonMetaInfo = model->metaInfo("MyButton"); @@ -3918,14 +3930,14 @@ char qmlString[] = "import QtQuick 1.1\n" void tst_TestCore::testMetaInfo() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); // test whether default type is registered QVERIFY(model->metaInfo("QtQuick.Item", -1, -1).isValid()); // test whether non-qml type is registered - QVERIFY(model->hasNodeMetaInfo("<cpp>.QDeclarativeStateOperation", -1, -1)); + QVERIFY(model->hasNodeMetaInfo("<cpp>.QObject", -1, -1)); } void tst_TestCore::testMetaInfoSimpleType() @@ -3938,7 +3950,6 @@ void tst_TestCore::testMetaInfoSimpleType() QVERIFY(model->hasNodeMetaInfo("QtQuick.Item", 1, 1)); NodeMetaInfo itemMetaInfo = model->metaInfo("QtQuick.Item", 1, 1); - NodeMetaInfo itemMetaInfo2 = model->metaInfo("QtQuick.Item", 1, 1); QVERIFY(itemMetaInfo.isValid()); QCOMPARE(itemMetaInfo.typeName(), QmlDesigner::TypeName("QtQuick.Item")); @@ -3946,15 +3957,14 @@ void tst_TestCore::testMetaInfoSimpleType() QCOMPARE(itemMetaInfo.minorVersion(), 1); // super classes - NodeMetaInfo graphicsObjectInfo = itemMetaInfo.directSuperClass(); - QVERIFY(graphicsObjectInfo.isValid()); - QCOMPARE(graphicsObjectInfo.typeName(), QmlDesigner::TypeName("QtQuick.QGraphicsObject")); - QCOMPARE(graphicsObjectInfo.majorVersion(), -1); - QCOMPARE(graphicsObjectInfo.minorVersion(), -1); - - QCOMPARE(itemMetaInfo.superClasses().size(), 3); // Item, QGraphicsObject, QtQuick.QtObject - QVERIFY(itemMetaInfo.isSubclassOf("QtQuick.QGraphicsObject", -1, -1)); + NodeMetaInfo qobject = itemMetaInfo.directSuperClass(); + QVERIFY(qobject.isValid()); + QVERIFY(qobject.isSubclassOf("<cpp>.QObject")); + + QCOMPARE(itemMetaInfo.superClasses().size(), 2); // Item, QtQuick.QtObject + QVERIFY(itemMetaInfo.isSubclassOf("QtQuick.Item", -1, -1)); QVERIFY(itemMetaInfo.isSubclassOf("<cpp>.QObject", -1, -1)); + QVERIFY(itemMetaInfo.isSubclassOf("QtQuick.QtObject", -1, -1)); // availableInVersion QVERIFY(itemMetaInfo.availableInVersion(1, 1)); @@ -3989,44 +3999,37 @@ void tst_TestCore::testMetaInfoExtendedType() QScopedPointer<Model> model(createModel("QtQuick.Item")); QVERIFY(model.data()); - QVERIFY(model->hasNodeMetaInfo("QtQuick.QGraphicsWidget")); - NodeMetaInfo graphicsWidgetTypeInfo = model->metaInfo("QtQuick.QGraphicsWidget", 1, 1); - QVERIFY(graphicsWidgetTypeInfo.isValid()); - QVERIFY(graphicsWidgetTypeInfo.hasProperty("layout")); // from QGraphicsWidgetDeclarativeUI - QVERIFY(graphicsWidgetTypeInfo.hasProperty("font")); // from QGraphicsWidget - QVERIFY(graphicsWidgetTypeInfo.hasProperty("enabled")); // from QGraphicsItem + QVERIFY(model->hasNodeMetaInfo("QtQuick.Text")); + NodeMetaInfo typeInfo = model->metaInfo("QtQuick.Text", 2, 1); + QVERIFY(typeInfo.isValid()); + QVERIFY(typeInfo.hasProperty("font")); // from QGraphicsWidget + QVERIFY(typeInfo.hasProperty("enabled")); // from QGraphicsItem - NodeMetaInfo graphicsObjectTypeInfo = graphicsWidgetTypeInfo.directSuperClass(); + NodeMetaInfo graphicsObjectTypeInfo = typeInfo.directSuperClass(); QVERIFY(graphicsObjectTypeInfo.isValid()); - /*QCOMPARE(graphicsObjectTypeInfo.typeName(), QmlDesigner::TypeName("<cpp>.QGraphicsObject")); - QCOMPARE(graphicsObjectTypeInfo.majorVersion(), -1); - QCOMPARE(graphicsObjectTypeInfo.minorVersion(), -1); - QCOMPARE(graphicsWidgetTypeInfo.superClasses().size(), 3);*/ } void tst_TestCore::testMetaInfoInterface() { // Test type registered with qmlRegisterInterface // - - MSKIP_ALL("TODO: Test not implemented yet"); } void tst_TestCore::testMetaInfoCustomType() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QVERIFY(model->hasNodeMetaInfo("QtQuick.PropertyChanges")); - NodeMetaInfo propertyChangesInfo = model->metaInfo("QtQuick.PropertyChanges", 1, 1); + NodeMetaInfo propertyChangesInfo = model->metaInfo("QtQuick.PropertyChanges", -1, -1); QVERIFY(propertyChangesInfo.isValid()); - QVERIFY(propertyChangesInfo.hasProperty("target")); // from QDeclarativePropertyChanges - QVERIFY(propertyChangesInfo.hasProperty("restoreEntryValues")); // from QDeclarativePropertyChanges - QVERIFY(propertyChangesInfo.hasProperty("explicit")); // from QDeclarativePropertyChanges + QVERIFY(propertyChangesInfo.hasProperty("target")); + QVERIFY(propertyChangesInfo.hasProperty("restoreEntryValues")); + QVERIFY(propertyChangesInfo.hasProperty("explicit")); NodeMetaInfo stateOperationInfo = propertyChangesInfo.directSuperClass(); QVERIFY(stateOperationInfo.isValid()); - QCOMPARE(stateOperationInfo.typeName(), QmlDesigner::TypeName("QtQuick.QDeclarativeStateOperation")); + QCOMPARE(stateOperationInfo.typeName(), QmlDesigner::TypeName("QtQuick.QQuickStateOperation")); QCOMPARE(stateOperationInfo.majorVersion(), -1); QCOMPARE(stateOperationInfo.minorVersion(), -1); QCOMPARE(propertyChangesInfo.superClasses().size(), 3); @@ -4119,10 +4122,10 @@ void tst_TestCore::testMetaInfoQtQuick1Vs2() QCOMPARE(rootModelNode.type(), QmlDesigner::TypeName("QtQuick.Rectangle")); QVERIFY(model->metaInfo("Rectangle", -1, -1).isValid()); - //QVERIFY(model->metaInfo("Rectangle", 2, 0).isValid()); 2.0 meta info currently not available + QVERIFY(model->metaInfo("Rectangle", 2, 0).isValid()); QVERIFY(model->metaInfo("QtQuick.Rectangle", -1, -1).isValid()); - //QVERIFY(model->metaInfo("QtQuick.Rectangle", 2, 0).isValid()); 2.0 meta info currently not available + QVERIFY(model->metaInfo("QtQuick.Rectangle", 2, 0).isValid()); } void tst_TestCore::testMetaInfoProperties() @@ -4130,10 +4133,10 @@ void tst_TestCore::testMetaInfoProperties() QScopedPointer<Model> model(createModel("QtQuick.Text")); QVERIFY(model.data()); - NodeMetaInfo textNodeMetaInfo = model->metaInfo("QtQuick.TextEdit", 1, 1); - QVERIFY(textNodeMetaInfo.hasProperty("text")); // QDeclarativeTextEdit - QVERIFY(textNodeMetaInfo.hasProperty("parent")); // QDeclarativeItem - QVERIFY(textNodeMetaInfo.hasProperty("x")); // QGraphicsObject + NodeMetaInfo textNodeMetaInfo = model->metaInfo("QtQuick.TextEdit", 2, 1); + QVERIFY(textNodeMetaInfo.hasProperty("text")); + QVERIFY(textNodeMetaInfo.hasProperty("parent")); + QVERIFY(textNodeMetaInfo.hasProperty("x")); QVERIFY(textNodeMetaInfo.hasProperty("objectName")); // QtQuick.QObject QVERIFY(!textNodeMetaInfo.hasProperty("bla")); @@ -4145,7 +4148,7 @@ void tst_TestCore::testMetaInfoProperties() void tst_TestCore::testMetaInfoDotProperties() { - QScopedPointer<Model> model(createModel("QtQuick.Text")); + QScopedPointer<Model> model(createModel("QtQuick.Text", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -4155,7 +4158,7 @@ void tst_TestCore::testMetaInfoDotProperties() QVERIFY(model->hasNodeMetaInfo("QtQuick.Text")); QVERIFY(model->metaInfo("QtQuick.Rectangle").hasProperty("border")); - QCOMPARE(model->metaInfo("QtQuick.Rectangle").propertyTypeName("border"), QmlDesigner::TypeName("<cpp>.QDeclarativePen")); + QCOMPARE(model->metaInfo("QtQuick.Rectangle").propertyTypeName("border"), QmlDesigner::TypeName("<cpp>.QQuickPen")); QCOMPARE(view->rootModelNode().metaInfo().typeName(), QmlDesigner::TypeName("QtQuick.Text")); QVERIFY(view->rootModelNode().metaInfo().hasProperty("font")); @@ -4165,11 +4168,10 @@ void tst_TestCore::testMetaInfoDotProperties() QVERIFY(view->rootModelNode().metaInfo().propertyNames().contains("font.pointSize")); QVERIFY(view->rootModelNode().metaInfo().hasProperty("font.pointSize")); - ModelNode rectNode(addNodeListChild(view->rootModelNode(), "QtQuick.Rectangle", 1, 0, "data")); + ModelNode rectNode(addNodeListChild(view->rootModelNode(), "QtQuick.Rectangle", 2, 0, "data")); - QVERIFY(rectNode.metaInfo().propertyNames().contains("pos")); - QVERIFY(rectNode.metaInfo().propertyNames().contains("pos.y")); - QVERIFY(rectNode.metaInfo().propertyNames().contains("pos.x")); + QVERIFY(rectNode.metaInfo().propertyNames().contains("implicitHeight")); + QVERIFY(rectNode.metaInfo().propertyNames().contains("implicitWidth")); QVERIFY(rectNode.metaInfo().propertyNames().contains("anchors.topMargin")); QVERIFY(rectNode.metaInfo().propertyNames().contains("border.width")); QVERIFY(rectNode.metaInfo().hasProperty("border")); @@ -4180,7 +4182,7 @@ void tst_TestCore::testMetaInfoDotProperties() void tst_TestCore::testMetaInfoListProperties() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -4203,8 +4205,6 @@ void tst_TestCore::testMetaInfoListProperties() QVERIFY(view->rootModelNode().metaInfo().hasProperty("transform")); QVERIFY(view->rootModelNode().metaInfo().propertyIsListProperty("transform")); - QVERIFY(view->rootModelNode().metaInfo().hasProperty("effect")); - QVERIFY(!view->rootModelNode().metaInfo().propertyIsListProperty("effect")); QVERIFY(view->rootModelNode().metaInfo().hasProperty("parent")); QVERIFY(!view->rootModelNode().metaInfo().propertyIsListProperty("parent")); @@ -4213,7 +4213,6 @@ void tst_TestCore::testMetaInfoListProperties() void tst_TestCore::testQtQuick20Basic() { - QSKIP("QtQuick 2.0", SkipAll); QPlainTextEdit textEdit; textEdit.setPlainText("\nimport QtQuick 2.0\n\nItem {\n}\n"); NotIndentingTextEditModifier modifier(&textEdit); @@ -4236,7 +4235,6 @@ void tst_TestCore::testQtQuick20Basic() void tst_TestCore::testQtQuick20BasicRectangle() { - QSKIP("QtQuick 2.0", SkipAll); QPlainTextEdit textEdit; textEdit.setPlainText("\nimport QtQuick 2.0\nRectangle {\n}\n"); NotIndentingTextEditModifier modifier(&textEdit); @@ -4264,7 +4262,7 @@ void tst_TestCore::testQtQuick20BasicRectangle() void tst_TestCore::testStatesRewriter() { QPlainTextEdit textEdit; - textEdit.setPlainText("import QtQuick 1.1; Item {}\n"); + textEdit.setPlainText("import QtQuick 2.1; Item {}\n"); NotIndentingTextEditModifier modifier(&textEdit); QScopedPointer<Model> model(Model::create("QtQuick.Item")); @@ -4313,10 +4311,10 @@ void tst_TestCore::testStatesRewriter() void tst_TestCore::testGradientsRewriter() { QPlainTextEdit textEdit; - textEdit.setPlainText("\nimport QtQuick 1.1\n\nItem {\n}\n"); + textEdit.setPlainText("\nimport QtQuick 2.0\n\nItem {\n}\n"); NotIndentingTextEditModifier modifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item")); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); QVERIFY(view.data()); @@ -4332,9 +4330,9 @@ void tst_TestCore::testGradientsRewriter() QVERIFY(rootModelNode.isValid()); - ModelNode rectNode(addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data")); + ModelNode rectNode(addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data")); - const QLatin1String expected1("\nimport QtQuick 1.1\n" + const QLatin1String expected1("\nimport QtQuick 2.0\n" "\n" "Item {\n" "Rectangle {\n" @@ -4342,11 +4340,11 @@ void tst_TestCore::testGradientsRewriter() "}\n"); QCOMPARE(textEdit.toPlainText(), expected1); - ModelNode gradientNode(addNodeChild(rectNode, "QtQuick.Gradient", 1, 0, "gradient")); + ModelNode gradientNode(addNodeChild(rectNode, "QtQuick.Gradient", 2, 0, "gradient")); QVERIFY(rectNode.hasNodeProperty("gradient")); - const QLatin1String expected2("\nimport QtQuick 1.1\n" + const QLatin1String expected2("\nimport QtQuick 2.0\n" "\n" "Item {\n" "Rectangle {\n" @@ -4363,11 +4361,11 @@ void tst_TestCore::testGradientsRewriter() propertyList.append(qMakePair(QmlDesigner::PropertyName("position"), QVariant::fromValue(0))); propertyList.append(qMakePair(QmlDesigner::PropertyName("color"), QVariant::fromValue(QColor(Qt::red)))); - ModelNode gradientStop1(gradientNode.view()->createModelNode("QtQuick.GradientStop", 1, 0, propertyList)); + ModelNode gradientStop1(gradientNode.view()->createModelNode("QtQuick.GradientStop", 2, 0, propertyList)); QVERIFY(gradientStop1.isValid()); stops.reparentHere(gradientStop1); - const QLatin1String expected3("\nimport QtQuick 1.1\n" + const QLatin1String expected3("\nimport QtQuick 2.0\n" "\n" "Item {\n" "Rectangle {\n" @@ -4386,11 +4384,11 @@ void tst_TestCore::testGradientsRewriter() propertyList.append(qMakePair(QmlDesigner::PropertyName("position"), QVariant::fromValue(0.5))); propertyList.append(qMakePair(QmlDesigner::PropertyName("color"), QVariant::fromValue(QColor(Qt::blue)))); - ModelNode gradientStop2(gradientNode.view()->createModelNode("QtQuick.GradientStop", 1, 0, propertyList)); + ModelNode gradientStop2(gradientNode.view()->createModelNode("QtQuick.GradientStop", 2, 0, propertyList)); QVERIFY(gradientStop2.isValid()); stops.reparentHere(gradientStop2); - const QLatin1String expected4("\nimport QtQuick 1.1\n" + const QLatin1String expected4("\nimport QtQuick 2.0\n" "\n" "Item {\n" "Rectangle {\n" @@ -4414,11 +4412,11 @@ void tst_TestCore::testGradientsRewriter() propertyList.append(qMakePair(QmlDesigner::PropertyName("position"), QVariant::fromValue(0.8))); propertyList.append(qMakePair(QmlDesigner::PropertyName("color"), QVariant::fromValue(QColor(Qt::yellow)))); - ModelNode gradientStop3(gradientNode.view()->createModelNode("QtQuick.GradientStop", 1, 0, propertyList)); + ModelNode gradientStop3(gradientNode.view()->createModelNode("QtQuick.GradientStop", 2, 0, propertyList)); QVERIFY(gradientStop3.isValid()); stops.reparentHere(gradientStop3); - const QLatin1String expected5("\nimport QtQuick 1.1\n" + const QLatin1String expected5("\nimport QtQuick 2.0\n" "\n" "Item {\n" "Rectangle {\n" @@ -4445,7 +4443,7 @@ void tst_TestCore::testGradientsRewriter() gradientNode.removeProperty("stops"); - const QLatin1String expected6("\nimport QtQuick 1.1\n" + const QLatin1String expected6("\nimport QtQuick 2.0\n" "\n" "Item {\n" "Rectangle {\n" @@ -4462,7 +4460,7 @@ void tst_TestCore::testGradientsRewriter() propertyList.append(qMakePair(QmlDesigner::PropertyName("position"), QVariant::fromValue(0))); propertyList.append(qMakePair(QmlDesigner::PropertyName("color"), QVariant::fromValue(QColor(Qt::blue)))); - gradientStop1 = gradientNode.view()->createModelNode("QtQuick.GradientStop", 1, 0, propertyList); + gradientStop1 = gradientNode.view()->createModelNode("QtQuick.GradientStop", 2, 0, propertyList); QVERIFY(gradientStop1.isValid()); stops.reparentHere(gradientStop1); @@ -4500,11 +4498,9 @@ void tst_TestCore::testQmlModelStates() } -void tst_TestCore::testInstancesStates() +void tst_TestCore::testStatesWasInstances() { - QSKIP("Instances are not working", SkipAll); -// -// import QtQuick 1.1 +// import QtQuick 2.0 // // Rectangle { // Text { @@ -4532,213 +4528,43 @@ void tst_TestCore::testInstancesStates() // } // -// QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 1, 1)); -// QVERIFY(model.data()); -// QScopedPointer<TestView> view(new TestView(model.data())); -// QVERIFY(view.data()); -// model->attachView(view.data()); - -// // -// // build up model -// // -// ModelNode rootNode = view->rootModelNode(); - -// ModelNode textNode = view->createModelNode("QtQuick.Text", 1, 1); -// textNode.setId("targetObject"); -// textNode.variantProperty("text").setValue("base state"); - -// rootNode.nodeListProperty("data").reparentHere(textNode); - -// ModelNode propertyChanges1Node = view->createModelNode("QtQuick.PropertyChanges", 1, 1); -// propertyChanges1Node.bindingProperty("target").setExpression("targetObject"); -// propertyChanges1Node.variantProperty("x").setValue(10); -// propertyChanges1Node.variantProperty("text").setValue("state1"); - -// ModelNode state1Node = view->createModelNode("QtQuick.State", 1, 1); -// state1Node.variantProperty("name").setValue("state1"); -// state1Node.nodeListProperty("changes").reparentHere(propertyChanges1Node); - -// rootNode.nodeListProperty("states").reparentHere(state1Node); - -// ModelNode propertyChanges2Node = view->createModelNode("QtQuick.PropertyChanges", 1, 1); -// propertyChanges2Node.bindingProperty("target").setExpression("targetObject"); -// propertyChanges2Node.variantProperty("text").setValue("state2"); - -// ModelNode state2Node = view->createModelNode("QtQuick.State", 1, 1); -// state2Node.variantProperty("name").setValue("state2"); -// state2Node.nodeListProperty("changes").reparentHere(propertyChanges2Node); - -// rootNode.nodeListProperty("states").reparentHere(state2Node); - -// // -// // load into instance view -// // -// QScopedPointer<NodeInstanceView> instanceView(new NodeInstanceView); - -// model->attachView(instanceView.data()); - -// // -// // check that list of actions is not empty (otherwise the CustomParser has not been run properly) -// // -// NodeInstance state1Instance = instanceView->instanceForNode(state1Node); -// QVERIFY(state1Instance.isValid()); -// QDeclarativeState *state1 = const_cast<QDeclarativeState*>(qobject_cast<const QDeclarativeState*>(state1Instance.testHandle())); -// QVERIFY(state1); -// QDeclarativeListProperty<QDeclarativeStateOperation> state1Changes = state1->changes(); -// QCOMPARE(state1Changes.count(&state1Changes), 1); -// QCOMPARE(state1Changes.at(&state1Changes, 0)->actions().size(), 2); - -// NodeInstance state2Instance = instanceView->instanceForNode(state2Node); -// QVERIFY(state2Instance.isValid()); -// QDeclarativeState *state2 = const_cast<QDeclarativeState*>(qobject_cast<const QDeclarativeState*>(state1Instance.testHandle())); -// QVERIFY(state2); -// QDeclarativeListProperty<QDeclarativeStateOperation> state2Changes = state2->changes(); -// QCOMPARE(state2Changes.count(&state2Changes), 1); -// QCOMPARE(state2Changes.at(&state2Changes, 0)->actions().size(), 2); - -// NodeInstance textInstance = instanceView->instanceForNode(textNode); - -// // -// // State switching -// // - -// // base state -// QVERIFY(textInstance.isValid()); -// QCOMPARE(state1Instance == instanceView->activeStateInstance(), false); -// QCOMPARE(state2Instance == instanceView->activeStateInstance(), false); -// QCOMPARE(textInstance.property("x").toInt(), 0); -// QCOMPARE(textInstance.property("text").toString(), QString("base state")); - -// // base state -> state -// instanceView->activateState(state1Instance); -// QCOMPARE(state1Instance == instanceView->activeStateInstance(), true); -// QCOMPARE(state2Instance == instanceView->activeStateInstance(), false); -// QCOMPARE(textInstance.property("x").toInt(), 10); -// QCOMPARE(textInstance.property("text").toString(), QString("state1")); - -// // state 1 -> state 2 -// instanceView->activateState(state2Instance); -// QCOMPARE(state1Instance == instanceView->activeStateInstance(), false); -// QCOMPARE(state2Instance == instanceView->activeStateInstance(), true); -// QCOMPARE(textInstance.property("x").toInt(), 0); -// QCOMPARE(textInstance.property("text").toString(), QString("state2")); - -// // state 1 -> base state -// instanceView->activateBaseState(); -// QCOMPARE(state1Instance == instanceView->activeStateInstance(), false); -// QCOMPARE(state2Instance == instanceView->activeStateInstance(), false); -// QCOMPARE(textInstance.property("x").toInt(), 0); -// QCOMPARE(textInstance.property("text").toString(), QString("base state")); - -// // -// // Add/Change/Remove properties in current state -// // -// instanceView->activateState(state1Instance); - -// propertyChanges1Node.variantProperty("x").setValue(20); -// QCOMPARE(textInstance.property("x").toInt(), 20); -// propertyChanges1Node.variantProperty("x").setValue(10); // undo -// QCOMPARE(textInstance.property("x").toInt(), 10); - -// QCOMPARE(textInstance.property("y").toInt(), 0); -// propertyChanges1Node.variantProperty("y").setValue(50); -// QCOMPARE(textInstance.property("y").toInt(), 50); -// propertyChanges1Node.removeProperty("y"); -// QCOMPARE(textInstance.property("y").toInt(), 0); - -// QCOMPARE(textInstance.property("text").toString(), QString("state1")); -// propertyChanges1Node.removeProperty("text"); -// QCOMPARE(textInstance.property("text").toString(), QString("base state")); -// propertyChanges1Node.variantProperty("text").setValue("state1"); // undo -// QCOMPARE(textInstance.property("text").toString(), QString("state1")); - -////// Following is not supported. We work around this -////// by _always_ changing to the base state before doing any changes to the -////// state structure. - -// // -// // Reparenting state actions (while state is active) -// // - -// // move property changes of current state out of state -// ModelNode state3Node = view->createModelNode("QtQuick.State", 1, 1); -// QDeclarativeListReference changes(state1, "changes"); -// QCOMPARE(changes.count(), 1); -// state3Node.nodeListProperty("changes").reparentHere(propertyChanges1Node); - -// QCOMPARE(changes.count(), 0); -// QCOMPARE(textInstance.property("text").toString(), QString("base state")); - -// // undo -// state1Node.nodeListProperty("changes").reparentHere(propertyChanges1Node); -// QCOMPARE(changes.count(), 1); -// QCOMPARE(textInstance.property("text").toString(), QString("state1")); - - -// // change base state if in state1 - -// textNode.variantProperty("text").setValue("state1 and base state"); -// QCOMPARE(textInstance.property("text").toString(), QString("state1")); -// instanceView->activateBaseState(); -// QCOMPARE(textInstance.property("text").toString(), QString("state1 and base state")); -// textNode.variantProperty("text").setValue("base state"); - -// // expressions -// ModelNode textNode2 = view->createModelNode("QtQuick.Text", 1, 1); -// textNode2.setId("targetObject2"); -// textNode2.variantProperty("text").setValue("textNode2"); - - -// rootNode.nodeListProperty("data").reparentHere(textNode2); - -// propertyChanges1Node.bindingProperty("text").setExpression("targetObject2.text"); - -// instanceView->activateState(state1Instance); - -// QCOMPARE(textInstance.property("text").toString(), QString("textNode2")); -// propertyChanges1Node.removeProperty("text"); -// QCOMPARE(textInstance.property("text").toString(), QString("base state")); -// propertyChanges1Node.variantProperty("text").setValue("state1"); -// QCOMPARE(textInstance.property("text").toString(), QString("state1")); - -// propertyChanges1Node.bindingProperty("text").setExpression("targetObject2.text"); -// QCOMPARE(textInstance.property("text").toString(), QString("textNode2")); - -// instanceView->activateBaseState(); -// QCOMPARE(textInstance.property("text").toString(), QString("base state")); + QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 2, 0)); + QVERIFY(model.data()); + QScopedPointer<TestView> view(new TestView(model.data())); + QVERIFY(view.data()); + model->attachView(view.data()); -// propertyChanges1Node.variantProperty("text").setValue("state1"); -// QCOMPARE(textInstance.property("text").toString(), QString("base state")); -// textNode.bindingProperty("text").setExpression("targetObject2.text"); -// QCOMPARE(textInstance.property("text").toString(), QString("textNode2")); + // + // build up model + // + ModelNode rootNode = view->rootModelNode(); -// instanceView->activateState(state1Instance); -// QCOMPARE(textInstance.property("text").toString(), QString("state1")); + ModelNode textNode = view->createModelNode("QtQuick.Text", 2, 0); + textNode.setIdWithoutRefactoring("targetObject"); + textNode.variantProperty("text").setValue("base state"); -// instanceView->activateBaseState(); -// QCOMPARE(textInstance.property("text").toString(), QString("textNode2")); -// textNode.variantProperty("text").setValue("base state"); + rootNode.nodeListProperty("data").reparentHere(textNode); -// instanceView->activateState(state1Instance); -// // -// // Removing state actions (while state is active) -// // + ModelNode propertyChanges1Node = view->createModelNode("QtQuick.PropertyChanges", 2, 0); + propertyChanges1Node.bindingProperty("target").setExpression("targetObject"); + propertyChanges1Node.variantProperty("x").setValue(10); + propertyChanges1Node.variantProperty("text").setValue("state1"); -// QCOMPARE(textInstance.property("text").toString(), QString("state1")); -// propertyChanges1Node.destroy(); -// QCOMPARE(changes.count(), 0); -// QCOMPARE(textInstance.property("text").toString(), QString("base state")); + ModelNode state1Node = view->createModelNode("QtQuick.State", 2, 0); + state1Node.variantProperty("name").setValue("state1"); + state1Node.nodeListProperty("changes").reparentHere(propertyChanges1Node); -// // -// // Removing state (while active) -// // + rootNode.nodeListProperty("states").reparentHere(state1Node); -// instanceView->activateState(state2Instance); -// QCOMPARE(textInstance.property("text").toString(), QString("state2")); -// state2Node.destroy(); + ModelNode propertyChanges2Node = view->createModelNode("QtQuick.PropertyChanges", 2, 0); + propertyChanges2Node.bindingProperty("target").setExpression("targetObject"); + propertyChanges2Node.variantProperty("text").setValue("state2"); -// QCOMPARE(textInstance.property("text").toString(), QString("base state")); + ModelNode state2Node = view->createModelNode("QtQuick.State", 2, 0); + state2Node.variantProperty("name").setValue("state2"); + state2Node.nodeListProperty("changes").reparentHere(propertyChanges2Node); + rootNode.nodeListProperty("states").reparentHere(state2Node); } void tst_TestCore::testStates() @@ -4859,7 +4685,7 @@ void tst_TestCore::testStatesBaseState() // } // - QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 1, 1)); + QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); QVERIFY(view.data()); @@ -4868,7 +4694,7 @@ void tst_TestCore::testStatesBaseState() // build up model ModelNode rootNode = view->rootModelNode(); - ModelNode textNode = view->createModelNode("QtQuick.Text", 1, 1); + ModelNode textNode = view->createModelNode("QtQuick.Text", 2, 0); textNode.setIdWithoutRefactoring("targetObject"); textNode.variantProperty("text").setValue("base state"); @@ -4897,7 +4723,7 @@ void tst_TestCore::testStatesBaseState() QVERIFY(textItem.propertyAffectedByCurrentState("text")); QApplication::processEvents(); - ModelNode newNode = view->createModelNode("QtQuick.Rectangle", 1, 0); + ModelNode newNode = view->createModelNode("QtQuick.Rectangle", 2, 0); QVERIFY(!QmlObjectNode(newNode).currentState().isBaseState()); view->setCurrentState(view->baseState()); //set currentState base state @@ -4916,14 +4742,13 @@ void tst_TestCore::testStatesBaseState() void tst_TestCore::testInstancesIdResolution() { - QSKIP("Instances are not working", SkipAll); - QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 1, 1)); + QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); QVERIFY(view.data()); model->attachView(view.data()); - // import QtQuick 1.1 + // import QtQuick 2.0 // // Rectangle { // id: root @@ -4941,18 +4766,18 @@ void tst_TestCore::testInstancesIdResolution() rootNode.variantProperty("width").setValue(100); rootNode.variantProperty("height").setValue(100); - ModelNode item1Node = view->createModelNode("QtQuick.Rectangle", 1, 0); + ModelNode item1Node = view->createModelNode("QtQuick.Rectangle", 2, 0); item1Node.setIdWithoutRefactoring("item1"); item1Node.bindingProperty("width").setExpression("root.width"); item1Node.bindingProperty("height").setExpression("item2.height"); rootNode.nodeListProperty("data").reparentHere(item1Node); - NodeInstance item1Instance = view->nodeInstanceView()->instanceForModelNode(item1Node); - QVERIFY(item1Instance.isValid()); + //NodeInstance item1Instance = view->nodeInstanceView()->instanceForModelNode(item1Node); + //QVERIFY(item1Instance.isValid()); - QCOMPARE(item1Instance.property("width").toInt(), 100); - QCOMPARE(item1Instance.property("height").toInt(), 0); // item2 is still unknown + //QCOMPARE(item1Instance.property("width").toInt(), 100); + //QCOMPARE(item1Instance.property("height").toInt(), 0); // item2 is still unknown // Add item2: // Rectangle { @@ -4961,24 +4786,24 @@ void tst_TestCore::testInstancesIdResolution() // height: root.height // } - ModelNode item2Node = view->createModelNode("QtQuick.Rectangle", 1, 0); + ModelNode item2Node = view->createModelNode("QtQuick.Rectangle", 2, 0); item2Node.setIdWithoutRefactoring("item2"); item2Node.bindingProperty("width").setExpression("root.width / 2"); item2Node.bindingProperty("height").setExpression("root.height"); rootNode.nodeListProperty("data").reparentHere(item2Node); - NodeInstance item2Instance = view->nodeInstanceView()->instanceForModelNode(item2Node); - QVERIFY(item2Instance.isValid()); + //NodeInstance item2Instance = view->nodeInstanceView()->instanceForModelNode(item2Node); + //QVERIFY(item2Instance.isValid()); - QCOMPARE(item2Instance.property("width").toInt(), 50); - QCOMPARE(item2Instance.property("height").toInt(), 100); - QCOMPARE(item1Instance.property("height").toInt(), 100); + //QCOMPARE(item2Instance.property("width").toInt(), 50); + //QCOMPARE(item2Instance.property("height").toInt(), 100); + //QCOMPARE(item1Instance.property("height").toInt(), 100); // Remove item2 again item2Node.destroy(); - QVERIFY(!item2Instance.isValid()); - QVERIFY(item2Instance.instanceId() >= 0); + //QVERIFY(!item2Instance.isValid()); + //QVERIFY(item2Instance.instanceId() >= 0); // Add item3: // Rectangle { @@ -4986,7 +4811,7 @@ void tst_TestCore::testInstancesIdResolution() // height: 80 // } - ModelNode item3Node = view->createModelNode("QtQuick.Rectangle", 1, 0); + ModelNode item3Node = view->createModelNode("QtQuick.Rectangle", 2, 0); item3Node.setIdWithoutRefactoring("item3"); item3Node.variantProperty("height").setValue(80); rootNode.nodeListProperty("data").reparentHere(item3Node); @@ -4994,27 +4819,26 @@ void tst_TestCore::testInstancesIdResolution() // Change item1.height: item3.height item1Node.bindingProperty("height").setExpression("item3.height"); - QCOMPARE(item1Instance.property("height").toInt(), 80); + //QCOMPARE(item1Instance.property("height").toInt(), 80); } void tst_TestCore::testInstancesNotInScene() { - QSKIP("Instances are not working", SkipAll); // // test whether deleting an instance which is not in the scene crashes // - QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 1, 1)); + QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); QVERIFY(view.data()); model->attachView(view.data()); - ModelNode node1 = view->createModelNode("QtQuick.Item", 1, 1); + ModelNode node1 = view->createModelNode("QtQuick.Item", 2, 0); node1.setIdWithoutRefactoring("node1"); - ModelNode node2 = view->createModelNode("QtQuick.Item", 1, 1); + ModelNode node2 = view->createModelNode("QtQuick.Item", 2, 0); node2.setIdWithoutRefactoring("node2"); node1.nodeListProperty("children").reparentHere(node2); @@ -5027,21 +4851,21 @@ void tst_TestCore::testInstancesBindingsInStatesStress() QSKIP("Instances are not working", SkipAll); //This is a stress test to provoke a crash for (int j=0;j<20;j++) { - QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 1, 1)); + QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); QVERIFY(view.data()); model->attachView(view.data()); - ModelNode node1 = view->createModelNode("QtQuick.Item", 1, 1); + ModelNode node1 = view->createModelNode("QtQuick.Item", 2, 0); node1.setIdWithoutRefactoring("node1"); view->rootModelNode().nodeListProperty("children").reparentHere(node1); - ModelNode node2 = view->createModelNode("QtQuick.Rectangle", 1, 0); + ModelNode node2 = view->createModelNode("QtQuick.Rectangle", 2, 0); node2.setIdWithoutRefactoring("node2"); - ModelNode node3 = view->createModelNode("QtQuick.Rectangle", 1, 0); + ModelNode node3 = view->createModelNode("QtQuick.Rectangle", 2, 0); node3.setIdWithoutRefactoring("node3"); node1.nodeListProperty("children").reparentHere(node2); @@ -5133,21 +4957,21 @@ void tst_TestCore::testInstancesPropertyChangeTargets() //this tests checks if a change of the target of a CropertyChange //node is handled correctly - QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 1, 1)); + QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); QVERIFY(view.data()); model->attachView(view.data()); - ModelNode node1 = view->createModelNode("QtQuick.Item", 1, 1); + ModelNode node1 = view->createModelNode("QtQuick.Item", 2, 0); node1.setIdWithoutRefactoring("node1"); view->rootModelNode().nodeListProperty("children").reparentHere(node1); - ModelNode node2 = view->createModelNode("QtQuick.Rectangle", 1, 0); + ModelNode node2 = view->createModelNode("QtQuick.Rectangle", 2, 0); node2.setIdWithoutRefactoring("node2"); - ModelNode node3 = view->createModelNode("QtQuick.Rectangle", 1, 0); + ModelNode node3 = view->createModelNode("QtQuick.Rectangle", 2, 0); node3.setIdWithoutRefactoring("node3"); node1.nodeListProperty("children").reparentHere(node2); @@ -5240,21 +5064,21 @@ void tst_TestCore::testInstancesPropertyChangeTargets() void tst_TestCore::testInstancesDeletePropertyChanges() { QSKIP("Instances are not working", SkipAll); - QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 1, 1)); + QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); QVERIFY(view.data()); model->attachView(view.data()); - ModelNode node1 = view->createModelNode("QtQuick.Item", 1, 1); + ModelNode node1 = view->createModelNode("QtQuick.Item", 2, 0); node1.setIdWithoutRefactoring("node1"); view->rootModelNode().nodeListProperty("children").reparentHere(node1); - ModelNode node2 = view->createModelNode("QtQuick.Rectangle", 1, 0); + ModelNode node2 = view->createModelNode("QtQuick.Rectangle", 2, 0); node2.setIdWithoutRefactoring("node2"); - ModelNode node3 = view->createModelNode("QtQuick.Rectangle", 1, 0); + ModelNode node3 = view->createModelNode("QtQuick.Rectangle", 2, 0); node3.setIdWithoutRefactoring("node3"); node1.nodeListProperty("children").reparentHere(node2); @@ -5757,7 +5581,7 @@ void tst_TestCore::testInstancesReorderChildrenLowLevel() void tst_TestCore::testQmlModelStatesInvalidForRemovedNodes() { - QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 1, 1)); + QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -5774,11 +5598,11 @@ void tst_TestCore::testQmlModelStatesInvalidForRemovedNodes() QVERIFY(state1.isValid()); QCOMPARE(state1.name(), QString("state1")); - ModelNode childNode = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode childNode = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); QVERIFY(childNode.isValid()); childNode.setIdWithoutRefactoring("childNode"); - ModelNode subChildNode = addNodeListChild(childNode, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode subChildNode = addNodeListChild(childNode, "QtQuick.Rectangle", 2, 0, "data"); QVERIFY(subChildNode.isValid()); subChildNode.setIdWithoutRefactoring("subChildNode"); @@ -5800,7 +5624,7 @@ void tst_TestCore::testInstancesAttachToExistingModel() QSKIP("Instances are not working", SkipAll); - QScopedPointer<Model> model(createModel("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -5808,7 +5632,7 @@ void tst_TestCore::testInstancesAttachToExistingModel() model->attachView(view.data()); ModelNode rootNode = view->rootModelNode(); - ModelNode rectangleNode = addNodeListChild(rootNode, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode rectangleNode = addNodeListChild(rootNode, "QtQuick.Rectangle", 2, 0, "data"); rectangleNode.variantProperty("width").setValue(100); @@ -5832,7 +5656,7 @@ void tst_TestCore::testInstancesAttachToExistingModel() void tst_TestCore::testQmlModelAddMultipleStates() { - QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 1, 1)); + QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -5863,7 +5687,7 @@ void tst_TestCore::testQmlModelAddMultipleStates() void tst_TestCore::testQmlModelRemoveStates() { - QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 1, 1)); + QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 2, 0)); QScopedPointer<TestView> view(new TestView(model.data())); QVERIFY(view.data()); @@ -5892,7 +5716,6 @@ void tst_TestCore::testQmlModelRemoveStates() void tst_TestCore::testQmlModelStateWithName() { - QSKIP("Crashing for unkwown reasons", SkipAll); QPlainTextEdit textEdit1; textEdit1.setPlainText("import QtQuick 2.1; Rectangle { id: theRect; width: 100; states: [ State { name: \"a\"; PropertyChanges { target: theRect; width: 200; } } ] }\n"); NotIndentingTextEditModifier modifier1(&textEdit1); @@ -5926,17 +5749,17 @@ void tst_TestCore::testQmlModelStateWithName() rootNode.setVariantProperty("width", 112); - const QLatin1String expected1("import QtQuick 1.1; Rectangle { id: theRect; width: 100; states: [ State { name: \"a\"; PropertyChanges { target: theRect; width: 112 } } ] }\n"); + const QLatin1String expected1("import QtQuick 2.1; Rectangle { id: theRect; width: 100; states: [ State { name: \"a\"; PropertyChanges { target: theRect; width: 112 } } ] }\n"); QCOMPARE(textEdit1.toPlainText(), expected1); QVERIFY(!rootNode.isInBaseState()); - QCOMPARE(rootNode.instanceValue("width").toInt(), 112); + //QCOMPARE(rootNode.instanceValue("width").toInt(), 112); view->setCurrentState(view->baseState()); - QCOMPARE(rootNode.instanceValue("width").toInt(), 100); + //QCOMPARE(rootNode.instanceValue("width").toInt(), 100); view->setCurrentState(rootNode.states().allStates().at(0)); - QCOMPARE(rootNode.instanceValue("width").toInt(), 112); + //QCOMPARE(rootNode.instanceValue("width").toInt(), 112); modelState.destroy(); @@ -5966,7 +5789,7 @@ void tst_TestCore::testRewriterAutomaticSemicolonAfterChangedProperty() void tst_TestCore::defaultPropertyValues() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -5976,12 +5799,12 @@ void tst_TestCore::defaultPropertyValues() QCOMPARE(view->rootModelNode().variantProperty("x").value().toDouble(), 0.0); QCOMPARE(view->rootModelNode().variantProperty("width").value().toDouble(), 0.0); - ModelNode rectNode(addNodeListChild(view->rootModelNode(), "QtQuick.Rectangle", 1, 0, "data")); + ModelNode rectNode(addNodeListChild(view->rootModelNode(), "QtQuick.Rectangle", 2, 0, "data")); QCOMPARE(rectNode.variantProperty("y").value().toDouble(), 0.0); QCOMPARE(rectNode.variantProperty("width").value().toDouble(), 0.0); - ModelNode imageNode(addNodeListChild(view->rootModelNode(), "QtQuick.Image", 1, 0, "data")); + ModelNode imageNode(addNodeListChild(view->rootModelNode(), "QtQuick.Image", 2, 0, "data")); QCOMPARE(imageNode.variantProperty("y").value().toDouble(), 0.0); QCOMPARE(imageNode.variantProperty("width").value().toDouble(), 0.0); @@ -5990,7 +5813,7 @@ void tst_TestCore::defaultPropertyValues() void tst_TestCore::testModelPropertyValueTypes() { QPlainTextEdit textEdit1; - textEdit1.setPlainText("import QtQuick 1.1; Rectangle { width: 100; radius: 1.5; color: \"red\"; }"); + textEdit1.setPlainText("import QtQuick 2.1; Rectangle { width: 100; radius: 1.5; color: \"red\"; }"); NotIndentingTextEditModifier modifier1(&textEdit1); QScopedPointer<Model> model1(Model::create("QtQuick.Item")); @@ -6011,7 +5834,7 @@ void tst_TestCore::testModelPropertyValueTypes() void tst_TestCore::testModelNodeInHierarchy() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -6019,9 +5842,9 @@ void tst_TestCore::testModelNodeInHierarchy() model->attachView(view.data()); QVERIFY(view->rootModelNode().isInHierarchy()); - ModelNode node1 = addNodeListChild(view->rootModelNode(), "QtQuick.Item", 1, 1, "data"); + ModelNode node1 = addNodeListChild(view->rootModelNode(), "QtQuick.Item", 2, 1, "data"); QVERIFY(node1.isInHierarchy()); - ModelNode node2 = view->createModelNode("QtQuick.Item", 1, 1); + ModelNode node2 = view->createModelNode("QtQuick.Item", 2, 1); QVERIFY(!node2.isInHierarchy()); node2.nodeListProperty("data").reparentHere(node1); QVERIFY(!node2.isInHierarchy()); @@ -6032,11 +5855,11 @@ void tst_TestCore::testModelNodeInHierarchy() void tst_TestCore::testModelNodeIsAncestorOf() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); // - // import QtQuick 1.1 + // import QtQuick 2.0 // Item { // Item { // id: item2 @@ -6054,11 +5877,11 @@ void tst_TestCore::testModelNodeIsAncestorOf() model->attachView(view.data()); view->rootModelNode().setIdWithoutRefactoring("item1"); - ModelNode item2 = addNodeListChild(view->rootModelNode(), "QtQuick.Item", 1, 1, "data"); + ModelNode item2 = addNodeListChild(view->rootModelNode(), "QtQuick.Item", 2, 0, "data"); item2.setIdWithoutRefactoring("item2"); - ModelNode item3 = addNodeListChild(view->rootModelNode(), "QtQuick.Item", 1, 1, "data"); + ModelNode item3 = addNodeListChild(view->rootModelNode(), "QtQuick.Item", 2, 0, "data"); item3.setIdWithoutRefactoring("item3"); - ModelNode item4 = addNodeListChild(item3, "QtQuick.Item", 1, 1, "data"); + ModelNode item4 = addNodeListChild(item3, "QtQuick.Item", 2, 0, "data"); item4.setIdWithoutRefactoring("item4"); QVERIFY(view->rootModelNode().isAncestorOf(item2)); @@ -6071,7 +5894,7 @@ void tst_TestCore::testModelNodeIsAncestorOf() void tst_TestCore::testModelDefaultProperties() { - QScopedPointer<Model> model(createModel("QtQuick.Rectangle")); + QScopedPointer<Model> model(createModel("QtQuick.Rectangle", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -6086,9 +5909,9 @@ void tst_TestCore::testModelDefaultProperties() void tst_TestCore::loadAnchors() { - QSKIP("Crashing for unkwown reasons", SkipAll); + QSKIP("Crashing because of instance accesss", SkipAll); QPlainTextEdit textEdit1; - textEdit1.setPlainText("import QtQuick 1.1; Item { width: 100; height: 100; Rectangle { anchors.left: parent.left; anchors.horizontalCenter: parent.horizontalCenter; anchors.rightMargin: 20; }}"); + textEdit1.setPlainText("import QtQuick 2.1; Item { width: 100; height: 100; Rectangle { anchors.left: parent.left; anchors.horizontalCenter: parent.horizontalCenter; anchors.rightMargin: 20; }}"); NotIndentingTextEditModifier modifier1(&textEdit1); QScopedPointer<Model> model(Model::create("QtQuick.Item")); @@ -6126,9 +5949,9 @@ void tst_TestCore::loadAnchors() void tst_TestCore::changeAnchors() { - QSKIP("Crashing for unkwown reasons", SkipAll); + QSKIP("Requires instances", SkipAll); QPlainTextEdit textEdit1; - textEdit1.setPlainText("import QtQuick 1.1; Item { width: 100; height: 100; Rectangle { anchors.left: parent.left; anchors.horizontalCenter: parent.horizontalCenter; anchors.rightMargin: 20; }}"); + textEdit1.setPlainText("import QtQuick 2.1; Item { width: 100; height: 100; Rectangle { anchors.left: parent.left; anchors.horizontalCenter: parent.horizontalCenter; anchors.rightMargin: 20; }}"); NotIndentingTextEditModifier modifier1(&textEdit1); QScopedPointer<Model> model(Model::create("QtQuick.Item")); @@ -6188,9 +6011,9 @@ void tst_TestCore::changeAnchors() void tst_TestCore::anchorToSibling() { - QSKIP("Crashing for unkwown reasons", SkipAll); + QSKIP("Requires instances", SkipAll); QPlainTextEdit textEdit1; - textEdit1.setPlainText("import QtQuick 1.1; Item { Rectangle {} Rectangle { id: secondChild } }"); + textEdit1.setPlainText("import QtQuick 2.1; Item { Rectangle {} Rectangle { id: secondChild } }"); NotIndentingTextEditModifier modifier1(&textEdit1); QScopedPointer<Model> model(Model::create("QtQuick.Item")); @@ -6233,9 +6056,9 @@ void tst_TestCore::anchorToSibling() void tst_TestCore::removeFillAnchorByDetaching() { - QSKIP("Crashing for unkwown reasons", SkipAll); + QSKIP("Requires instances", SkipAll); QPlainTextEdit textEdit1; - textEdit1.setPlainText("import QtQuick 1.1; Item { width: 100; height: 100; Rectangle { id: child; anchors.fill: parent } }"); + textEdit1.setPlainText("import QtQuick 2.1; Item { width: 100; height: 100; Rectangle { id: child; anchors.fill: parent } }"); NotIndentingTextEditModifier modifier1(&textEdit1); QScopedPointer<Model> model(Model::create("QtQuick.Item")); @@ -6314,9 +6137,9 @@ void tst_TestCore::removeFillAnchorByDetaching() void tst_TestCore::removeFillAnchorByChanging() { - QSKIP("Crashing for unkwown reasons", SkipAll); + QSKIP("Requires instances", SkipAll); QPlainTextEdit textEdit1; - textEdit1.setPlainText("import QtQuick 1.1; Item { width: 100; height: 100; Rectangle { id: child; anchors.fill: parent } }"); + textEdit1.setPlainText("import QtQuick 2.1; Item { width: 100; height: 100; Rectangle { id: child; anchors.fill: parent } }"); NotIndentingTextEditModifier modifier1(&textEdit1); QScopedPointer<Model> model(Model::create("QtQuick.Item")); @@ -6396,7 +6219,7 @@ void tst_TestCore::removeFillAnchorByChanging() void tst_TestCore::testModelBindings() { - QScopedPointer<Model> model(createModel("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); //NodeInstanceView *nodeInstanceView = new NodeInstanceView(model.data(), NodeInstanceServerInterface::TestModus); @@ -6419,7 +6242,7 @@ void tst_TestCore::testModelBindings() //QCOMPARE(rootInstance.size().width(), 200.0); //QCOMPARE(rootInstance.size().height(), 100.0); - ModelNode childNode = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode childNode = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); childNode.variantProperty("width").setValue(100); childNode.variantProperty("height").setValue(100); @@ -6459,8 +6282,7 @@ void tst_TestCore::testModelBindings() void tst_TestCore::testModelDynamicProperties() { - MSKIP_ALL("Fix rewriter dynamic properties writing"); - QScopedPointer<Model> model(createModel("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); TestView *testView = new TestView(model.data()); @@ -6479,13 +6301,14 @@ void tst_TestCore::testModelDynamicProperties() QCOMPARE(rootModelNode.property("myColor").dynamicTypeName(), QmlDesigner::TypeName("color")); QCOMPARE(rootModelNode.variantProperty("myColor").value(), QVariant(QColor(Qt::red))); - //QCOMPARE(rootQmlItemNode.instanceValue("myColor"), QVariant(Qt::red)); //not working yet QCOMPARE(rootModelNode.property("myDouble").dynamicTypeName(), QmlDesigner::TypeName("real")); QCOMPARE(rootModelNode.variantProperty("myDouble").value(), QVariant(10)); - //QCOMPARE(rootQmlItemNode.instanceValue("myDouble"), QVariant(10)); //not working yet QVERIFY(rootModelNode.property("x").dynamicTypeName().isEmpty()); + model->rewriterView()->setCheckSemanticErrors(false); + + rootModelNode.removeProperty("myDouble"); rootModelNode.variantProperty("myDouble").setValue(QVariant(10)); QVERIFY(!rootModelNode.property("myDouble").isDynamic()); @@ -6605,13 +6428,13 @@ void tst_TestCore::testRewriterChangeId() QCOMPARE(textEdit.toPlainText(), expected); // change id for node outside of hierarchy - ModelNode node = view->createModelNode("QtQuick.Item", 1, 1); + ModelNode node = view->createModelNode("QtQuick.Item", 2, 0); node.setIdWithoutRefactoring("myId"); } void tst_TestCore::testRewriterRemoveId() { - const char* qmlString = "import QtQuick 1.1\nRectangle { id: rect }"; + const char* qmlString = "import QtQuick 2.1\nRectangle { id: rect }"; QPlainTextEdit textEdit; textEdit.setPlainText(QString::fromUtf8(qmlString)); @@ -6635,7 +6458,7 @@ void tst_TestCore::testRewriterRemoveId() // // remove id in text // - const char* qmlString2 = "import QtQuick 1.1\nRectangle { }"; + const char* qmlString2 = "import QtQuick 2.1\nRectangle { }"; textEdit.setPlainText(QString::fromUtf8(qmlString2)); QCOMPARE(rootModelNode.id(), QString()); @@ -6643,7 +6466,7 @@ void tst_TestCore::testRewriterRemoveId() void tst_TestCore::testRewriterChangeValueProperty() { - const char* qmlString = "import QtQuick 1.1\nRectangle { x: 10; y: 10 }"; + const char* qmlString = "import QtQuick 2.1\nRectangle { x: 10; y: 10 }"; QPlainTextEdit textEdit; textEdit.setPlainText(QString::fromUtf8(qmlString)); @@ -6679,7 +6502,7 @@ void tst_TestCore::testRewriterChangeValueProperty() void tst_TestCore::testRewriterRemoveValueProperty() { const QLatin1String qmlString("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "Rectangle {\n" " x: 10\n" " y: 10;\n" @@ -6710,7 +6533,7 @@ void tst_TestCore::testRewriterRemoveValueProperty() rootModelNode.removeProperty("x"); const QLatin1String expected("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "Rectangle {\n" " y: 10;\n" "}\n"); @@ -6725,7 +6548,7 @@ void tst_TestCore::testRewriterRemoveValueProperty() void tst_TestCore::testRewriterSignalProperty() { - const char* qmlString = "import QtQuick 1.1\nRectangle { onColorChanged: {} }"; + const char* qmlString = "import QtQuick 2.1\nRectangle { onColorChanged: {} }"; QPlainTextEdit textEdit; textEdit.setPlainText(QString::fromUtf8(qmlString)); @@ -6750,7 +6573,7 @@ void tst_TestCore::testRewriterSignalProperty() void tst_TestCore::testRewriterObjectTypeProperty() { - const char* qmlString = "import QtQuick 1.1\nRectangle { x: 10; y: 10 }"; + const char* qmlString = "import QtQuick 2.1\nRectangle { x: 10; y: 10 }"; QPlainTextEdit textEdit; textEdit.setPlainText(QString::fromUtf8(qmlString)); @@ -6772,7 +6595,7 @@ void tst_TestCore::testRewriterObjectTypeProperty() QCOMPARE(rootModelNode.type(), QmlDesigner::TypeName("QtQuick.Rectangle")); - view->changeRootNodeType("QtQuick.Text", 1, 1); + view->changeRootNodeType("QtQuick.Text", 2, 0); QCOMPARE(rootModelNode.type(), QmlDesigner::TypeName("QtQuick.Text")); } @@ -6784,7 +6607,7 @@ void tst_TestCore::testRewriterPropertyChanges() // Use a slightly more complicated example so that target properties are not resolved in default scope const char* qmlString - = "import QtQuick 1.1\n" + = "import QtQuick 2.1\n" "Rectangle {\n" " Text {\n" " id: targetObj\n" @@ -6804,7 +6627,7 @@ void tst_TestCore::testRewriterPropertyChanges() textEdit.setPlainText(QString::fromUtf8(qmlString)); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -6851,17 +6674,15 @@ void tst_TestCore::testRewriterPropertyChanges() void tst_TestCore::testRewriterListModel() { - MSKIP_ALL("See BAUHAUS-157"); - try { // ListModel uses a custom parser - const char* qmlString = "import QtQuick 1.1; ListModel {\n ListElement {\n age: 12\n} \n}"; + const char* qmlString = "import QtQuick 2.1; ListModel {\n ListElement {\n age: 12\n} \n}"; QPlainTextEdit textEdit; textEdit.setPlainText(QString::fromUtf8(qmlString)); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestRewriterView> testRewriterView(new TestRewriterView()); @@ -6872,9 +6693,8 @@ void tst_TestCore::testRewriterListModel() model->attachView(view.data()); ModelNode listModelNode = view->rootModelNode(); - //QCOMPARE(listModelNode.propertyNames(), QStringList() << "__elements"); // TODO: what should be the name? - NodeListProperty elementListProperty = listModelNode.nodeListProperty("__elements"); + NodeListProperty elementListProperty = listModelNode.defaultNodeListProperty(); QCOMPARE(elementListProperty.toModelNodeList().size(), 1); ModelNode elementNode = elementListProperty.toModelNodeList().at(0); @@ -6890,7 +6710,7 @@ void tst_TestCore::testRewriterListModel() void tst_TestCore::testRewriterAddProperty() { const QLatin1String qmlString("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" "}"); @@ -6898,7 +6718,7 @@ void tst_TestCore::testRewriterAddProperty() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -6920,7 +6740,7 @@ void tst_TestCore::testRewriterAddProperty() QCOMPARE(rootNode.variantProperty(("x")).value(), QVariant(123)); const QLatin1String expected("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" "x: 123\n" @@ -6931,7 +6751,7 @@ void tst_TestCore::testRewriterAddProperty() void tst_TestCore::testRewriterAddPropertyInNestedObject() { const QLatin1String qmlString("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " Rectangle {\n" @@ -6942,7 +6762,7 @@ void tst_TestCore::testRewriterAddPropertyInNestedObject() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -6966,7 +6786,7 @@ void tst_TestCore::testRewriterAddPropertyInNestedObject() childNode.variantProperty(("y")).setValue(10); const QLatin1String expected("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " Rectangle {\n" @@ -6980,7 +6800,7 @@ void tst_TestCore::testRewriterAddPropertyInNestedObject() void tst_TestCore::testRewriterAddObjectDefinition() { - const QLatin1String qmlString("import QtQuick 1.1\n" + const QLatin1String qmlString("import QtQuick 2.1\n" "\n" "Rectangle {\n" "}"); @@ -6988,7 +6808,7 @@ void tst_TestCore::testRewriterAddObjectDefinition() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -7003,7 +6823,7 @@ void tst_TestCore::testRewriterAddObjectDefinition() QVERIFY(rootNode.isValid()); QCOMPARE(rootNode.type(), QmlDesigner::TypeName("QtQuick.Rectangle")); - ModelNode childNode = view->createModelNode("QtQuick.MouseArea", 1, 1); + ModelNode childNode = view->createModelNode("QtQuick.MouseArea", 2, 0); rootNode.nodeAbstractProperty("data").reparentHere(childNode); QCOMPARE(rootNode.nodeProperty("data").toNodeListProperty().toModelNodeList().size(), 1); @@ -7014,7 +6834,7 @@ void tst_TestCore::testRewriterAddObjectDefinition() void tst_TestCore::testRewriterAddStatesArray() { const QLatin1String qmlString("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" "}"); @@ -7022,7 +6842,7 @@ void tst_TestCore::testRewriterAddStatesArray() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -7036,11 +6856,11 @@ void tst_TestCore::testRewriterAddStatesArray() QVERIFY(rootNode.isValid()); QCOMPARE(rootNode.type(), QmlDesigner::TypeName("QtQuick.Rectangle")); - ModelNode stateNode = view->createModelNode("QtQuick.State", 1, 0); + ModelNode stateNode = view->createModelNode("QtQuick.State", 2, 0); rootNode.nodeListProperty(("states")).reparentHere(stateNode); const QString expected1 = QLatin1String("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" "states: [\n" @@ -7050,11 +6870,11 @@ void tst_TestCore::testRewriterAddStatesArray() "}"); QCOMPARE(textEdit.toPlainText(), expected1); - ModelNode stateNode2 = view->createModelNode("QtQuick.State", 1, 0); + ModelNode stateNode2 = view->createModelNode("QtQuick.State", 2, 0); rootNode.nodeListProperty(("states")).reparentHere(stateNode2); const QString expected2 = QLatin1String("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" "states: [\n" @@ -7070,7 +6890,7 @@ void tst_TestCore::testRewriterAddStatesArray() void tst_TestCore::testRewriterRemoveStates() { const QLatin1String qmlString("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " states: [\n" @@ -7084,7 +6904,7 @@ void tst_TestCore::testRewriterRemoveStates() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -7106,7 +6926,7 @@ void tst_TestCore::testRewriterRemoveStates() state.destroy(); const QLatin1String expected1("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " states: [\n" @@ -7120,7 +6940,7 @@ void tst_TestCore::testRewriterRemoveStates() state.destroy(); const QLatin1String expected2("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" "}"); @@ -7130,7 +6950,7 @@ void tst_TestCore::testRewriterRemoveStates() void tst_TestCore::testRewriterRemoveObjectDefinition() { const QLatin1String qmlString("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " MouseArea {\n" @@ -7142,7 +6962,7 @@ void tst_TestCore::testRewriterRemoveObjectDefinition() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -7172,7 +6992,7 @@ void tst_TestCore::testRewriterRemoveObjectDefinition() QVERIFY(!rootNode.hasProperty(("data"))); const QString expected = QLatin1String("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " // some comment here\n" @@ -7180,9 +7000,9 @@ void tst_TestCore::testRewriterRemoveObjectDefinition() QCOMPARE(textEdit.toPlainText(), expected); // don't crash when deleting nodes not in any hierarchy - ModelNode node1 = view->createModelNode("QtQuick.Rectangle", 1, 0); - ModelNode node2 = addNodeListChild(node1, "QtQuick.Item", 1, 1, "data"); - ModelNode node3 = addNodeListChild(node2, "QtQuick.Item", 1, 1, "data"); + ModelNode node1 = view->createModelNode("QtQuick.Rectangle", 2, 0); + ModelNode node2 = addNodeListChild(node1, "QtQuick.Item", 2, 1, "data"); + ModelNode node3 = addNodeListChild(node2, "QtQuick.Item", 2, 1, "data"); node3.destroy(); node1.destroy(); @@ -7191,7 +7011,7 @@ void tst_TestCore::testRewriterRemoveObjectDefinition() void tst_TestCore::testRewriterRemoveScriptBinding() { const QLatin1String qmlString("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " x: 10; // some comment\n" @@ -7201,7 +7021,7 @@ void tst_TestCore::testRewriterRemoveScriptBinding() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -7231,7 +7051,7 @@ void tst_TestCore::testRewriterRemoveScriptBinding() QCOMPARE(rootNode.properties().size(), 0); const QString expected = QLatin1String("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " // some comment\n" @@ -7242,7 +7062,7 @@ void tst_TestCore::testRewriterRemoveScriptBinding() void tst_TestCore::testRewriterNodeReparenting() { const QLatin1String qmlString("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " Item {\n" @@ -7254,7 +7074,7 @@ void tst_TestCore::testRewriterNodeReparenting() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -7283,7 +7103,7 @@ void tst_TestCore::testRewriterNodeReparenting() QCOMPARE(rootNode.nodeListProperty("data").toModelNodeList().size(), 2); QString expected = "\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " Item {\n" @@ -7295,9 +7115,9 @@ void tst_TestCore::testRewriterNodeReparenting() QCOMPARE(textEdit.toPlainText(), expected); // reparenting outside of the hierarchy - ModelNode node1 = view->createModelNode("QtQuick.Rectangle", 1, 0); - ModelNode node2 = view->createModelNode("QtQuick.Item", 1, 1); - ModelNode node3 = view->createModelNode("QtQuick.Item", 1, 1); + ModelNode node1 = view->createModelNode("QtQuick.Rectangle", 2, 0); + ModelNode node2 = view->createModelNode("QtQuick.Item", 2, 1); + ModelNode node3 = view->createModelNode("QtQuick.Item", 2, 1); node2.nodeListProperty("data").reparentHere(node3); node1.nodeListProperty("data").reparentHere(node2); @@ -7305,7 +7125,7 @@ void tst_TestCore::testRewriterNodeReparenting() rootNode.nodeListProperty("data").reparentHere(node1); expected = "\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " Item {\n" @@ -7325,11 +7145,11 @@ void tst_TestCore::testRewriterNodeReparenting() QCOMPARE(textEdit.toPlainText(), expected); // reparent out of the hierarchy - ModelNode node4 = view->createModelNode("QtQuick.Rectangle", 1, 0); + ModelNode node4 = view->createModelNode("QtQuick.Rectangle", 2, 0); node4.nodeListProperty("data").reparentHere(node1); expected = "\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " Item {\n" @@ -7345,7 +7165,7 @@ void tst_TestCore::testRewriterNodeReparenting() void tst_TestCore::testRewriterNodeReparentingWithTransaction() { const QLatin1String qmlString("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " id: rootItem\n" @@ -7362,7 +7182,7 @@ void tst_TestCore::testRewriterNodeReparentingWithTransaction() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -7396,7 +7216,7 @@ void tst_TestCore::testRewriterNodeReparentingWithTransaction() transaction.commit(); const QLatin1String expected("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " id: rootItem\n" @@ -7415,7 +7235,7 @@ void tst_TestCore::testRewriterNodeReparentingWithTransaction() void tst_TestCore::testRewriterMovingInOut() { const QLatin1String qmlString("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" "}"); @@ -7423,7 +7243,7 @@ void tst_TestCore::testRewriterMovingInOut() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -7438,11 +7258,11 @@ void tst_TestCore::testRewriterMovingInOut() QVERIFY(rootNode.isValid()); QCOMPARE(rootNode.type(), QmlDesigner::TypeName("QtQuick.Rectangle")); - ModelNode newNode = view->createModelNode("QtQuick.MouseArea", 1, 1); + ModelNode newNode = view->createModelNode("QtQuick.MouseArea", 2, 0); rootNode.nodeListProperty("data").reparentHere(newNode); const QLatin1String expected1("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" "MouseArea {\n" @@ -7461,7 +7281,7 @@ void tst_TestCore::testRewriterMovingInOut() newNode.destroy(); const QLatin1String expected2("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" "}"); @@ -7473,7 +7293,7 @@ void tst_TestCore::testRewriterMovingInOut() void tst_TestCore::testRewriterMovingInOutWithTransaction() { const QLatin1String qmlString("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" "}"); @@ -7481,7 +7301,7 @@ void tst_TestCore::testRewriterMovingInOutWithTransaction() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -7498,7 +7318,7 @@ void tst_TestCore::testRewriterMovingInOutWithTransaction() RewriterTransaction transaction = view->beginRewriterTransaction("TEST"); - ModelNode newNode = view->createModelNode("QtQuick.MouseArea", 1, 1); + ModelNode newNode = view->createModelNode("QtQuick.MouseArea", 2, 1); rootNode.nodeListProperty("data").reparentHere(newNode); #define move(node, x, y) {\ @@ -7514,7 +7334,7 @@ void tst_TestCore::testRewriterMovingInOutWithTransaction() transaction.commit(); const QLatin1String expected2("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" "}"); @@ -7525,7 +7345,7 @@ void tst_TestCore::testRewriterMovingInOutWithTransaction() void tst_TestCore::testRewriterComplexMovingInOut() { const QLatin1String qmlString("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " Item {\n" @@ -7535,7 +7355,7 @@ void tst_TestCore::testRewriterComplexMovingInOut() textEdit.setPlainText(qmlString); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -7551,11 +7371,11 @@ void tst_TestCore::testRewriterComplexMovingInOut() QCOMPARE(rootNode.type(), QmlDesigner::TypeName("QtQuick.Rectangle")); ModelNode itemNode = rootNode.nodeListProperty("data").toModelNodeList().at(0); - ModelNode newNode = view->createModelNode("QtQuick.MouseArea", 1, 1); + ModelNode newNode = view->createModelNode("QtQuick.MouseArea", 2, 0); rootNode.nodeListProperty("data").reparentHere(newNode); const QLatin1String expected1("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " Item {\n" @@ -7575,7 +7395,7 @@ void tst_TestCore::testRewriterComplexMovingInOut() move(newNode, 3, 3); const QLatin1String expected2("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " Item {\n" @@ -7591,7 +7411,7 @@ void tst_TestCore::testRewriterComplexMovingInOut() itemNode.nodeListProperty(("data")).reparentHere(newNode); const QLatin1String expected3("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " Item {\n" @@ -7611,7 +7431,7 @@ void tst_TestCore::testRewriterComplexMovingInOut() newNode.destroy(); const QLatin1String expected4("\n" - "import QtQuick 1.1\n" + "import QtQuick 2.1\n" "\n" "Rectangle {\n" " Item {\n" @@ -7625,7 +7445,7 @@ void tst_TestCore::removeCenteredInAnchorByDetaching() { QSKIP("Crashing for unkwown reasons", SkipAll); QPlainTextEdit textEdit1; - textEdit1.setPlainText("import QtQuick 1.1; Item { Rectangle { id: child; anchors.centerIn: parent } }"); + textEdit1.setPlainText("import QtQuick 2.1; Item { Rectangle { id: child; anchors.centerIn: parent } }"); NotIndentingTextEditModifier modifier1(&textEdit1); QScopedPointer<Model> model(Model::create("QtQuick.Item")); @@ -7679,7 +7499,7 @@ void tst_TestCore::removeCenteredInAnchorByDetaching() void tst_TestCore::changePropertyBinding() { - QScopedPointer<Model> model(createModel("QtQuick.Item")); + QScopedPointer<Model> model(createModel("QtQuick.Item", 2, 0)); QVERIFY(model.data()); QScopedPointer<TestView> view(new TestView(model.data())); @@ -7688,7 +7508,7 @@ void tst_TestCore::changePropertyBinding() ModelNode rootModelNode(view->rootModelNode()); rootModelNode.variantProperty("width").setValue(20); - ModelNode firstChild = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 1, 0, "data"); + ModelNode firstChild = addNodeListChild(rootModelNode, "QtQuick.Rectangle", 2, 0, "data"); firstChild.bindingProperty("width").setExpression(QString("parent.width")); firstChild.variantProperty("height").setValue(10); QVERIFY(firstChild.isValid()); @@ -7751,7 +7571,7 @@ void tst_TestCore::loadTestFiles() textEdit.setPlainText(QString(QString::fromUtf8(file.readAll()))); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestRewriterView> testRewriterView(new TestRewriterView()); @@ -7781,7 +7601,7 @@ void tst_TestCore::loadTestFiles() textEdit.setPlainText(QString(QString::fromUtf8(file.readAll()))); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestRewriterView> testRewriterView(new TestRewriterView()); @@ -7830,7 +7650,7 @@ void tst_TestCore::loadTestFiles() textEdit.setPlainText(QString(QString::fromUtf8(file.readAll()))); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestRewriterView> testRewriterView(new TestRewriterView()); @@ -7847,7 +7667,7 @@ void tst_TestCore::loadTestFiles() } } -static QString rectWithGradient = "import QtQuick 1.1\n" +static QString rectWithGradient = "import QtQuick 2.1\n" "Rectangle {\n" " gradient: Gradient {\n" " id: pGradient\n" @@ -7867,7 +7687,7 @@ void tst_TestCore::loadGradient() textEdit.setPlainText(rectWithGradient); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestRewriterView> testRewriterView(new TestRewriterView()); @@ -7964,7 +7784,7 @@ void tst_TestCore::changeGradientId() textEdit.setPlainText(rectWithGradient); NotIndentingTextEditModifier textModifier(&textEdit); - QScopedPointer<Model> model(Model::create("QtQuick.Item", 1, 1)); + QScopedPointer<Model> model(Model::create("QtQuick.Item", 2, 1)); QVERIFY(model.data()); QScopedPointer<TestRewriterView> testRewriterView(new TestRewriterView()); @@ -7997,7 +7817,7 @@ void tst_TestCore::changeGradientId() firstStop.destroy(); QVERIFY(!firstStop.isValid()); - ModelNode gradientStop = addNodeListChild(gradientNode, "QtQuick.GradientStop", 1, 0, "stops"); + ModelNode gradientStop = addNodeListChild(gradientNode, "QtQuick.GradientStop", 2, 0, "stops"); gradientStop.variantProperty("position").setValue(0.5); gradientStop.variantProperty("color").setValue(QColor("yellow")); diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.h b/tests/auto/qml/qmldesigner/coretests/tst_testcore.h index 08e4265519..fdb09811c9 100644 --- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.h +++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.h @@ -149,7 +149,7 @@ private slots: // unit tests Instances // void testInstancesAttachToExistingModel(); - void testInstancesStates(); + void testStatesWasInstances(); void testInstancesIdResolution(); void testInstancesNotInScene(); void testInstancesBindingsInStatesStress(); diff --git a/tests/auto/qml/qmldesigner/data/fx/subitems/SubItem.qml b/tests/auto/qml/qmldesigner/data/fx/subitems/SubItem.qml index b457bfe38c..1783100846 100644 --- a/tests/auto/qml/qmldesigner/data/fx/subitems/SubItem.qml +++ b/tests/auto/qml/qmldesigner/data/fx/subitems/SubItem.qml @@ -23,12 +23,12 @@ ** ****************************************************************************/ -import Qt 4.7 +import QtQuick 2.0 Rectangle { property string text - width : {toprect.width} + width : toprect.width height : 20 color : "blue" Text { diff --git a/tests/auto/qml/qmldesigner/data/fx/topitem.qml b/tests/auto/qml/qmldesigner/data/fx/topitem.qml index 759d1330c4..a36ab04f0a 100644 --- a/tests/auto/qml/qmldesigner/data/fx/topitem.qml +++ b/tests/auto/qml/qmldesigner/data/fx/topitem.qml @@ -23,13 +23,13 @@ ** ****************************************************************************/ -import Qt 4.7 -import Qt 4.7 as Qt46 +import QtQuick 2.0 +import QtQuick 2.0 as Qt2 import "subitems" import "subitems" as Subdir -Qt46.Rectangle { - id : "toprect" +Qt2.Rectangle { + id : toprect width : 100 height : 50 SubItem { |