From a484bb240d064249b116b2364400c9a2fc5eef71 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann <Thomas.Hartmann@nokia.com> Date: Thu, 20 May 2010 16:44:05 +0200 Subject: [PATCH] QmlDesigner.tests: an integration test for the metaInfo --- .../qml/qmldesigner/coretests/testcore.cpp | 36 +++++++++++++++++++ .../auto/qml/qmldesigner/coretests/testcore.h | 1 + 2 files changed, 37 insertions(+) diff --git a/tests/auto/qml/qmldesigner/coretests/testcore.cpp b/tests/auto/qml/qmldesigner/coretests/testcore.cpp index bacf35716cb..2208c4f5e46 100644 --- a/tests/auto/qml/qmldesigner/coretests/testcore.cpp +++ b/tests/auto/qml/qmldesigner/coretests/testcore.cpp @@ -43,6 +43,7 @@ #include <rewritingexception.h> #include <nodeinstanceview.h> #include <nodeinstance.h> +#include <subcomponentmanager.h> #include <QDebug> #include "../testview.h" @@ -3244,6 +3245,38 @@ void TestCore::testCopyModelRewriter2() QCOMPARE(textEdit2.toPlainText(), qmlString1); } +void TestCore::testSubComponentManager() +{ + QString fileName = QString(QTCREATORDIR) + "/tests/auto/qml/qmldesigner/data/fx/usingmybutton.qml"; + QFile file(fileName); + QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); + + QPlainTextEdit textEdit; + textEdit.setPlainText(file.readAll()); + NotIndentingTextEditModifier modifier(&textEdit); + + QScopedPointer<Model> model(Model::create("Qt/Item")); + model->setFileUrl(QUrl::fromLocalFile(fileName)); + QScopedPointer<SubComponentManager> subComponentManager(new SubComponentManager(model->metaInfo(), 0)); + subComponentManager->update(QUrl::fromLocalFile(fileName), modifier.text().toUtf8()); + + QScopedPointer<TestRewriterView> testRewriterView(new TestRewriterView()); + testRewriterView->setTextModifier(&modifier); + model->attachView(testRewriterView.data()); + + QVERIFY(testRewriterView->errors().isEmpty()); + + QVERIFY(testRewriterView->rootModelNode().isValid()); + + + QVERIFY(model->metaInfo().nodeMetaInfo("Qt/Rectangle").properties(true).keys().contains("border.width")); + + QVERIFY(model->metaInfo().hasNodeMetaInfo("Qt/Pen")); + NodeMetaInfo myButtonMetaInfo = model->metaInfo().nodeMetaInfo("MyButton"); + QVERIFY(myButtonMetaInfo.isValid()); + QVERIFY(myButtonMetaInfo.properties(true).keys().contains("border.width")); + QVERIFY(myButtonMetaInfo.property("border.width", true).isValid()); +} void TestCore::loadQml() { @@ -3576,11 +3609,14 @@ void TestCore::testMetaInfoDotProperties() QVERIFY(!rectNode.metaInfo().properties().keys().contains("pos.x")); QVERIFY(rectNode.metaInfo().properties(true).keys().contains("pos.y")); QVERIFY(!rectNode.metaInfo().properties().keys().contains("pos.y")); + QVERIFY(!rectNode.metaInfo().properties().keys().contains("anchors.topMargin")); QVERIFY(rectNode.metaInfo().properties(true).keys().contains("border.width")); QVERIFY(rectNode.metaInfo().hasProperty("border")); QVERIFY(!rectNode.metaInfo().property("border").isValueType()); QVERIFY(rectNode.metaInfo().hasProperty("border.width", true)); QVERIFY(rectNode.metaInfo().property("border.width", true).isValid()); + QVERIFY(rectNode.metaInfo().property("border.width", true).isValid()); + QVERIFY(rectNode.metaInfo().property("anchors.topMargin", true).isValid()); } void TestCore::testMetaInfoListProperties() diff --git a/tests/auto/qml/qmldesigner/coretests/testcore.h b/tests/auto/qml/qmldesigner/coretests/testcore.h index 5ff29f3333e..91b4e1e0e5a 100644 --- a/tests/auto/qml/qmldesigner/coretests/testcore.h +++ b/tests/auto/qml/qmldesigner/coretests/testcore.h @@ -163,6 +163,7 @@ private slots: void testRewriterTransactionRewriter(); void testCopyModelRewriter1(); void testCopyModelRewriter2(); + void testSubComponentManager(); // // regression tests -- GitLab