summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qmldesigner/coretests/testcore.cpp67
-rw-r--r--tests/auto/qml/qmldesigner/coretests/testcore.h2
-rw-r--r--tests/auto/qml/qmldesigner/coretests/testrewriterview.cpp14
3 files changed, 75 insertions, 8 deletions
diff --git a/tests/auto/qml/qmldesigner/coretests/testcore.cpp b/tests/auto/qml/qmldesigner/coretests/testcore.cpp
index 43521af494..eaeeb0d2e2 100644
--- a/tests/auto/qml/qmldesigner/coretests/testcore.cpp
+++ b/tests/auto/qml/qmldesigner/coretests/testcore.cpp
@@ -700,6 +700,73 @@ void TestCore::testRewriterPreserveOrder()
}
}
+void TestCore::testRewriterActionCompression()
+{
+ const QLatin1String qmlString("\n"
+ "import Qt 4.7\n"
+ "\n"
+ "Rectangle {\n"
+ " id: root\n"
+ " Rectangle {\n"
+ " id: rect1\n"
+ " x: 10\n"
+ " y: 10\n"
+ " }\n"
+ " Rectangle {\n"
+ " id: rect2\n"
+ " x: 10\n"
+ " y: 10\n"
+ " }\n"
+ "}\n");
+
+ QPlainTextEdit textEdit;
+ textEdit.setPlainText(qmlString);
+ NotIndentingTextEditModifier modifier1(&textEdit);
+
+ QScopedPointer<Model> model1(Model::create("Qt/Rectangle"));
+
+ QScopedPointer<TestRewriterView> testRewriterView(new TestRewriterView());
+ testRewriterView->setTextModifier(&modifier1);
+ model1->attachView(testRewriterView.data());
+
+ QVERIFY(testRewriterView->errors().isEmpty());
+
+ ModelNode rootModelNode = testRewriterView->rootModelNode();
+ ModelNode rect1 = rootModelNode.property(QLatin1String("data")).toNodeListProperty().toModelNodeList().at(0);
+ ModelNode rect2 = rootModelNode.property(QLatin1String("data")).toNodeListProperty().toModelNodeList().at(1);
+
+ QVERIFY(rect1.isValid());
+ QVERIFY(rect2.isValid());
+
+ RewriterTransaction transaction = testRewriterView->beginRewriterTransaction();
+ rect1.nodeListProperty(QLatin1String("data")).reparentHere(rect2);
+ rect2.variantProperty(QLatin1String("x")).setValue(1.0);
+ rect2.variantProperty(QLatin1String("y")).setValue(1.0);
+
+ rootModelNode.nodeListProperty(QLatin1String("data")).reparentHere(rect2);
+ rect2.variantProperty(QLatin1String("x")).setValue(9.0);
+ rect2.variantProperty(QLatin1String("y")).setValue(9.0);
+ transaction.commit();
+
+ const QLatin1String expected("\n"
+ "import Qt 4.7\n"
+ "\n"
+ "Rectangle {\n"
+ " id: root\n"
+ " Rectangle {\n"
+ " id: rect1\n"
+ " x: 10\n"
+ " y: 10\n"
+ " }\n"
+ " Rectangle {\n"
+ " id: rect2\n"
+ " x: 9\n"
+ " y: 9\n"
+ " }\n"
+ "}\n");
+ QCOMPARE(textEdit.toPlainText(), expected);
+}
+
void TestCore::testRewriterForGradientMagic()
{
const QLatin1String qmlString("\n"
diff --git a/tests/auto/qml/qmldesigner/coretests/testcore.h b/tests/auto/qml/qmldesigner/coretests/testcore.h
index 5bfd5e9320..f3cbc8ebe8 100644
--- a/tests/auto/qml/qmldesigner/coretests/testcore.h
+++ b/tests/auto/qml/qmldesigner/coretests/testcore.h
@@ -127,7 +127,7 @@ private slots:
void testRewriterDynamicProperties();
void testRewriterGroupedProperties();
void testRewriterPreserveOrder();
-
+ void testRewriterActionCompression();
//
// unit tests QmlModelNodeFacade/QmlModelState
diff --git a/tests/auto/qml/qmldesigner/coretests/testrewriterview.cpp b/tests/auto/qml/qmldesigner/coretests/testrewriterview.cpp
index 7b340f0e09..b12c164a6d 100644
--- a/tests/auto/qml/qmldesigner/coretests/testrewriterview.cpp
+++ b/tests/auto/qml/qmldesigner/coretests/testrewriterview.cpp
@@ -37,8 +37,8 @@ using namespace QmlDesigner::Internal;
bool TestModelToTextMerger::isNodeScheduledForRemoval(const ModelNode &node) const
{
- foreach (const RewriteAction *action, scheduledRewriteActions()) {
- if (RemoveNodeRewriteAction const *removeAction = action->asRemoveNodeRewriteAction()) {
+ foreach (RewriteAction *action, scheduledRewriteActions()) {
+ if (RemoveNodeRewriteAction *removeAction = action->asRemoveNodeRewriteAction()) {
if (removeAction->node() == node)
return true;
}
@@ -49,14 +49,14 @@ bool TestModelToTextMerger::isNodeScheduledForRemoval(const ModelNode &node) con
bool TestModelToTextMerger::isNodeScheduledForAddition(const ModelNode &node) const
{
- foreach (const RewriteAction *action, scheduledRewriteActions()) {
- if (AddPropertyRewriteAction const *addPropertyAction = action->asAddPropertyRewriteAction()) {
+ foreach (RewriteAction *action, scheduledRewriteActions()) {
+ if (AddPropertyRewriteAction *addPropertyAction = action->asAddPropertyRewriteAction()) {
const AbstractProperty property = addPropertyAction->property();
if (property.isNodeProperty() && property.toNodeProperty().modelNode() == node)
return true;
else if (property.isNodeListProperty() && property.toNodeListProperty().toModelNodeList().contains(node))
return true;
- } else if (ChangePropertyRewriteAction const *changePropertyAction = action->asChangePropertyRewriteAction()) {
+ } else if (ChangePropertyRewriteAction *changePropertyAction = action->asChangePropertyRewriteAction()) {
const AbstractProperty property = changePropertyAction->property();
if (property.isNodeProperty() && property.toNodeProperty().modelNode() == node)
return true;
@@ -71,8 +71,8 @@ bool TestModelToTextMerger::isNodeScheduledForAddition(const ModelNode &node) co
VariantProperty TestModelToTextMerger::findAddedVariantProperty(const VariantProperty &property) const
{
- foreach (const RewriteAction *action, scheduledRewriteActions()) {
- if (AddPropertyRewriteAction const * addPropertyAction = action->asAddPropertyRewriteAction()) {
+ foreach (RewriteAction *action, scheduledRewriteActions()) {
+ if (AddPropertyRewriteAction *addPropertyAction = action->asAddPropertyRewriteAction()) {
const AbstractProperty candidate = addPropertyAction->property();
if (property.isVariantProperty() && property.toVariantProperty() == property)