aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmldesigner
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qmldesigner')
-rw-r--r--tests/auto/qml/qmldesigner/CMakeLists.txt1
-rw-r--r--tests/auto/qml/qmldesigner/coretests/CMakeLists.txt20
-rw-r--r--tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp40
-rw-r--r--tests/auto/qml/qmldesigner/coretests/tst_testcore.h1
4 files changed, 61 insertions, 1 deletions
diff --git a/tests/auto/qml/qmldesigner/CMakeLists.txt b/tests/auto/qml/qmldesigner/CMakeLists.txt
new file mode 100644
index 0000000000..9d4ab11adc
--- /dev/null
+++ b/tests/auto/qml/qmldesigner/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(coretests)
diff --git a/tests/auto/qml/qmldesigner/coretests/CMakeLists.txt b/tests/auto/qml/qmldesigner/coretests/CMakeLists.txt
new file mode 100644
index 0000000000..3e83f280af
--- /dev/null
+++ b/tests/auto/qml/qmldesigner/coretests/CMakeLists.txt
@@ -0,0 +1,20 @@
+# TODO: fix compiler errors
+return()
+
+add_qtc_test(tst_qml_testcore
+ DEPENDS qmljs Utils QmlEditorWidgets CPlusPlus Core QmlJSEditor
+ INCLUDES
+ "${CMAKE_SOURCE_DIR}/src/plugins/qmldesigner/designercore/include"
+ "${CMAKE_SOURCE_DIR}/src/plugins/qmldesigner/designercore"
+ "${CMAKE_SOURCE_DIR}/share/qtcreator/qml/qmlpuppet/interfaces"
+ "${CMAKE_SOURCE_DIR}/share/qtcreator/qml/qmlpuppet/types"
+ DEFINES
+ QT_CREATOR
+ QTCREATORDIR="${CMAKE_SOURCE_DIR}"
+ TESTSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}"
+ SOURCES
+ ../data/testfiles.qrc
+ ../testview.cpp ../testview.h
+ testrewriterview.cpp testrewriterview.h
+ tst_testcore.cpp tst_testcore.h
+)
diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp
index 1a4eda3bcc..31ea4e5914 100644
--- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp
+++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp
@@ -185,7 +185,7 @@ void tst_TestCore::initTestCase()
QFutureInterface<void> result;
QmlJS::PathsAndLanguages lPaths;
- lPaths.maybeInsert(Utils::FileName::fromString(basePaths.first()), QmlJS::Dialect::Qml);
+ lPaths.maybeInsert(Utils::FilePath::fromString(basePaths.first()), QmlJS::Dialect::Qml);
QmlJS::ModelManagerInterface::importScan(result, QmlJS::ModelManagerInterface::workingCopy(),
lPaths, QmlJS::ModelManagerInterface::instance(), false);
@@ -1017,6 +1017,44 @@ void tst_TestCore::testRewriterUnicodeChars()
QCOMPARE(textEdit.toPlainText(), unicodeChar);
}
+void tst_TestCore::testRewriterTransactionAddingAfterReparenting()
+{
+ const QLatin1String qmlString("\n"
+ "import QtQuick 2.0\n"
+ "\n"
+ "Item {\n"
+ "}\n");
+
+ QPlainTextEdit textEdit;
+ textEdit.setPlainText(qmlString);
+ NotIndentingTextEditModifier modifier(&textEdit);
+
+ QScopedPointer<Model> model(Model::create("QtQuick.Rectangle"));
+
+ QScopedPointer<TestRewriterView> testRewriterView(new TestRewriterView(0, RewriterView::Amend));
+ testRewriterView->setTextModifier(&modifier);
+ model->attachView(testRewriterView.data());
+
+ QVERIFY(testRewriterView->errors().isEmpty());
+
+ ModelNode rootModelNode = testRewriterView->rootModelNode();
+ QVERIFY(rootModelNode.isValid());
+
+ {
+ /* Regression test
+ * If a node is not a direct child node of the root item we did get an exception when adding properties
+ * after the reparent */
+
+ RewriterTransaction transaction = testRewriterView->beginRewriterTransaction("TEST");
+ ModelNode rectangle = testRewriterView->createModelNode("QtQuick.Rectangle", 2, 0);
+ rootModelNode.nodeListProperty("data").reparentHere(rectangle);
+ ModelNode rectangle2 = testRewriterView->createModelNode("QtQuick.Rectangle", 2, 0);
+ rectangle.nodeListProperty("data").reparentHere(rectangle2);
+
+ rectangle2.variantProperty("width").setValue(100);
+ }
+}
+
void tst_TestCore::testRewriterForGradientMagic()
{
const QLatin1String qmlString("\n"
diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.h b/tests/auto/qml/qmldesigner/coretests/tst_testcore.h
index 3f1eec576b..92f3b17161 100644
--- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.h
+++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.h
@@ -140,6 +140,7 @@ private slots:
void testRewriterImports();
void testRewriterChangeImports();
void testRewriterUnicodeChars();
+ void testRewriterTransactionAddingAfterReparenting();
//
// unit tests QmlModelNodeFacade/QmlModelState