diff options
author | Thomas Hartmann <Thomas.Hartmann@nokia.com> | 2010-05-25 17:49:57 +0200 |
---|---|---|
committer | Thomas Hartmann <Thomas.Hartmann@nokia.com> | 2010-05-25 17:51:19 +0200 |
commit | a952b9ba4e58d76fcadad259fc8ae54fa20b3b43 (patch) | |
tree | a5b23c76b3cd7d622d0678ea974617f0be05f915 /tests | |
parent | 441403bf60f3a81033a245516a74be2db686d001 (diff) | |
download | qt-creator-a952b9ba4e58d76fcadad259fc8ae54fa20b3b43.tar.gz |
QmlDesigner.autoTests
Integration tests
TestCore::testAnchorsAndRewriting
TestCore::testAnchorsAndRewritingCenter
Task-number: Bauhaus-109
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qmldesigner/coretests/testcore.cpp | 115 | ||||
-rw-r--r-- | tests/auto/qml/qmldesigner/coretests/testcore.h | 2 |
2 files changed, 117 insertions, 0 deletions
diff --git a/tests/auto/qml/qmldesigner/coretests/testcore.cpp b/tests/auto/qml/qmldesigner/coretests/testcore.cpp index 2208c4f5e4..43521af494 100644 --- a/tests/auto/qml/qmldesigner/coretests/testcore.cpp +++ b/tests/auto/qml/qmldesigner/coretests/testcore.cpp @@ -3278,6 +3278,121 @@ void TestCore::testSubComponentManager() QVERIFY(myButtonMetaInfo.property("border.width", true).isValid()); } +void TestCore::testAnchorsAndRewriting() +{ + const QString qmlString("import Qt 4.7\n" + "Rectangle {\n" + " id: root\n" + " x: 10;\n" + " y: 10;\n" + " Rectangle {\n" + " id: rectangle1\n" + " x: 10;\n" + " y: 10;\n" + " }\n" + " Component {\n" + " id: rectangleComponent\n" + " Rectangle {\n" + " x: 100;\n" + " y: 100;\n" + " }\n" + " }\n" + "}"); + + QSKIP("See BAUHAUS-729", SkipAll); + + QPlainTextEdit textEdit; + textEdit.setPlainText(qmlString); + NotIndentingTextEditModifier textModifier(&textEdit); + + QScopedPointer<Model> model(Model::create("Qt/Item", 4, 7)); + QVERIFY(model.data()); + + QScopedPointer<TestView> view(new TestView); + model->attachView(view.data()); + + // read in + QScopedPointer<TestRewriterView> testRewriterView(new TestRewriterView()); + testRewriterView->setTextModifier(&textModifier); + model->attachView(testRewriterView.data()); + + ModelNode rootNode = view->rootModelNode(); + QVERIFY(rootNode.isValid()); + QCOMPARE(rootNode.type(), QLatin1String("Qt/Rectangle")); + + QmlItemNode rootItemNode = view->rootQmlItemNode(); + QVERIFY(rootItemNode.isValid()); + + QmlItemNode childNode = rootItemNode.allDirectSubModelNodes().first(); + QVERIFY(childNode.isValid()); + + childNode.anchors().setMargin(AnchorLine::Left, 280); + childNode.anchors().setAnchor(AnchorLine::Left, rootItemNode, AnchorLine::Left); + childNode.anchors().setMargin(AnchorLine::Right, 200); + childNode.anchors().setAnchor(AnchorLine::Right, rootItemNode, AnchorLine::Right); + childNode.anchors().setMargin(AnchorLine::Bottom, 50); + childNode.anchors().setAnchor(AnchorLine::Bottom, rootItemNode, AnchorLine::Bottom); + + { + RewriterTransaction transaction = view->beginRewriterTransaction(); + + childNode.anchors().setMargin(AnchorLine::Top, 100); + childNode.anchors().setAnchor(AnchorLine::Top, rootItemNode, AnchorLine::Top); + } +} + +void TestCore::testAnchorsAndRewritingCenter() +{ + const QString qmlString("import Qt 4.7\n" + "Rectangle {\n" + " id: root\n" + " x: 10;\n" + " y: 10;\n" + " Rectangle {\n" + " id: rectangle1\n" + " x: 10;\n" + " y: 10;\n" + " }\n" + " Component {\n" + " id: rectangleComponent\n" + " Rectangle {\n" + " x: 100;\n" + " y: 100;\n" + " }\n" + " }\n" + "}"); + + //QSKIP("See BAUHAUS-729", SkipAll); + + QPlainTextEdit textEdit; + textEdit.setPlainText(qmlString); + NotIndentingTextEditModifier textModifier(&textEdit); + + QScopedPointer<Model> model(Model::create("Qt/Item", 4, 7)); + QVERIFY(model.data()); + + QScopedPointer<TestView> view(new TestView); + model->attachView(view.data()); + + // read in + QScopedPointer<TestRewriterView> testRewriterView(new TestRewriterView()); + testRewriterView->setTextModifier(&textModifier); + model->attachView(testRewriterView.data()); + + ModelNode rootNode = view->rootModelNode(); + QVERIFY(rootNode.isValid()); + QCOMPARE(rootNode.type(), QLatin1String("Qt/Rectangle")); + + QmlItemNode rootItemNode = view->rootQmlItemNode(); + QVERIFY(rootItemNode.isValid()); + + QmlItemNode childNode = rootItemNode.allDirectSubModelNodes().first(); + QVERIFY(childNode.isValid()); + + childNode.anchors().setAnchor(AnchorLine::VerticalCenter, rootItemNode, AnchorLine::VerticalCenter); + childNode.anchors().setAnchor(AnchorLine::HorizontalCenter, rootItemNode, AnchorLine::HorizontalCenter); +} + void TestCore::loadQml() { char qmlString[] = "import Qt 4.7\n" diff --git a/tests/auto/qml/qmldesigner/coretests/testcore.h b/tests/auto/qml/qmldesigner/coretests/testcore.h index 91b4e1e0e5..5bfd5e9320 100644 --- a/tests/auto/qml/qmldesigner/coretests/testcore.h +++ b/tests/auto/qml/qmldesigner/coretests/testcore.h @@ -164,6 +164,8 @@ private slots: void testCopyModelRewriter1(); void testCopyModelRewriter2(); void testSubComponentManager(); + void testAnchorsAndRewriting(); + void testAnchorsAndRewritingCenter(); // // regression tests |