summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-03-05 03:51:10 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-03-05 03:51:10 (GMT)
commit48fd47f64f3f73e82016161d82cdf67908a9c653 (patch)
treee337d89e525d3a55d2b9aca8c19d2b3b43c65c50 /tests/auto/declarative
parenta7b46bda37a428ae2e5554aa8e58469c92b310a9 (diff)
parentc9b3309ae1d3a34790d71fdfd7dcaab79433f049 (diff)
downloadQt-48fd47f64f3f73e82016161d82cdf67908a9c653.zip
Qt-48fd47f64f3f73e82016161d82cdf67908a9c653.tar.gz
Qt-48fd47f64f3f73e82016161d82cdf67908a9c653.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Conflicts: tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/examples/examples.pro2
-rw-r--r--tests/auto/declarative/examples/tst_examples.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp20
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml9
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scope.4.qml12
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.h13
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp38
-rw-r--r--tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml8
-rw-r--r--tests/auto/declarative/qdeclarativeitem/data/keys.qml2
-rw-r--r--tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp38
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml7
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml4
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.qml7
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.qml6
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.qml6
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp24
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp46
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/formatting.qml19
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp36
-rw-r--r--tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp37
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml2
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml2
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml6
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml7
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp20
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml4
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp20
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml10
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp70
36 files changed, 429 insertions, 58 deletions
diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro
index b9bcd28..85d2a73 100644
--- a/tests/auto/declarative/examples/examples.pro
+++ b/tests/auto/declarative/examples/examples.pro
@@ -3,3 +3,5 @@ contains(QT_CONFIG,declarative): QT += declarative
macx:CONFIG -= app_bundle
SOURCES += tst_examples.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp
index 106a4e0..678dd59 100644
--- a/tests/auto/declarative/examples/tst_examples.cpp
+++ b/tests/auto/declarative/examples/tst_examples.cpp
@@ -168,10 +168,12 @@ void tst_examples::examples_data()
QString examples = QLibraryInfo::location(QLibraryInfo::ExamplesPath);
QString demos = QLibraryInfo::location(QLibraryInfo::DemosPath);
+ QString snippets = QLatin1String(SRCDIR) + "/../../../../doc/src/snippets/";
QStringList files;
files << findQmlFiles(QDir(examples));
files << findQmlFiles(QDir(demos));
+ files << findQmlFiles(QDir(snippets));
foreach (const QString &file, files)
QTest::newRow(file.toLatin1().constData()) << file;
diff --git a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp
index 5f03989..f0117f5 100644
--- a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp
+++ b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp
@@ -60,6 +60,7 @@ private slots:
void setContextProperty();
void addDefaultObject();
void destruction();
+ void idAsContextProperty();
private:
QDeclarativeEngine engine;
@@ -429,6 +430,25 @@ void tst_qdeclarativecontext::destruction()
QCOMPARE(ctxt, expr.context());
}
+void tst_qdeclarativecontext::idAsContextProperty()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; QtObject { property var a; a: QtObject { id: myObject } }", QUrl());
+
+ QObject *obj = component.create();
+ QVERIFY(obj);
+
+ QVariant a = obj->property("a");
+ QVERIFY(a.userType() == QMetaType::QObjectStar);
+
+ QVariant ctxt = qmlContext(obj)->contextProperty("myObject");
+ QVERIFY(ctxt.userType() == QMetaType::QObjectStar);
+
+ QVERIFY(a == ctxt);
+
+ delete obj;
+}
+
QTEST_MAIN(tst_qdeclarativecontext)
#include "tst_qdeclarativecontext.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml b/tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml
new file mode 100644
index 0000000..4b5464d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+import Qt.test 1.0
+
+QtObject {
+ property int value: 9
+ property int value2
+
+ MyQmlObject.onMySignal: value2 = value
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml b/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml
index 3d45b15..5ba324a 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml
@@ -1,7 +1,7 @@
import Qt 4.6
Item {
- property alias x: item.x
+ property alias blah: item.x
Item { id: item }
function testFunction() { return 9; }
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scope.4.qml
new file mode 100644
index 0000000..d65b6e7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scope.4.qml
@@ -0,0 +1,12 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ id: a
+ property int b: 9
+
+ property int test
+ property string test2
+
+ // Should resolve to signal arguments, not to other elements in the file
+ onArgumentSignal: { test = a; test2 = b; }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
index 8fbd071..a283e3f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
@@ -60,10 +60,21 @@ class MyQmlAttachedObject : public QObject
{
Q_OBJECT
Q_PROPERTY(int value READ value CONSTANT)
+ Q_PROPERTY(int value2 READ value2 WRITE setValue2)
public:
- MyQmlAttachedObject(QObject *parent) : QObject(parent) {}
+ MyQmlAttachedObject(QObject *parent) : QObject(parent), m_value2(0) {}
int value() const { return 19; }
+ int value2() const { return m_value2; }
+ void setValue2(int v) { m_value2 = v; }
+
+ void emitMySignal() { emit mySignal(); }
+
+signals:
+ void mySignal();
+
+private:
+ int m_value2;
};
class MyQmlObject : public QObject
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 75ee7ce..b5649cb 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -123,6 +123,7 @@ private slots:
void multiEngineObject();
void deletedObject();
void scriptScope();
+ void attachedPropertyScope();
void bug1();
@@ -739,6 +740,23 @@ void tst_qdeclarativeecmascript::scope()
QCOMPARE(object->property("test2").toBool(), true);
QCOMPARE(object->property("test3").toBool(), true);
}
+
+ // Signal argument scope
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("scope.4.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 0);
+ QCOMPARE(object->property("test2").toString(), QString());
+
+ emit object->argumentSignal(13, "Argument Scope", 9);
+
+ QCOMPARE(object->property("test").toInt(), 13);
+ QCOMPARE(object->property("test2").toString(), QString("Argument Scope"));
+
+ delete object;
+ }
}
/*
@@ -1693,6 +1711,26 @@ void tst_qdeclarativeecmascript::scriptScope()
}
}
+void tst_qdeclarativeecmascript::attachedPropertyScope()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("attachedPropertyScope.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ MyQmlAttachedObject *attached =
+ qobject_cast<MyQmlAttachedObject *>(qmlAttachedPropertiesObject<MyQmlObject>(object));
+ QVERIFY(attached != 0);
+
+ QCOMPARE(object->property("value2").toInt(), 0);
+
+ attached->emitMySignal();
+
+ QCOMPARE(object->property("value2").toInt(), 9);
+
+ delete object;
+}
+
QTEST_MAIN(tst_qdeclarativeecmascript)
#include "tst_qdeclarativeecmascript.moc"
diff --git a/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml b/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml
index 9281a17..08da901 100644
--- a/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml
+++ b/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml
@@ -11,6 +11,8 @@ Grid {
color: focus ? "red" : "lightgray"
KeyNavigation.right: item2
KeyNavigation.down: item3
+ KeyNavigation.tab: item2
+ KeyNavigation.backtab: item4
}
Rectangle {
id: item2
@@ -19,6 +21,8 @@ Grid {
color: focus ? "red" : "lightgray"
KeyNavigation.left: item1
KeyNavigation.down: item4
+ KeyNavigation.tab: item3
+ KeyNavigation.backtab: item1
}
Rectangle {
id: item3
@@ -27,6 +31,8 @@ Grid {
color: focus ? "red" : "lightgray"
KeyNavigation.right: item4
KeyNavigation.up: item1
+ KeyNavigation.tab: item4
+ KeyNavigation.backtab: item2
}
Rectangle {
id: item4
@@ -35,5 +41,7 @@ Grid {
color: focus ? "red" : "lightgray"
KeyNavigation.left: item3
KeyNavigation.up: item2
+ KeyNavigation.tab: item1
+ KeyNavigation.backtab: item3
}
}
diff --git a/tests/auto/declarative/qdeclarativeitem/data/keys.qml b/tests/auto/declarative/qdeclarativeitem/data/keys.qml
index f3c1f7b..7d34fc8 100644
--- a/tests/auto/declarative/qdeclarativeitem/data/keys.qml
+++ b/tests/auto/declarative/qdeclarativeitem/data/keys.qml
@@ -7,6 +7,8 @@ Item {
Keys.onReturnPressed: keysTestObject.keyPress(event.key, "Return", event.modifiers)
Keys.onDigit0Pressed: keysTestObject.keyPress(event.key, event.text, event.modifiers)
Keys.onDigit9Pressed: { event.accepted = false; keysTestObject.keyPress(event.key, event.text, event.modifiers) }
+ Keys.onTabPressed: keysTestObject.keyPress(event.key, "Tab", event.modifiers)
+ Keys.onBacktabPressed: keysTestObject.keyPress(event.key, "Backtab", event.modifiers)
Keys.forwardTo: [ item2 ]
Keys.enabled: enableKeyHanding
diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
index 5549a3e..bbcc86e 100644
--- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
+++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
@@ -178,6 +178,26 @@ void tst_QDeclarativeItem::keys()
testObject->reset();
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_Tab));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Tab));
+ QCOMPARE(testObject->mText, QLatin1String("Tab"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_Backtab));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Backtab));
+ QCOMPARE(testObject->mText, QLatin1String("Backtab"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false));
key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
@@ -243,6 +263,24 @@ void tst_QDeclarativeItem::keyNavigation()
QVERIFY(item);
QVERIFY(item->hasFocus());
+ // tab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2");
+ QVERIFY(item);
+ QVERIFY(item->hasFocus());
+
+ // backtab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasFocus());
+
delete canvas;
}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml
index aecb3c3..b46ec34 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml
@@ -3,8 +3,6 @@ import Test 1.0 as Namespace
import Qt 4.6
QtObject {
- property int value2: 8
MyQmlObject.value: 10
Namespace.MyQmlObject.value2: 13
- MyQmlObject.onValueChanged: value2 = MyQmlObject.value
}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml
new file mode 100644
index 0000000..7cd6a83
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+QtObject {
+ property int on
+
+ Component.onCompleted: on = 10
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt
index 945d51b..32055f6 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt
@@ -1 +1 @@
-7:9:Invalid value in grouped property
+7:9:Cannot assign a value directly to a grouped property
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt
new file mode 100644
index 0000000..d4e0cc0
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt
@@ -0,0 +1 @@
+3:1:Element is not creatable.
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml
new file mode 100644
index 0000000..a723269
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml
@@ -0,0 +1,4 @@
+import Qt 4.6
+
+Font {
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.errors.txt
new file mode 100644
index 0000000..1fcb1b6
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.errors.txt
@@ -0,0 +1 @@
+4:14:Cannot assign a value directly to a grouped property
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.qml
new file mode 100644
index 0000000..41aa3e2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ grouped: "10x10"
+ grouped.value: 10
+}
+
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.errors.txt
new file mode 100644
index 0000000..fa0da21
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.errors.txt
@@ -0,0 +1 @@
+5:19:Property has already been assigned a value
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.qml
new file mode 100644
index 0000000..56fca9b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ pointProperty: "10x10"
+ pointProperty.x: 10
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.errors.txt
new file mode 100644
index 0000000..6d837a7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.errors.txt
@@ -0,0 +1 @@
+5:20:Property has already been assigned a value
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.qml
new file mode 100644
index 0000000..982ab26
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ pointProperty.x: 10
+ pointProperty: "10x10"
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index 5d480fa..da0bf1a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -128,6 +128,8 @@ private slots:
void qmlAttachedPropertiesObjectMethod();
+ void customOnProperty();
+
// regression tests for crashes
void crash1();
void crash2();
@@ -255,6 +257,9 @@ void tst_qdeclarativelanguage::errors_data()
QTest::newRow("invalidGroupedProperty.5") << "invalidGroupedProperty.5.qml" << "invalidGroupedProperty.5.errors.txt" << false;
QTest::newRow("invalidGroupedProperty.6") << "invalidGroupedProperty.6.qml" << "invalidGroupedProperty.6.errors.txt" << false;
QTest::newRow("invalidGroupedProperty.7") << "invalidGroupedProperty.7.qml" << "invalidGroupedProperty.7.errors.txt" << true;
+ QTest::newRow("invalidGroupedProperty.8") << "invalidGroupedProperty.8.qml" << "invalidGroupedProperty.8.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.9") << "invalidGroupedProperty.9.qml" << "invalidGroupedProperty.9.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.10") << "invalidGroupedProperty.10.qml" << "invalidGroupedProperty.10.errors.txt" << false;
QTest::newRow("importNamespaceConflict") << "importNamespaceConflict.qml" << "importNamespaceConflict.errors.txt" << false;
QTest::newRow("importVersionMissing (builtin)") << "importVersionMissingBuiltIn.qml" << "importVersionMissingBuiltIn.errors.txt" << false;
@@ -321,6 +326,7 @@ void tst_qdeclarativelanguage::errors_data()
QTest::newRow("invalidRoot") << "invalidRoot.qml" << "invalidRoot.errors.txt" << false;
QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false;
QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false;
+ QTest::newRow("enumTypes") << "enumTypes.qml" << "enumTypes.errors.txt" << false;
}
@@ -713,11 +719,6 @@ void tst_qdeclarativelanguage::attachedProperties()
QVERIFY(attached != 0);
QCOMPARE(attached->property("value"), QVariant(10));
QCOMPARE(attached->property("value2"), QVariant(13));
-
- QEXPECT_FAIL("", "QTBUG-8677", Abort);
- attached->setProperty("value", QVariant(12));
- int val = object->property("value2").toInt();
- QCOMPARE(val, 12);
}
// Tests non-static object properties
@@ -1394,6 +1395,19 @@ void tst_qdeclarativelanguage::crash2()
QDeclarativeComponent component(&engine, TEST_FILE("crash2.qml"));
}
+// QTBUG-8676
+void tst_qdeclarativelanguage::customOnProperty()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("customOnProperty.qml"));
+
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("on").toInt(), 10);
+
+ delete object;
+}
void tst_qdeclarativelanguage::initTestCase()
{
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index a36224f..1df4448 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -450,7 +450,7 @@ void tst_QDeclarativeListView::inserted()
model.insertItem(1, "Will", "9876");
// let transitions settle.
- QTest::qWait(500);
+ QTest::qWait(300);
QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
@@ -470,7 +470,7 @@ void tst_QDeclarativeListView::inserted()
model.insertItem(0, "Foo", "1111"); // zero index, and current item
// let transitions settle.
- QTest::qWait(500);
+ QTest::qWait(300);
QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
@@ -491,14 +491,14 @@ void tst_QDeclarativeListView::inserted()
for (int i = model.count(); i < 30; ++i)
model.insertItem(i, "Hello", QString::number(i));
- QTest::qWait(500);
+ QTest::qWait(300);
listview->setContentY(80);
- QTest::qWait(500);
+ QTest::qWait(300);
// Insert item outside visible area
model.insertItem(1, "Hello", "1324");
- QTest::qWait(500);
+ QTest::qWait(300);
QVERIFY(listview->contentY() == 80);
@@ -543,7 +543,7 @@ void tst_QDeclarativeListView::removed(bool animated)
model.removeItem(1);
// let transitions settle.
- QTest::qWait(500);
+ QTest::qWait(300);
QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
QVERIFY(name != 0);
@@ -565,7 +565,7 @@ void tst_QDeclarativeListView::removed(bool animated)
model.removeItem(0); // post: top item starts at 20
// let transitions settle.
- QTest::qWait(500);
+ QTest::qWait(300);
name = findItem<QDeclarativeText>(viewport, "textName", 0);
QVERIFY(name != 0);
@@ -586,7 +586,7 @@ void tst_QDeclarativeListView::removed(bool animated)
// Remove items not visible
model.removeItem(18);
// let transitions settle.
- QTest::qWait(500);
+ QTest::qWait(300);
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
@@ -603,7 +603,7 @@ void tst_QDeclarativeListView::removed(bool animated)
model.removeItem(1); // post: top item will be at 40
// let transitions settle.
- QTest::qWait(500);
+ QTest::qWait(300);
// Confirm items positioned correctly
for (int i = 2; i < 18; ++i) {
@@ -617,14 +617,14 @@ void tst_QDeclarativeListView::removed(bool animated)
QVERIFY(listview->currentIndex() == 9);
QDeclarativeItem *oldCurrent = listview->currentItem();
model.removeItem(9);
- QTest::qWait(500);
+ QTest::qWait(300);
QCOMPARE(listview->currentIndex(), 9);
QVERIFY(listview->currentItem() != oldCurrent);
listview->setContentY(40); // That's the top now
// let transitions settle.
- QTest::qWait(500);
+ QTest::qWait(300);
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
@@ -637,20 +637,20 @@ void tst_QDeclarativeListView::removed(bool animated)
// remove current item beyond visible items.
listview->setCurrentIndex(20);
- QTest::qWait(500);
+ QTest::qWait(300);
listview->setContentY(40);
model.removeItem(20);
- QTest::qWait(500);
+ QTest::qWait(300);
QCOMPARE(listview->currentIndex(), 20);
QVERIFY(listview->currentItem() != 0);
// remove item before current, but visible
listview->setCurrentIndex(8);
- QTest::qWait(500);
+ QTest::qWait(300);
oldCurrent = listview->currentItem();
model.removeItem(6);
- QTest::qWait(500);
+ QTest::qWait(300);
QCOMPARE(listview->currentIndex(), 7);
QVERIFY(listview->currentItem() == oldCurrent);
@@ -1028,22 +1028,16 @@ void tst_QDeclarativeListView::currentIndex()
QCOMPARE(listview->contentY(), 0.0);
// Test keys
+ qApp->setActiveWindow(canvas);
canvas->show();
+ canvas->setFocus();
qApp->processEvents();
- QEvent wa(QEvent::WindowActivate);
- QApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QApplication::sendEvent(canvas, &fe);
-
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
+ QTest::keyClick(canvas, Qt::Key_Down);
+ QEXPECT_FAIL("", "QTBUG-8475", Abort);
QCOMPARE(listview->currentIndex(), 1);
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
+ QTest::keyClick(canvas, Qt::Key_Up);
QCOMPARE(listview->currentIndex(), 0);
// turn off auto highlight
diff --git a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml b/tests/auto/declarative/qdeclarativeqt/data/formatting.qml
new file mode 100644
index 0000000..e62749a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeqt/data/formatting.qml
@@ -0,0 +1,19 @@
+import Qt 4.6
+
+QtObject {
+ property date date1: "2008-12-24"
+ property string test1: Qt.formatDate(date1)
+ property string test2: Qt.formatDate(date1, Qt.DefaultLocaleLongDate)
+ property string test3: Qt.formatDate(date1, "ddd MMMM d yy")
+
+ property var time1: new Date(0,0,0,14,15,38,200)
+ property string test4: Qt.formatTime(time1)
+ property string test5: Qt.formatTime(time1, Qt.DefaultLocaleLongDate)
+ property string test6: Qt.formatTime(time1, "H:m:s a")
+ property string test7: Qt.formatTime(time1, "hh:mm:ss.zzz")
+
+ property var dateTime1: new Date(1978,2,4,9,13,54)
+ property string test8: Qt.formatDateTime(dateTime1)
+ property string test9: Qt.formatDateTime(dateTime1, Qt.DefaultLocaleLongDate)
+ property string test10: Qt.formatDateTime(dateTime1, "M/d/yy H:m:s a")
+}
diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
index 9ec6872..90afd4e 100644
--- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
+++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
@@ -67,12 +67,12 @@ private slots:
void darker();
void tint();
void closestAngle();
- void playSound();
void openUrlExternally();
void md5();
void createComponent();
void createQmlObject();
void consoleLog();
+ void formatting();
private:
QDeclarativeEngine engine;
@@ -279,12 +279,6 @@ void tst_qdeclarativeqt::closestAngle()
delete object;
}
-void tst_qdeclarativeqt::playSound()
-{
- QEXPECT_FAIL("", "How do we test this?", Abort);
- QVERIFY(false);
-}
-
void tst_qdeclarativeqt::openUrlExternally()
{
QEXPECT_FAIL("", "How do we test this?", Abort);
@@ -364,6 +358,34 @@ void tst_qdeclarativeqt::consoleLog()
delete object;
}
+void tst_qdeclarativeqt::formatting()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("formatting.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QDate date1(2008,12,24);
+ QCOMPARE(object->property("date1").toDate(), date1);
+ QCOMPARE(object->property("test1").toString(), date1.toString(Qt::DefaultLocaleShortDate));
+ QCOMPARE(object->property("test2").toString(), date1.toString(Qt::DefaultLocaleLongDate));
+ QCOMPARE(object->property("test3").toString(), date1.toString("ddd MMMM d yy"));
+
+ QTime time1(14,15,38,200);
+ QCOMPARE(object->property("time1").toTime(), time1);
+ QCOMPARE(object->property("test4").toString(), time1.toString(Qt::DefaultLocaleShortDate));
+ QCOMPARE(object->property("test5").toString(), time1.toString(Qt::DefaultLocaleLongDate));
+ QCOMPARE(object->property("test6").toString(), time1.toString("H:m:s a"));
+ QCOMPARE(object->property("test7").toString(), time1.toString("hh:mm:ss.zzz"));
+
+ QDateTime dateTime1(QDate(1978,03,04),QTime(9,13,54));
+ QCOMPARE(object->property("dateTime1").toDateTime(),dateTime1);
+ QCOMPARE(object->property("test8").toString(), dateTime1.toString(Qt::DefaultLocaleShortDate));
+ QCOMPARE(object->property("test9").toString(), dateTime1.toString(Qt::DefaultLocaleLongDate));
+ QCOMPARE(object->property("test10").toString(), dateTime1.toString("M/d/yy H:m:s a"));
+
+ delete object;
+}
+
QTEST_MAIN(tst_qdeclarativeqt)
#include "tst_qdeclarativeqt.moc"
diff --git a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp
index b120d5d..1dfec50 100644
--- a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp
+++ b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp
@@ -38,6 +38,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#include <QtTest/QSignalSpy>
#include <qtest.h>
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
@@ -161,6 +162,18 @@ void tst_qdeclarativetimer::repeat()
QVERIFY(helper.count == oldCount);
QVERIFY(timer->isRunning() == false);
+ QSignalSpy spy(timer, SIGNAL(repeatChanged()));
+
+ timer->setRepeating(false);
+ QVERIFY(!timer->isRepeating());
+ QCOMPARE(spy.count(),1);
+
+ timer->setRepeating(false);
+ QCOMPARE(spy.count(),1);
+
+ timer->setRepeating(true);
+ QCOMPARE(spy.count(),2);
+
delete timer;
}
@@ -184,6 +197,18 @@ void tst_qdeclarativetimer::triggeredOnStart()
QCOMPARE(helper.count, 2);
QVERIFY(timer->isRunning() == false);
+ QSignalSpy spy(timer, SIGNAL(triggeredOnStartChanged()));
+
+ timer->setTriggeredOnStart(false);
+ QVERIFY(!timer->triggeredOnStart());
+ QCOMPARE(spy.count(),1);
+
+ timer->setTriggeredOnStart(false);
+ QCOMPARE(spy.count(),1);
+
+ timer->setTriggeredOnStart(true);
+ QCOMPARE(spy.count(),2);
+
delete timer;
}
@@ -250,6 +275,18 @@ void tst_qdeclarativetimer::changeDuration()
QCOMPARE(helper.count, 3);
QVERIFY(timer->isRunning());
+ QSignalSpy spy(timer, SIGNAL(intervalChanged()));
+
+ timer->setInterval(200);
+ QCOMPARE(timer->interval(), 200);
+ QCOMPARE(spy.count(),1);
+
+ timer->setInterval(200);
+ QCOMPARE(spy.count(),1);
+
+ timer->setInterval(300);
+ QCOMPARE(spy.count(),2);
+
delete timer;
}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml
index 0eadd50..cb01a80 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml
@@ -1,6 +1,6 @@
import Test 1.0
MyTypeObject {
- font.capitalization: "MixedCase"
+ font.capitalization: "AllUppercase"
}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml
index 81f1c92..93f1ed5 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml
@@ -1,6 +1,6 @@
import Test 1.0
MyTypeObject {
- font.capitalization: if (1) "MixedCase"
+ font.capitalization: if (1) "AllUppercase"
}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml
new file mode 100644
index 0000000..3be5099
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+import Qt 4.6
+
+MyTypeObject {
+ font.capitalization: Font.AllUppercase
+}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml
new file mode 100644
index 0000000..6b494e4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+import Qt 4.6 as MyQt
+
+MyTypeObject {
+ font.capitalization: MyQt.Font.AllUppercase
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
index 8732215..51f9a07 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
+++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
@@ -597,7 +597,7 @@ void tst_qdeclarativevaluetypes::enums()
QDeclarativeComponent component(&engine, TEST_FILE("enums.1.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
- QVERIFY(object->font().capitalization() == QFont::MixedCase);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
delete object;
}
@@ -605,7 +605,23 @@ void tst_qdeclarativevaluetypes::enums()
QDeclarativeComponent component(&engine, TEST_FILE("enums.2.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
- QVERIFY(object->font().capitalization() == QFont::MixedCase);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("enums.3.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("enums.4.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
delete object;
}
}
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml
index bb4028f..1fce155 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml
@@ -12,10 +12,6 @@ WorkerScript {
worker.sendMessage(value)
}
- function testSendLiteral(value) {
- eval('worker.sendMessage(' + value +')')
- }
-
function compareLiteralResponse(expected) {
var e = eval('(' + expected + ')')
return worker.response == e
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
index 56e906e..4f9f21a 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
+++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
@@ -48,9 +48,9 @@
#include <QtDeclarative/qdeclarativeitem.h>
#include <private/qdeclarativeworkerscript_p.h>
+#include <private/qdeclarativeengine_p.h>
#include "../../../shared/util.h"
-Q_DECLARE_METATYPE(QList<QObject*>)
Q_DECLARE_METATYPE(QScriptValue)
class tst_QDeclarativeWorkerScript : public QObject
@@ -86,13 +86,14 @@ void tst_QDeclarativeWorkerScript::source()
QFETCH(QUrl, source);
QFETCH(bool, valid);
- QDeclarativeComponent component(&m_engine);
- component.setData("import Qt 4.6\nWorkerScript { source: '" + source.toString().toUtf8() + "'; }", QUrl());
-
if (!valid) {
QByteArray w = "WorkerScript: Cannot find source file \"" + source.toString().toUtf8() + "\"";
QTest::ignoreMessage(QtWarningMsg, w.constData());
}
+
+ QDeclarativeComponent component(&m_engine);
+ component.setData("import Qt 4.6\nWorkerScript { source: '" + source.toString().toUtf8() + "'; }", QUrl());
+
QDeclarativeWorkerScript *item = qobject_cast<QDeclarativeWorkerScript*>(component.create());
QVERIFY(item != 0);
@@ -172,9 +173,15 @@ void tst_QDeclarativeWorkerScript::messaging_sendJsObject()
QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
QVERIFY(worker != 0);
- QString jsObject = "{'spell power': 3101, 'haste': 1125}";
+ QString jsObject = "{'name': 'zyz', 'spell power': 3101, 'haste': 1125}";
- QVERIFY(QMetaObject::invokeMethod(worker, "testSendLiteral", Q_ARG(QVariant, jsObject)));
+ QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(worker));
+ QScriptValue sv = engine->newObject();
+ sv.setProperty("name", "zyz");
+ sv.setProperty("spell power", 3101);
+ sv.setProperty("haste", 1125);
+
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, qVariantFromValue(sv))));
waitForEchoMessage(worker);
QVariant result = qVariantFromValue(false);
@@ -189,4 +196,3 @@ void tst_QDeclarativeWorkerScript::messaging_sendJsObject()
QTEST_MAIN(tst_QDeclarativeWorkerScript)
#include "tst_qdeclarativeworkerscript.moc"
-
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml
new file mode 100644
index 0000000..737ec81
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+XmlListModel {
+ source: "model.xml"
+ query: "/Pets/Pet"
+ XmlRole { objectName: "role"; name: "name"; query: "name/string()" }
+ XmlRole { name: "type"; query: "type/string()" }
+ XmlRole { name: "age"; query: "age/number()" }
+ XmlRole { name: "size"; query: "size/string()" }
+}
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
index 68029bc..6199234 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
@@ -74,6 +74,7 @@ private slots:
void useKeys_data();
void noKeysValueChanges();
void keysChanged();
+ void propertyChanges();
private:
QString makeItemXmlAndData(const QString &data, QDeclarativeXmlModelData *modelData = 0) const
@@ -440,6 +441,8 @@ void tst_qdeclarativexmllistmodel::noKeysValueChanges()
model->setXml(xml);
QTRY_COMPARE(model->count(), 2);
+ model->setXml("");
+
QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
QSignalSpy spyCount(model, SIGNAL(countChanged()));
@@ -476,6 +479,8 @@ void tst_qdeclarativexmllistmodel::keysChanged()
model->setXml(xml);
QTRY_COMPARE(model->count(), 2);
+ model->setXml("");
+
QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
QSignalSpy spyCount(model, SIGNAL(countChanged()));
@@ -496,6 +501,71 @@ void tst_qdeclarativexmllistmodel::keysChanged()
QCOMPARE(spyCount.count(), 0);
}
+void tst_qdeclarativexmllistmodel::propertyChanges()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+ QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 9);
+
+ QDeclarativeXmlListModelRole *role = model->findChild<QDeclarativeXmlListModelRole*>("role");
+ QVERIFY(role);
+
+ QSignalSpy nameSpy(role, SIGNAL(nameChanged()));
+ QSignalSpy querySpy(role, SIGNAL(queryChanged()));
+ QSignalSpy isKeySpy(role, SIGNAL(isKeyChanged()));
+
+ role->setName("size");
+ role->setQuery("size/string()");
+ role->setIsKey(true);
+
+ QCOMPARE(role->name(), QString("size"));
+ QCOMPARE(role->query(), QString("size/string()"));
+ QVERIFY(role->isKey());
+
+ QCOMPARE(nameSpy.count(),1);
+ QCOMPARE(querySpy.count(),1);
+ QCOMPARE(isKeySpy.count(),1);
+
+ role->setName("size");
+ role->setQuery("size/string()");
+ role->setIsKey(true);
+
+ QCOMPARE(nameSpy.count(),1);
+ QCOMPARE(querySpy.count(),1);
+ QCOMPARE(isKeySpy.count(),1);
+
+ QSignalSpy sourceSpy(model, SIGNAL(sourceChanged()));
+ QSignalSpy xmlSpy(model, SIGNAL(xmlChanged()));
+ QSignalSpy modelQuerySpy(model, SIGNAL(queryChanged()));
+ QSignalSpy namespaceDeclarationsSpy(model, SIGNAL(namespaceDeclarationsChanged()));
+
+ model->setSource(QUrl(""));
+ model->setXml("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
+ model->setQuery("/Pets");
+ model->setNamespaceDeclarations("declare namespace media=\"http://search.yahoo.com/mrss/\";");
+
+ QCOMPARE(model->source(), QUrl(""));
+ QCOMPARE(model->xml(), QString("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>"));
+ QCOMPARE(model->query(), QString("/Pets"));
+ QCOMPARE(model->namespaceDeclarations(), QString("declare namespace media=\"http://search.yahoo.com/mrss/\";"));
+
+ QCOMPARE(sourceSpy.count(),1);
+ QCOMPARE(xmlSpy.count(),1);
+ QCOMPARE(modelQuerySpy.count(),1);
+ QCOMPARE(namespaceDeclarationsSpy.count(),1);
+
+ model->setSource(QUrl(""));
+ model->setXml("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
+ model->setQuery("/Pets");
+ model->setNamespaceDeclarations("declare namespace media=\"http://search.yahoo.com/mrss/\";");
+
+ QCOMPARE(sourceSpy.count(),1);
+ QCOMPARE(xmlSpy.count(),1);
+ QCOMPARE(modelQuerySpy.count(),1);
+ QCOMPARE(namespaceDeclarationsSpy.count(),1);
+}
+
QTEST_MAIN(tst_qdeclarativexmllistmodel)
#include "tst_qdeclarativexmllistmodel.moc"