diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-02 08:50:25 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-02 08:50:25 (GMT) |
commit | 2dee7ff0cc66438437915f7894e036953140641f (patch) | |
tree | a7558eaa827ebcdc3908fd66cd0557670021f5f3 /tests | |
parent | f309c1cc1b0212f1c882fca5adb0e7d7ef552de9 (diff) | |
parent | 1e4258c6098a87342b61935f1ad25102ce699af1 (diff) | |
download | Qt-2dee7ff0cc66438437915f7894e036953140641f.zip Qt-2dee7ff0cc66438437915f7894e036953140641f.tar.gz Qt-2dee7ff0cc66438437915f7894e036953140641f.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (25 commits)
Fix zooming (broke with transformOrigin default change).
doc
Move WebView to an extension plugin.
follow syntax change
missed file
Optimization.
Add autotests for script block scoping.
Make test more reliable.
Add NOTIFY signals to list, grid and path views
Example of text focus.
Add docs and tests for WorkerListModel.
Add NOTIFY signals to list, grid and path views
Example of text focus.
Add accessor operations to VisualItemModel::children
Make "on" syntax mandatory for value sources and interceptors
Fix warning.
Minor optimization.
Test GridView.onAdd & GridView.onRemove. Reduce wait()s
Replace remaining QGuard usage with QDeclarativeGuard.
Reapply "Some animation cleanup/refactoring."
...
Diffstat (limited to 'tests')
110 files changed, 1381 insertions, 432 deletions
diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index 6160e7c..106a4e0 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -190,7 +190,6 @@ void tst_examples::examples() << "-scriptopts" << "play,testerror,exitoncomplete,exitonfailure" << file; QProcess p; -qDebug() << qmlruntime << arguments; p.start(qmlruntime, arguments); QVERIFY(p.waitForFinished()); QCOMPARE(p.exitStatus(), QProcess::NormalExit); diff --git a/tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml index 6381df3..2629cf4 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml @@ -7,6 +7,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: PropertyAnimation { from: "blue"; to: "green"; } + PropertyAnimation on x { from: "blue"; to: "green"; } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml index 8d57e41..1543a2a 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml @@ -7,6 +7,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { from: "blue"; to: "green"; } + NumberAnimation on x { from: "blue"; to: "green"; } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml index c4867c3..aa98c33 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml @@ -5,7 +5,7 @@ Rectangle { height: 320 Rectangle { color: "red" - color: ColorAnimation { from: 10; to: 15; } + ColorAnimation on color { from: 10; to: 15; } width: 50; height: 50 x: 100; y: 100 } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml b/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml index d9660b6..3f00e68 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml @@ -9,7 +9,7 @@ Rectangle { id: redRect width: 100; height: 100 color: Qt.rgba(1,0,0) - x: Behavior { + Behavior on x { NumberAnimation { objectName: "MyAnim"; target: redRect; property: "y"; to: 300; repeat: true} } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml b/tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml index 36417db..efed058 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml @@ -9,7 +9,7 @@ Rectangle { id: redRect width: 100; height: 100 color: Qt.rgba(1,0,0) - x: SequentialAnimation { + SequentialAnimation on x { running: false NumberAnimation { objectName: "MyAnim"; running: true } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/properties.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties.qml index 7e73f57..4437815 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/properties.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/properties.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { to: 200 } + NumberAnimation on x { to: 200 } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/properties2.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties2.qml index 6c96155..b1f2020 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/properties2.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/properties2.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { targets: theRect; properties: "x"; to: 200; } + NumberAnimation on x { targets: theRect; properties: "x"; to: 200; } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/properties3.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties3.qml index ff08885..0a0ed6f 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/properties3.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/properties3.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { target: theRect; property: "x"; to: 300; } + NumberAnimation on x { target: theRect; property: "x"; to: 300; } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/properties4.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties4.qml index dab7e5f..a90f004 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/properties4.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/properties4.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { target: theRect; property: "y"; to: 200; } + NumberAnimation on x { target: theRect; property: "y"; to: 200; } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/properties5.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties5.qml index 38396b1..7d3cec9 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/properties5.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/properties5.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { targets: theRect; properties: "y"; to: 200; } + NumberAnimation on x { targets: theRect; properties: "y"; to: 200; } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml b/tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml index c35063d..2260440 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { id: anim; objectName: "MyAnim"; to: 200 } + NumberAnimation on x { id: anim; objectName: "MyAnim"; to: 200 } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml b/tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml index 1a60542..36d6c72 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { id: anim; objectName: "MyAnim"; running: false; to: 200 } + NumberAnimation on x { id: anim; objectName: "MyAnim"; running: false; to: 200 } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index 53c63b5..0c166df 100644 --- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -221,17 +221,17 @@ void tst_qdeclarativeanimations::resume() QVERIFY(animation.from() == 10); animation.start(); - QTest::qWait(100); + QTest::qWait(200); animation.pause(); qreal x = rect.x(); - QVERIFY(x != qreal(200)); + QVERIFY(x != qreal(200) && x != qreal(10)); QVERIFY(animation.isRunning()); QVERIFY(animation.isPaused()); animation.resume(); QVERIFY(animation.isRunning()); QVERIFY(!animation.isPaused()); - QTest::qWait(100); + QTest::qWait(200); animation.stop(); QVERIFY(rect.x() > x); } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml b/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml index 201da37..e982f21 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml @@ -9,7 +9,7 @@ Rectangle { objectName: "MyRect" width: 100; height: 100; color: "green" x: basex - x: Behavior { NumberAnimation { duration: 500; } } + Behavior on x { NumberAnimation { duration: 500; } } } MouseArea { id: clicker diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/color.qml b/tests/auto/declarative/qdeclarativebehaviors/data/color.qml index 91dbbd1..f2f4742 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/color.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/color.qml @@ -7,7 +7,7 @@ Rectangle { objectName: "MyRect" width: 100; height: 100; color: "green" - color: Behavior { ColorAnimation { duration: 500; } } + Behavior on color { ColorAnimation { duration: 500; } } } MouseArea { id: clicker diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml b/tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml index 8d032f0..3ea9376 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml @@ -6,6 +6,6 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { NumberAnimation { duration: 500; } } + Behavior on x { NumberAnimation { duration: 500; } } } } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml b/tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml index 3c7078a..1403eb9 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { + Behavior on x { objectName: "MyBehavior"; enabled: false NumberAnimation { duration: 200; } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml b/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml index ba7cc9c..12b1b7b 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml @@ -9,7 +9,7 @@ Rectangle { id: redRect width: 100; height: 100 color: Qt.rgba(1,0,0) - x: Behavior { + Behavior on x { NumberAnimation { objectName: "MyAnim"; running: true } } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/empty.qml b/tests/auto/declarative/qdeclarativebehaviors/data/empty.qml index 95d934a..5e30f03 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/empty.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/empty.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior {} + Behavior on x {} } MouseArea { id: clicker diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml b/tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml index 1b2025a..ca0ea54 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { + Behavior on x { objectName: "MyBehavior"; NumberAnimation { target: rect; property: "x"; duration: 500; } } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml index 14883d4..a6c4ed9 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - pos: Behavior { PropertyAnimation { duration: 500; } } + Behavior on pos { PropertyAnimation { duration: 500; } } } MouseArea { id: clicker diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml index b43ddbc..2dda220 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - pos.x: Behavior { NumberAnimation { duration: 500; } } + Behavior on pos.x { NumberAnimation { duration: 500; } } } MouseArea { id: clicker diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/loop.qml b/tests/auto/declarative/qdeclarativebehaviors/data/loop.qml index 5f2c057..6187768 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/loop.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/loop.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { NumberAnimation { duration: 200; } } + Behavior on x { NumberAnimation { duration: 200; } } onXChanged: x = 100; } states: State { diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml b/tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml index f267a05..640a7d1 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { + Behavior on x { objectName: "MyBehavior"; NumberAnimation { targets: rect; properties: "y"; duration: 200; } } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/parent.qml b/tests/auto/declarative/qdeclarativebehaviors/data/parent.qml index 7c7fdcb..3860ec7 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/parent.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/parent.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - parent: Behavior { + Behavior on parent { SequentialAnimation { PauseAnimation { duration: 500 } PropertyAction {} diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml index ba744b1..6419a6b 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { + Behavior on x { objectName: "MyBehavior" NumberAnimation { duration: 200 } NumberAnimation { duration: 1000 } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml b/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml index a91ca88..b22441a 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml @@ -11,6 +11,6 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { NumberAnimation { duration: 500; } } + Behavior on x { NumberAnimation { duration: 500; } } } } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml b/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml index ac98ed0..c28fa9a 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { + Behavior on x { objectName: "MyBehavior"; NumberAnimation { duration: 500; } } diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index f87330d..0bf0b81 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -260,7 +260,7 @@ void tst_qdeclarativebehaviors::reassignedAnimation() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml")); - QTest::ignoreMessage(QtWarningMsg, QString("QML Behavior (" + QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:12) Cannot change the animation assigned to a Behavior.").toUtf8().constData()); + QTest::ignoreMessage(QtWarningMsg, QString("QML Behavior (" + QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:9) Cannot change the animation assigned to a Behavior.").toUtf8().constData()); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); QVERIFY(rect); QCOMPARE(qobject_cast<QDeclarativeNumberAnimation*>( diff --git a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp index 9543280..6cd0bdb 100644 --- a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp +++ b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp @@ -274,7 +274,7 @@ void tst_qdeclarativedom::loadComposite() void tst_qdeclarativedom::testValueSource() { QByteArray qml = "import Qt 4.6\n" - "Rectangle { height: SpringFollow { spring: 1.4; damping: .15; source: Math.min(Math.max(-130, value*2.2 - 130), 133); }}"; + "Rectangle { SpringFollow on height { spring: 1.4; damping: .15; source: Math.min(Math.max(-130, value*2.2 - 130), 133); }}"; QDeclarativeEngine freshEngine; QDeclarativeDomDocument document; @@ -306,7 +306,7 @@ void tst_qdeclarativedom::testValueSource() void tst_qdeclarativedom::testValueInterceptor() { QByteArray qml = "import Qt 4.6\n" - "Rectangle { height: Behavior { NumberAnimation { duration: 100 } } }"; + "Rectangle { Behavior on height { NumberAnimation { duration: 100 } } }"; QDeclarativeEngine freshEngine; QDeclarativeDomDocument document; @@ -823,8 +823,8 @@ void tst_qdeclarativedom::copy() " property int a: 10\n" " x: 10\n" " y: x + 10\n" - " z: NumberAnimation {}\n" - " opacity: Behavior {}\n" + " NumberAnimation on z {}\n" + " Behavior on opacity {}\n" " Component {\n" " Item{}\n" " }\n" @@ -1193,18 +1193,18 @@ void tst_qdeclarativedom::copy() void tst_qdeclarativedom::position() { QByteArray qml = "import Qt 4.6\n" - /*14*/ "Item {\n" - /*21*/ " id: myItem\n" - /*36*/ " property int a: 10\n" - /*59*/ " x: 10\n" - /*69*/ " y: x + 10\n" - /*83*/ " z: NumberAnimation {}\n" - /*109*/ " opacity: Behavior {}\n" - /*134*/ " Component {\n" - /*150*/ " Item{}\n" - /*165*/ " }\n" - /*171*/ " children: [ Item{}, Item{} ]\n" - /*204*/ "}\n"; + "Item {\n" + " id: myItem\n" + " property int a: 10\n" + " x: 10\n" + " y: x + 10\n" + " NumberAnimation on z {}\n" + " Behavior on opacity {}\n" + " Component {\n" + " Item{}\n" + " }\n" + " children: [ Item{}, Item{} ]\n" + "}\n"; QDeclarativeDomDocument document; @@ -1227,19 +1227,19 @@ void tst_qdeclarativedom::position() QCOMPARE(y.length(), 1); QDeclarativeDomProperty z = root.property("z"); - QCOMPARE(z.position(), 87); + QCOMPARE(z.position(), 106); QCOMPARE(z.length(), 1); QDeclarativeDomProperty opacity = root.property("opacity"); - QCOMPARE(opacity.position(), 113); + QCOMPARE(opacity.position(), 127); QCOMPARE(opacity.length(), 7); QDeclarativeDomProperty data = root.property("data"); - QCOMPARE(data.position(), 138); + QCOMPARE(data.position(), 142); QCOMPARE(data.length(), 0); QDeclarativeDomProperty children = root.property("children"); - QCOMPARE(children.position(), 175); + QCOMPARE(children.position(), 179); QCOMPARE(children.length(), 8); QDeclarativeDomList dataList = data.value().toList(); @@ -1249,30 +1249,30 @@ void tst_qdeclarativedom::position() // All QDeclarativeDomObject QCOMPARE(root.position(), 14); - QCOMPARE(root.length(), 191); + QCOMPARE(root.length(), 195); QDeclarativeDomObject numberAnimation = z.value().toValueSource().object(); - QCOMPARE(numberAnimation.position(), 90); - QCOMPARE(numberAnimation.length(), 18); + QCOMPARE(numberAnimation.position(), 87); + QCOMPARE(numberAnimation.length(), 23); QDeclarativeDomObject behavior = opacity.value().toValueInterceptor().object(); - QCOMPARE(behavior.position(), 122); - QCOMPARE(behavior.length(), 11); + QCOMPARE(behavior.position(), 115); + QCOMPARE(behavior.length(), 22); QDeclarativeDomObject component = dataList.values().at(0).toObject(); - QCOMPARE(component.position(), 138); + QCOMPARE(component.position(), 142); QCOMPARE(component.length(), 32); QDeclarativeDomObject componentRoot = component.toComponent().componentRoot(); - QCOMPARE(componentRoot.position(), 158); + QCOMPARE(componentRoot.position(), 162); QCOMPARE(componentRoot.length(), 6); QDeclarativeDomObject child1 = childrenList.values().at(0).toObject(); - QCOMPARE(child1.position(), 187); + QCOMPARE(child1.position(), 191); QCOMPARE(child1.length(), 6); QDeclarativeDomObject child2 = childrenList.values().at(1).toObject(); - QCOMPARE(child2.position(), 195); + QCOMPARE(child2.position(), 199); QCOMPARE(child2.length(), 6); // All QDeclarativeDomValue @@ -1285,23 +1285,23 @@ void tst_qdeclarativedom::position() QCOMPARE(yValue.length(), 6); QDeclarativeDomValue zValue = z.value(); - QCOMPARE(zValue.position(), 90); - QCOMPARE(zValue.length(), 18); + QCOMPARE(zValue.position(), 87); + QCOMPARE(zValue.length(), 23); QDeclarativeDomValue opacityValue = opacity.value(); - QCOMPARE(opacityValue.position(), 122); - QCOMPARE(opacityValue.length(), 11); + QCOMPARE(opacityValue.position(), 115); + QCOMPARE(opacityValue.length(), 22); QDeclarativeDomValue dataValue = data.value(); - QCOMPARE(dataValue.position(), 138); + QCOMPARE(dataValue.position(), 142); QCOMPARE(dataValue.length(), 32); QDeclarativeDomValue child1Value = childrenList.values().at(0); - QCOMPARE(child1Value.position(), 187); + QCOMPARE(child1Value.position(), 191); QCOMPARE(child1Value.length(), 6); QDeclarativeDomValue child2Value = childrenList.values().at(1); - QCOMPARE(child2Value.position(), 195); + QCOMPARE(child2Value.position(), 199); QCOMPARE(child2Value.length(), 6); // All QDeclarativeDomList diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.1.qml new file mode 100644 index 0000000..9b11fa9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.1.qml @@ -0,0 +1,13 @@ +import Qt.test 1.0 + +MyQmlObject { + property string result + + Script{ + function f() { + result = b + } + + } + onArgumentSignal: f() +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.2.qml new file mode 100644 index 0000000..ec727e2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.2.qml @@ -0,0 +1,11 @@ +import Qt.test 1.0 + +MyQmlObject { + property string result + property string aProp: "hello" + + Script{ + source: "scriptScope.js" + } + onBasicSignal: f() +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.js b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.js new file mode 100644 index 0000000..5689930 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.js @@ -0,0 +1,5 @@ +var aProp = "world"; + +function f() { + result = aProp; +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 60c380c..8e7944d 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -122,6 +122,7 @@ private slots: void listToVariant(); void multiEngineObject(); void deletedObject(); + void scriptScope(); void bug1(); @@ -1657,6 +1658,33 @@ void tst_qdeclarativeecmascript::deletedObject() delete object; } +void tst_qdeclarativeecmascript::scriptScope() +{ + { + QDeclarativeComponent component(&engine, TEST_FILE("scriptScope.1.qml")); + + MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(object != 0); + emit object->argumentSignal(19, "Hello world!", 10.3); + QEXPECT_FAIL("", "QTBUG-8641", Continue); + QCOMPARE(object->property("result").toString(), QLatin1String("undefined")); + + delete object; + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("scriptScope.2.qml")); + + MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(object != 0); + emit object->basicSignal(); + QEXPECT_FAIL("", "QTBUG-8641", Continue); + QCOMPARE(object->property("result").toString(), QLatin1String("world")); + + delete object; + } +} + QTEST_MAIN(tst_qdeclarativeecmascript) #include "tst_qdeclarativeecmascript.moc" diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview.qml index 344b4b5..ba6b807 100644 --- a/tests/auto/declarative/qdeclarativegridview/data/gridview.qml +++ b/tests/auto/declarative/qdeclarativegridview/data/gridview.qml @@ -1,6 +1,10 @@ import Qt 4.6 Rectangle { + id: root + property int added: -1 + property var removed + width: 240 height: 320 color: "#ffffff" @@ -33,6 +37,8 @@ Rectangle { text: number } color: GridView.isCurrentItem ? "lightsteelblue" : "white" + GridView.onAdd: root.added = index + GridView.onRemove: root.removed = name } } ] diff --git a/tests/auto/declarative/qdeclarativegridview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativegridview/data/propertychanges.qml new file mode 100644 index 0000000..da2e8d0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativegridview/data/propertychanges.qml @@ -0,0 +1,69 @@ +import Qt 4.6 + +Rectangle { + width: 360; height: 120; color: "white" + Component { + id: delegate + Item { + id: wrapper + width: 180; height: 40; + Column { + x: 5; y: 5 + Text { text: '<b>Name:</b> ' + name } + Text { text: '<b>Number:</b> ' + number } + } + } + } + Component { + id: highlightRed + Rectangle { + color: "red" + radius: 10 + opacity: 0.5 + } + } + GridView { + cellWidth:180 + cellHeight:40 + objectName: "gridView" + anchors.fill: parent + model: listModel + delegate: delegate + highlight: highlightRed + focus: true + keyNavigationWraps: true + cacheBuffer: 10 + flow: GridView.LeftToRight + } + + data:[ + ListModel { + id: listModel + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + }, + ListModel { + objectName: "alternateModel" + ListElement { + name: "Jack" + number: "555 8426" + } + ListElement { + name: "Mary" + number: "555 3264" + } + } + ] +} + +
\ No newline at end of file diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index 2a60fee..7ade309 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -39,16 +39,17 @@ ** ****************************************************************************/ -#include <qdeclarativeengine.h> -#include <qdeclarativecomponent.h> -#include <QStringListModel> #include <QtTest/QtTest> -#include <private/qlistmodelinterface_p.h> -#include <qdeclarativeview.h> -#include <private/qdeclarativegridview_p.h> -#include <private/qdeclarativetext_p.h> -#include <qdeclarativecontext.h> -#include <qdeclarativeexpression.h> +#include <QtGui/qstringlistmodel.h> +#include <QtDeclarative/qdeclarativeview.h> +#include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativecomponent.h> +#include <QtDeclarative/qdeclarativecontext.h> +#include <QtDeclarative/qdeclarativeexpression.h> +#include <QtDeclarative/private/qlistmodelinterface_p.h> +#include <QtDeclarative/private/qdeclarativegridview_p.h> +#include <QtDeclarative/private/qdeclarativetext_p.h> +#include <QtDeclarative/private/qdeclarativelistmodel_p.h> class tst_QDeclarativeGridView : public QObject { @@ -66,6 +67,9 @@ private slots: void currentIndex(); void defaultValues(); void properties(); + void propertyChanges(); + void componentChanges(); + void modelChanges(); void positionViewAtIndex(); void resetModel(); void QTBUG_8456(); @@ -91,7 +95,7 @@ public: setRoleNames(roles); } - int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); } + int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); } QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const { QVariant rv; if (role == Name) @@ -253,7 +257,7 @@ void tst_QDeclarativeGridView::inserted() model.insertItem(1, "Will", "9876"); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item @@ -264,6 +268,10 @@ void tst_QDeclarativeGridView::inserted() QVERIFY(number != 0); QCOMPARE(number->text(), model.number(1)); + // Checks that onAdd is called + int added = canvas->rootObject()->property("added").toInt(); + QCOMPARE(added, 1); + // Confirm items positioned correctly for (int i = 0; i < model.count(); ++i) { QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); @@ -274,7 +282,7 @@ void tst_QDeclarativeGridView::inserted() model.insertItem(0, "Foo", "1111"); // zero index, and current item // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item @@ -296,14 +304,14 @@ void tst_QDeclarativeGridView::inserted() for (int i = model.count(); i < 30; ++i) model.insertItem(i, "Hello", QString::number(i)); - QTest::qWait(300); + QTest::qWait(100); gridview->setContentY(120); - QTest::qWait(300); + QTest::qWait(100); // Insert item outside visible area model.insertItem(1, "Hello", "1324"); - QTest::qWait(300); + QTest::qWait(100); QVERIFY(gridview->contentY() == 120); @@ -334,7 +342,7 @@ void tst_QDeclarativeGridView::removed() model.removeItem(1); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1); QVERIFY(name != 0); @@ -343,6 +351,10 @@ void tst_QDeclarativeGridView::removed() QVERIFY(number != 0); QCOMPARE(number->text(), model.number(1)); + // Checks that onRemove is called + QString removed = canvas->rootObject()->property("removed").toString(); + QCOMPARE(removed, QString("Item1")); + // Confirm items positioned correctly int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { @@ -357,7 +369,7 @@ void tst_QDeclarativeGridView::removed() model.removeItem(0); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); name = findItem<QDeclarativeText>(viewport, "textName", 0); QVERIFY(name != 0); @@ -379,7 +391,7 @@ void tst_QDeclarativeGridView::removed() // Remove items not visible model.removeItem(25); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); // Confirm items positioned correctly itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); @@ -393,11 +405,11 @@ void tst_QDeclarativeGridView::removed() // Remove items before visible gridview->setContentY(120); - QTest::qWait(500); + QTest::qWait(100); gridview->setCurrentIndex(10); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); // Setting currentIndex above shouldn't cause view to scroll QCOMPARE(gridview->contentY(), 120.0); @@ -405,7 +417,7 @@ void tst_QDeclarativeGridView::removed() model.removeItem(1); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); // Confirm items positioned correctly for (int i = 6; i < 18; ++i) { @@ -419,14 +431,14 @@ void tst_QDeclarativeGridView::removed() // Remove currentIndex QDeclarativeItem *oldCurrent = gridview->currentItem(); model.removeItem(9); - QTest::qWait(500); + QTest::qWait(100); QCOMPARE(gridview->currentIndex(), 9); QVERIFY(gridview->currentItem() != oldCurrent); gridview->setContentY(0); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); // Confirm items positioned correctly itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); @@ -440,7 +452,7 @@ void tst_QDeclarativeGridView::removed() // remove item outside current view. gridview->setCurrentIndex(32); - QTest::qWait(500); + QTest::qWait(100); gridview->setContentY(240); model.removeItem(30); @@ -448,21 +460,21 @@ void tst_QDeclarativeGridView::removed() // remove current item beyond visible items. gridview->setCurrentIndex(20); - QTest::qWait(500); + QTest::qWait(100); gridview->setContentY(0); model.removeItem(20); - QTest::qWait(500); + QTest::qWait(100); QCOMPARE(gridview->currentIndex(), 20); QVERIFY(gridview->currentItem() != 0); // remove item before current, but visible gridview->setCurrentIndex(8); - QTest::qWait(500); + QTest::qWait(100); gridview->setContentY(240); oldCurrent = gridview->currentItem(); model.removeItem(6); - QTest::qWait(500); + QTest::qWait(100); QCOMPARE(gridview->currentIndex(), 7); QVERIFY(gridview->currentItem() == oldCurrent); @@ -494,7 +506,7 @@ void tst_QDeclarativeGridView::moved() model.moveItem(1, 8); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1); QVERIFY(name != 0); @@ -526,7 +538,7 @@ void tst_QDeclarativeGridView::moved() model.moveItem(1, 25); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); // Confirm items positioned correctly and indexes correct itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count()-1; @@ -548,7 +560,7 @@ void tst_QDeclarativeGridView::moved() model.moveItem(28, 8); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); // Confirm items positioned correctly and indexes correct for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) { @@ -591,7 +603,7 @@ void tst_QDeclarativeGridView::currentIndex() QDeclarativeItem *viewport = gridview->viewport(); QVERIFY(viewport != 0); - QTest::qWait(500); + QTest::qWait(300); // current item should be third item QCOMPARE(gridview->currentIndex(), 5); @@ -618,7 +630,7 @@ void tst_QDeclarativeGridView::currentIndex() QCOMPARE(gridview->currentIndex(), 0); gridview->setCurrentIndex(model.count()-1); - QTest::qWait(500); + QTest::qWait(100); QCOMPARE(gridview->currentIndex(), model.count()-1); gridview->moveCurrentIndexRight(); @@ -677,8 +689,6 @@ void tst_QDeclarativeGridView::currentIndex() // turn off auto highlight gridview->setHighlightFollowsCurrentItem(false); QVERIFY(gridview->highlightFollowsCurrentItem() == false); - - QTest::qWait(500); QVERIFY(gridview->highlightItem()); qreal hlPosX = gridview->highlightItem()->x(); qreal hlPosY = gridview->highlightItem()->y(); @@ -729,7 +739,7 @@ void tst_QDeclarativeGridView::changeFlow() } ctxt->setContextProperty("testTopToBottom", QVariant(true)); - QTest::qWait(500); + QTest::qWait(100); // Confirm items positioned correctly and indexes correct itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); @@ -796,6 +806,107 @@ void tst_QDeclarativeGridView::properties() delete obj; } +void tst_QDeclarativeGridView::propertyChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativeGridView *gridView = canvas->rootObject()->findChild<QDeclarativeGridView*>("gridView"); + QVERIFY(gridView); + + QSignalSpy keyNavigationWrapsSpy(gridView, SIGNAL(keyNavigationWrapsChanged())); + QSignalSpy cacheBufferSpy(gridView, SIGNAL(cacheBufferChanged())); + QSignalSpy flowSpy(gridView, SIGNAL(flowChanged())); + + QCOMPARE(gridView->isWrapEnabled(), true); + QCOMPARE(gridView->cacheBuffer(), 10); + QCOMPARE(gridView->flow(), QDeclarativeGridView::LeftToRight); + + gridView->setWrapEnabled(false); + gridView->setCacheBuffer(3); + gridView->setFlow(QDeclarativeGridView::TopToBottom); + + QCOMPARE(gridView->isWrapEnabled(), false); + QCOMPARE(gridView->cacheBuffer(), 3); + QCOMPARE(gridView->flow(), QDeclarativeGridView::TopToBottom); + + QCOMPARE(keyNavigationWrapsSpy.count(),1); + QCOMPARE(cacheBufferSpy.count(),1); + QCOMPARE(flowSpy.count(),1); + + gridView->setWrapEnabled(false); + gridView->setCacheBuffer(3); + gridView->setFlow(QDeclarativeGridView::TopToBottom); + + QCOMPARE(keyNavigationWrapsSpy.count(),1); + QCOMPARE(cacheBufferSpy.count(),1); + QCOMPARE(flowSpy.count(),1); + + delete canvas; +} + +void tst_QDeclarativeGridView::componentChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativeGridView *gridView = canvas->rootObject()->findChild<QDeclarativeGridView*>("gridView"); + QVERIFY(gridView); + + QDeclarativeComponent component(canvas->engine()); + component.setData("import Qt 4.6; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile("")); + + QDeclarativeComponent delegateComponent(canvas->engine()); + delegateComponent.setData("import Qt 4.6; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile("")); + + QSignalSpy highlightSpy(gridView, SIGNAL(highlightChanged())); + QSignalSpy delegateSpy(gridView, SIGNAL(delegateChanged())); + + gridView->setHighlight(&component); + gridView->setDelegate(&delegateComponent); + + QCOMPARE(gridView->highlight(), &component); + QCOMPARE(gridView->delegate(), &delegateComponent); + + QCOMPARE(highlightSpy.count(),1); + QCOMPARE(delegateSpy.count(),1); + + gridView->setHighlight(&component); + gridView->setDelegate(&delegateComponent); + + QCOMPARE(highlightSpy.count(),1); + QCOMPARE(delegateSpy.count(),1); + delete canvas; +} + +void tst_QDeclarativeGridView::modelChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativeGridView *gridView = canvas->rootObject()->findChild<QDeclarativeGridView*>("gridView"); + QVERIFY(gridView); + + QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel"); + QVERIFY(alternateModel); + QVariant modelVariant = QVariant::fromValue(alternateModel); + QSignalSpy modelSpy(gridView, SIGNAL(modelChanged())); + + gridView->setModel(modelVariant); + QCOMPARE(gridView->model(), modelVariant); + QCOMPARE(modelSpy.count(),1); + + gridView->setModel(modelVariant); + QCOMPARE(modelSpy.count(),1); + + gridView->setModel(QVariant()); + QCOMPARE(modelSpy.count(),2); + delete canvas; +} + void tst_QDeclarativeGridView::positionViewAtIndex() { QDeclarativeView *canvas = createView(); diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml index c86c96b..9fe0ded 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml @@ -10,8 +10,6 @@ MyTypeObject { floatProperty: 8.5 colorProperty: "red" dateProperty: "1982-11-25" - timeProperty: "11:11:31" - timeProperty: "11:11:32" timeProperty: "11:11:32" dateTimeProperty: "2009-05-12T13:22:01" pointProperty: "99,13" diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt index 9a13142..450fc16 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt @@ -1 +1 @@ -6:9:Invalid component id specification +6:9:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt index 2aea251..e1f7ec5 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt @@ -1 +1 @@ -5:5:Incorrectly specified signal +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt index 8331725..e1f7ec5 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt @@ -1 +1 @@ -5:18:Single property assignment expected +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt index cfe8756..c721fe9 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt @@ -1 +1 @@ -4:5:Invalid use of id property +4:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt index 8c7b7e9..c721fe9 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt @@ -1 +1 @@ -4:15:Can only assign one binding to lists +4:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.qml new file mode 100644 index 0000000..649c49e --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + intProperty: 10 + intProperty: 11 +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.qml new file mode 100644 index 0000000..bc21db9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + property int a: 10 + a: 11 +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.qml new file mode 100644 index 0000000..abcd216 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + intProperty: 10 + intProperty: a + 10 +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.qml new file mode 100644 index 0000000..77eaba0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + intProperty: a + 10 + intProperty: 10 +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.qml new file mode 100644 index 0000000..c16d04f --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + intProperty: 10 + intProperty: MyTypeObject {} +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.qml new file mode 100644 index 0000000..2980c5b --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyContainer { + children: MyContainer {} + children: MyContainer {} +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.qml new file mode 100644 index 0000000..492c720 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyContainer { + children: MyContainer {} + children: [ MyContainer {}, MyContainer {} ] +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.qml new file mode 100644 index 0000000..2a9c1d0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyContainer { + children: [ MyContainer {}, MyContainer {} ] + children: MyContainer {} +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.errors.txt new file mode 100644 index 0000000..450fc16 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.errors.txt @@ -0,0 +1 @@ +6:9:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.qml new file mode 100644 index 0000000..052437e --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + grouped { + value: 10 + value: 11 + } +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.qml new file mode 100644 index 0000000..e2e954f --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + grouped.value: 10 + grouped.value: 11 +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml index 57a6070..e48526a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml @@ -1,5 +1,5 @@ import Test 1.0 MyTypeObject { - intProperty : MyCompositeValueSource {} + MyCompositeValueSource on intProperty {} } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml b/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml index ad71fcf..22aa682 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml @@ -1,4 +1,4 @@ import Test 1.0 MyTypeObject { - intProperty : MyPropertyValueSource {} + MyPropertyValueSource on intProperty {} } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt index b5bf1a8..450fc16 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt @@ -1 +1 @@ -6:9:Invalid Script source value +6:9:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h index 8ac7aa6..ec2c5f7 100644 --- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h +++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h @@ -166,11 +166,16 @@ class MyGroupedObject : public QObject { Q_OBJECT Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript); + Q_PROPERTY(int value READ value WRITE setValue); public: QDeclarativeScriptString script() const { return m_script; } void setScript(const QDeclarativeScriptString &s) { m_script = s; } + int value() const { return m_value; } + void setValue(int v) { m_value = v; } + private: + int m_value; QDeclarativeScriptString m_script; }; diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 1ba4454..39f5223 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -288,6 +288,17 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("Component.5") << "component.5.qml" << "component.5.errors.txt" << false; QTest::newRow("Component.6") << "component.6.qml" << "component.6.errors.txt" << false; + QTest::newRow("MultiSet.1") << "multiSet.1.qml" << "multiSet.1.errors.txt" << false; + QTest::newRow("MultiSet.2") << "multiSet.2.qml" << "multiSet.2.errors.txt" << false; + QTest::newRow("MultiSet.3") << "multiSet.3.qml" << "multiSet.3.errors.txt" << false; + QTest::newRow("MultiSet.4") << "multiSet.4.qml" << "multiSet.4.errors.txt" << false; + QTest::newRow("MultiSet.5") << "multiSet.5.qml" << "multiSet.5.errors.txt" << false; + QTest::newRow("MultiSet.6") << "multiSet.6.qml" << "multiSet.6.errors.txt" << false; + QTest::newRow("MultiSet.7") << "multiSet.7.qml" << "multiSet.7.errors.txt" << false; + QTest::newRow("MultiSet.8") << "multiSet.8.qml" << "multiSet.8.errors.txt" << false; + QTest::newRow("MultiSet.9") << "multiSet.9.qml" << "multiSet.9.errors.txt" << false; + QTest::newRow("MultiSet.10") << "multiSet.10.qml" << "multiSet.10.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.1") << "invalidAttachedProperty.1.qml" << "invalidAttachedProperty.1.errors.txt" << false; QTest::newRow("invalidAttachedProperty.2") << "invalidAttachedProperty.2.qml" << "invalidAttachedProperty.2.errors.txt" << false; QTest::newRow("invalidAttachedProperty.3") << "invalidAttachedProperty.3.qml" << "invalidAttachedProperty.3.errors.txt" << false; diff --git a/tests/auto/declarative/qdeclarativelistview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativelistview/data/propertychanges.qml new file mode 100644 index 0000000..a41f003 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelistview/data/propertychanges.qml @@ -0,0 +1,71 @@ +import Qt 4.6 + +Rectangle { + width: 180; height: 120; color: "white" + Component { + id: delegate + Item { + id: wrapper + width: 180; height: 40; + Column { + x: 5; y: 5 + Text { text: '<b>Name:</b> ' + name } + Text { text: '<b>Number:</b> ' + number } + } + } + } + Component { + id: highlightRed + Rectangle { + color: "red" + radius: 10 + opacity: 0.5 + } + } + ListView { + objectName: "listView" + anchors.fill: parent + model: listModel + delegate: delegate + highlight: highlightRed + focus: true + highlightFollowsCurrentItem: true + preferredHighlightBegin: 0.0 + preferredHighlightEnd: 0.0 + highlightRangeMode: ListView.ApplyRange + keyNavigationWraps: true + cacheBuffer: 10 + snapMode: ListView.SnapToItem + } + + data:[ + ListModel { + id: listModel + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + }, + ListModel { + objectName: "alternateModel" + ListElement { + name: "Jack" + number: "555 8426" + } + ListElement { + name: "Mary" + number: "555 3264" + } + } + ] +} + +
\ No newline at end of file diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index f15f26b..a36224f 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -38,15 +38,18 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include <QtTest/QtTest> -#include <QStringListModel> -#include <private/qlistmodelinterface_p.h> -#include <qdeclarativeview.h> -#include <private/qdeclarativelistview_p.h> -#include <private/qdeclarativetext_p.h> -#include <private/qdeclarativevisualitemmodel_p.h> -#include <qdeclarativecontext.h> -#include <qdeclarativeexpression.h> +#include <QtGui/QStringListModel> +#include <QtDeclarative/qdeclarativeview.h> +#include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativecontext.h> +#include <QtDeclarative/qdeclarativeexpression.h> +#include <QtDeclarative/private/qdeclarativelistview_p.h> +#include <QtDeclarative/private/qdeclarativetext_p.h> +#include <QtDeclarative/private/qdeclarativevisualitemmodel_p.h> +#include <QtDeclarative/private/qdeclarativelistmodel_p.h> +#include <QtDeclarative/private/qlistmodelinterface_p.h> class tst_QDeclarativeListView : public QObject { @@ -82,6 +85,9 @@ private slots: void cacheBuffer(); void positionViewAtIndex(); void resetModel(); + void propertyChanges(); + void componentChanges(); + void modelChanges(); private: template <class T> void items(); @@ -240,7 +246,7 @@ public: setRoleNames(roles); } - int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); } + int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); } QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const { QVariant rv; if (role == Name) @@ -379,6 +385,7 @@ void tst_QDeclarativeListView::items() delete canvas; } + template <class T> void tst_QDeclarativeListView::changed() { @@ -1275,6 +1282,149 @@ void tst_QDeclarativeListView::resetModel() } } +void tst_QDeclarativeListView::propertyChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativeListView *listView = canvas->rootObject()->findChild<QDeclarativeListView*>("listView"); + QVERIFY(listView); + + QSignalSpy highlightFollowsCurrentItemSpy(listView, SIGNAL(highlightFollowsCurrentItemChanged())); + QSignalSpy preferredHighlightBeginSpy(listView, SIGNAL(preferredHighlightBeginChanged())); + QSignalSpy preferredHighlightEndSpy(listView, SIGNAL(preferredHighlightEndChanged())); + QSignalSpy highlightRangeModeSpy(listView, SIGNAL(highlightRangeModeChanged())); + QSignalSpy keyNavigationWrapsSpy(listView, SIGNAL(keyNavigationWrapsChanged())); + QSignalSpy cacheBufferSpy(listView, SIGNAL(cacheBufferChanged())); + QSignalSpy snapModeSpy(listView, SIGNAL(snapModeChanged())); + + QCOMPARE(listView->highlightFollowsCurrentItem(), true); + QCOMPARE(listView->preferredHighlightBegin(), 0.0); + QCOMPARE(listView->preferredHighlightEnd(), 0.0); + QCOMPARE(listView->highlightRangeMode(), QDeclarativeListView::ApplyRange); + QCOMPARE(listView->isWrapEnabled(), true); + QCOMPARE(listView->cacheBuffer(), 10); + QCOMPARE(listView->snapMode(), QDeclarativeListView::SnapToItem); + + listView->setHighlightFollowsCurrentItem(false); + listView->setPreferredHighlightBegin(1.0); + listView->setPreferredHighlightEnd(1.0); + listView->setHighlightRangeMode(QDeclarativeListView::StrictlyEnforceRange); + listView->setWrapEnabled(false); + listView->setCacheBuffer(3); + listView->setSnapMode(QDeclarativeListView::SnapOneItem); + + QCOMPARE(listView->highlightFollowsCurrentItem(), false); + QCOMPARE(listView->preferredHighlightBegin(), 1.0); + QCOMPARE(listView->preferredHighlightEnd(), 1.0); + QCOMPARE(listView->highlightRangeMode(), QDeclarativeListView::StrictlyEnforceRange); + QCOMPARE(listView->isWrapEnabled(), false); + QCOMPARE(listView->cacheBuffer(), 3); + QCOMPARE(listView->snapMode(), QDeclarativeListView::SnapOneItem); + + QCOMPARE(highlightFollowsCurrentItemSpy.count(),1); + QCOMPARE(preferredHighlightBeginSpy.count(),1); + QCOMPARE(preferredHighlightEndSpy.count(),1); + QCOMPARE(highlightRangeModeSpy.count(),1); + QCOMPARE(keyNavigationWrapsSpy.count(),1); + QCOMPARE(cacheBufferSpy.count(),1); + QCOMPARE(snapModeSpy.count(),1); + + listView->setHighlightFollowsCurrentItem(false); + listView->setPreferredHighlightBegin(1.0); + listView->setPreferredHighlightEnd(1.0); + listView->setHighlightRangeMode(QDeclarativeListView::StrictlyEnforceRange); + listView->setWrapEnabled(false); + listView->setCacheBuffer(3); + listView->setSnapMode(QDeclarativeListView::SnapOneItem); + + QCOMPARE(highlightFollowsCurrentItemSpy.count(),1); + QCOMPARE(preferredHighlightBeginSpy.count(),1); + QCOMPARE(preferredHighlightEndSpy.count(),1); + QCOMPARE(highlightRangeModeSpy.count(),1); + QCOMPARE(keyNavigationWrapsSpy.count(),1); + QCOMPARE(cacheBufferSpy.count(),1); + QCOMPARE(snapModeSpy.count(),1); + + delete canvas; +} + +void tst_QDeclarativeListView::componentChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativeListView *listView = canvas->rootObject()->findChild<QDeclarativeListView*>("listView"); + QVERIFY(listView); + + QDeclarativeComponent component(canvas->engine()); + component.setData("import Qt 4.6; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile("")); + + QDeclarativeComponent delegateComponent(canvas->engine()); + delegateComponent.setData("import Qt 4.6; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile("")); + + QSignalSpy highlightSpy(listView, SIGNAL(highlightChanged())); + QSignalSpy delegateSpy(listView, SIGNAL(delegateChanged())); + QSignalSpy headerSpy(listView, SIGNAL(headerChanged())); + QSignalSpy footerSpy(listView, SIGNAL(footerChanged())); + + listView->setHighlight(&component); + listView->setHeader(&component); + listView->setFooter(&component); + listView->setDelegate(&delegateComponent); + + QCOMPARE(listView->highlight(), &component); + QCOMPARE(listView->header(), &component); + QCOMPARE(listView->footer(), &component); + QCOMPARE(listView->delegate(), &delegateComponent); + + QCOMPARE(highlightSpy.count(),1); + QCOMPARE(delegateSpy.count(),1); + QCOMPARE(headerSpy.count(),1); + QCOMPARE(footerSpy.count(),1); + + listView->setHighlight(&component); + listView->setHeader(&component); + listView->setFooter(&component); + listView->setDelegate(&delegateComponent); + + QCOMPARE(highlightSpy.count(),1); + QCOMPARE(delegateSpy.count(),1); + QCOMPARE(headerSpy.count(),1); + QCOMPARE(footerSpy.count(),1); + + delete canvas; +} + +void tst_QDeclarativeListView::modelChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativeListView *listView = canvas->rootObject()->findChild<QDeclarativeListView*>("listView"); + QVERIFY(listView); + + QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel"); + QVERIFY(alternateModel); + QVariant modelVariant = QVariant::fromValue(alternateModel); + QSignalSpy modelSpy(listView, SIGNAL(modelChanged())); + + listView->setModel(modelVariant); + QCOMPARE(listView->model(), modelVariant); + QCOMPARE(modelSpy.count(),1); + + listView->setModel(modelVariant); + QCOMPARE(modelSpy.count(),1); + + listView->setModel(QVariant()); + QCOMPARE(modelSpy.count(),2); + + delete canvas; +} + void tst_QDeclarativeListView::qListModelInterface_items() { items<TestModel>(); diff --git a/tests/auto/declarative/qdeclarativeparticles/data/particles.qml b/tests/auto/declarative/qdeclarativeparticles/data/particles.qml index c58927e..0d42645 100644 --- a/tests/auto/declarative/qdeclarativeparticles/data/particles.qml +++ b/tests/auto/declarative/qdeclarativeparticles/data/particles.qml @@ -8,7 +8,7 @@ Rectangle{ objectName: "particles" width:1; height:1; anchors.centerIn: parent; opacity: 1 lifeSpan: 100; lifeSpanDeviation: 20; count:1000; - fadeInDuration: 20; fadeOutDuration: 20; count: -1; emissionRate: 1000 + fadeInDuration: 20; fadeOutDuration: 20; emissionRate: 1000 angle: 0; angleDeviation: 360; velocity: 500; velocityDeviation:30 source: "particle.png" } diff --git a/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml b/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml index 627f38a..ab1538b 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml @@ -33,7 +33,7 @@ Rectangle { height: 320 model: testModel delegate: delegate - snapPosition: 0.01 + snapPosition: 0.0001 path: Path { startY: 120 startX: 160 diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview.qml index 8fa8d59..c5d88cd 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathview.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview.qml @@ -39,7 +39,7 @@ Rectangle { height: 320 model: testModel delegate: delegate - snapPosition: 0.01 + snapPosition: 0.0001 path: Path { startY: 120 startX: 160 diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview2.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview2.qml index 0d5c98b..c825292 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathview2.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview2.qml @@ -1,7 +1,7 @@ import Qt 4.6 PathView { - id: photoPathView; model: rssModel; delegate: photoDelegate + id: photoPathView y: 100; width: 800; height: 330; pathItemCount: 10; z: 1 path: Path { diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml index 412cca2..f8ed29f 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml @@ -1,9 +1,9 @@ import Qt 4.6 PathView { - id: photoPathView; model: rssModel; delegate: photoDelegate + id: photoPathView y: 100; width: 800; height: 330; pathItemCount: 4; offset: 10 - dragMargin: 24; snapPosition: 50 + dragMargin: 24; snapPosition: 0.50 path: Path { startX: -50; startY: 40; diff --git a/tests/auto/declarative/qdeclarativepathview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativepathview/data/propertychanges.qml new file mode 100644 index 0000000..db70b7b --- /dev/null +++ b/tests/auto/declarative/qdeclarativepathview/data/propertychanges.qml @@ -0,0 +1,115 @@ +import Qt 4.6 + +Rectangle { + width: 350; height: 220; color: "white" + Component { + id: myDelegate + Item { + id: wrapper + width: 180; height: 40; + opacity: PathView.opacity + Column { + x: 5; y: 5 + Text { text: '<b>Name:</b> ' + name } + Text { text: '<b>Number:</b> ' + number } + } + } + } + + PathView { + snapPosition: 0.1 + dragMargin: 5.0 + id: pathView + objectName: "pathView" + anchors.fill: parent + model: listModel + delegate: myDelegate + focus: true + path: Path { + id: myPath + objectName: "path" + startX: 220; startY: 200 + PathAttribute { name: "opacity"; value: 1.0; objectName: "pathAttribute"; } + PathQuad { x: 220; y: 25; controlX: 260; controlY: 75 } + PathAttribute { name: "opacity"; value: 0.3 } + PathQuad { x: 220; y: 200; controlX: -20; controlY: 75 } + } + Timer { + interval: 2000; running: true; repeat: true + onTriggered: { + if (pathView.path == alternatePath) + pathView.path = myPath; + else + pathView.path = alternatePath; + } + } + } + + data:[ + ListModel { + id: listModel + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + }, + ListModel { + objectName: "alternateModel" + ListElement { + name: "Jack" + number: "555 8426" + } + ListElement { + name: "Mary" + number: "555 3264" + } + }, + Path { + id: alternatePath + objectName: "alternatePath" + startX: 100; startY: 40 + PathAttribute { name: "opacity"; value: 0.0 } + PathLine { x: 100; y: 160 } + PathAttribute { name: "opacity"; value: 0.2 } + PathLine { x: 300; y: 160 } + PathAttribute { name: "opacity"; value: 0.0 } + PathLine { x: 300; y: 40 } + PathAttribute { name: "opacity"; value: 0.2 } + PathLine { x: 100; y: 40 } + } + ] +} + + diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index 79bc607..fa4e9d3 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -38,20 +38,23 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include <private/qdeclarativepathview_p.h> -#include <private/qdeclarativepath_p.h> -#include <qdeclarativecontext.h> -#include <qdeclarativeexpression.h> -#include <qtest.h> + +#include <QtTest/QtTest> +#include <QtDeclarative/qdeclarativeview.h> #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativecomponent.h> -#include <QtDeclarative/qdeclarativeview.h> +#include <QtDeclarative/qdeclarativecontext.h> +#include <QtDeclarative/qdeclarativeexpression.h> +#include <QtDeclarative/private/qdeclarativepathview_p.h> +#include <QtDeclarative/private/qdeclarativepath_p.h> #include <QtDeclarative/private/qdeclarativetext_p.h> #include <QtDeclarative/private/qdeclarativerectangle_p.h> +#include <QtDeclarative/private/qdeclarativelistmodel_p.h> +#include <QtDeclarative/private/qdeclarativevaluetype_p.h> #include <QAbstractListModel> #include <QStringListModel> #include <QFile> -#include <private/qdeclarativevaluetype_p.h> + #include "../../../shared/util.h" class tst_QDeclarativePathView : public QObject @@ -69,6 +72,11 @@ private slots: void path(); void pathMoved(); void resetModel(); + void propertyChanges(); + void pathChanges(); + void componentChanges(); + void modelChanges(); + private: QDeclarativeView *createView(); @@ -120,7 +128,7 @@ public: setRoleNames(roles); } - int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); } + int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); } QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const { QVariant rv; if (role == Name) @@ -465,6 +473,149 @@ void tst_QDeclarativePathView::resetModel() } } +void tst_QDeclarativePathView::propertyChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativePathView *pathView = canvas->rootObject()->findChild<QDeclarativePathView*>("pathView"); + QVERIFY(pathView); + + QSignalSpy snapPositionSpy(pathView, SIGNAL(snapPositionChanged())); + QSignalSpy dragMarginSpy(pathView, SIGNAL(dragMarginChanged())); + + QCOMPARE(pathView->snapPosition(), 0.1); + QCOMPARE(pathView->dragMargin(), 5.0); + + pathView->setSnapPosition(0.4); + pathView->setDragMargin(20.0); + + QCOMPARE(pathView->snapPosition(), 0.4); + QCOMPARE(pathView->dragMargin(), 20.0); + + QCOMPARE(snapPositionSpy.count(), 1); + QCOMPARE(dragMarginSpy.count(), 1); + + pathView->setSnapPosition(0.4); + pathView->setDragMargin(20.0); + + QCOMPARE(snapPositionSpy.count(), 1); + QCOMPARE(dragMarginSpy.count(), 1); + delete canvas; +} + +void tst_QDeclarativePathView::pathChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativePathView *pathView = canvas->rootObject()->findChild<QDeclarativePathView*>("pathView"); + QVERIFY(pathView); + + QDeclarativePath *path = canvas->rootObject()->findChild<QDeclarativePath*>("path"); + QVERIFY(path); + + QSignalSpy startXSpy(path, SIGNAL(startXChanged())); + QSignalSpy startYSpy(path, SIGNAL(startYChanged())); + + QCOMPARE(path->startX(), 220.0); + QCOMPARE(path->startY(), 200.0); + + path->setStartX(240.0); + path->setStartY(220.0); + + QCOMPARE(path->startX(), 240.0); + QCOMPARE(path->startY(), 220.0); + + QCOMPARE(startXSpy.count(),1); + QCOMPARE(startYSpy.count(),1); + + path->setStartX(240); + path->setStartY(220); + + QCOMPARE(startXSpy.count(),1); + QCOMPARE(startYSpy.count(),1); + + QDeclarativePath *alternatePath = canvas->rootObject()->findChild<QDeclarativePath*>("alternatePath"); + QVERIFY(alternatePath); + + QSignalSpy pathSpy(pathView, SIGNAL(pathChanged())); + + QCOMPARE(pathView->path(), path); + + pathView->setPath(alternatePath); + QCOMPARE(pathView->path(), alternatePath); + QCOMPARE(pathSpy.count(),1); + + pathView->setPath(alternatePath); + QCOMPARE(pathSpy.count(),1); + + QDeclarativePathAttribute *pathAttribute = canvas->rootObject()->findChild<QDeclarativePathAttribute*>("pathAttribute"); + QVERIFY(pathAttribute); + + QSignalSpy nameSpy(pathAttribute, SIGNAL(nameChanged())); + QCOMPARE(pathAttribute->name(), QString("opacity")); + + pathAttribute->setName("scale"); + QCOMPARE(pathAttribute->name(), QString("scale")); + QCOMPARE(nameSpy.count(),1); + + pathAttribute->setName("scale"); + QCOMPARE(nameSpy.count(),1); + delete canvas; +} + +void tst_QDeclarativePathView::componentChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativePathView *pathView = canvas->rootObject()->findChild<QDeclarativePathView*>("pathView"); + QVERIFY(pathView); + + QDeclarativeComponent delegateComponent(canvas->engine()); + delegateComponent.setData("import Qt 4.6; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile("")); + + QSignalSpy delegateSpy(pathView, SIGNAL(delegateChanged())); + + pathView->setDelegate(&delegateComponent); + QCOMPARE(pathView->delegate(), &delegateComponent); + QCOMPARE(delegateSpy.count(),1); + + pathView->setDelegate(&delegateComponent); + QCOMPARE(delegateSpy.count(),1); + delete canvas; +} + +void tst_QDeclarativePathView::modelChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativePathView *pathView = canvas->rootObject()->findChild<QDeclarativePathView*>("pathView"); + QVERIFY(pathView); + + QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel"); + QVERIFY(alternateModel); + QVariant modelVariant = QVariant::fromValue(alternateModel); + QSignalSpy modelSpy(pathView, SIGNAL(modelChanged())); + + pathView->setModel(modelVariant); + QCOMPARE(pathView->model(), modelVariant); + QCOMPARE(modelSpy.count(),1); + + pathView->setModel(modelVariant); + QCOMPARE(modelSpy.count(),1); + + pathView->setModel(QVariant()); + QCOMPARE(modelSpy.count(),2); + + delete canvas; +} QDeclarativeView *tst_QDeclarativePathView::createView() { diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml index 026ae83..0897847 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml @@ -3,6 +3,6 @@ import Test 1.0 MyTypeObject { property int value: 13; - rect.x: MyOffsetValueInterceptor {} + MyOffsetValueInterceptor on rect.x {} rect.x: value } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml index d4d4391..717f350 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml @@ -1,5 +1,5 @@ import Test 1.0 MyTypeObject { - rect.x: MyConstantValueSource {} + MyConstantValueSource on rect.x {} } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 69646b9..8732215 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -502,10 +502,9 @@ void tst_qdeclarativevaluetypes::valueInterceptors() QDeclarativeComponent component(&engine, TEST_FILE("valueInterceptors.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); checkNoErrors(component); - QEXPECT_FAIL("", "QT-2920", Abort); QVERIFY(object != 0); - QCOMPARE(object->rect().x(), 26); + QCOMPARE(object->rect().x(), 13); object->setProperty("value", 99); diff --git a/tests/auto/declarative/qdeclarativewebview/data/basic.qml b/tests/auto/declarative/qdeclarativewebview/data/basic.qml index 5394837..f0b41ef 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/basic.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/basic.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { url: "basic.html" diff --git a/tests/auto/declarative/qdeclarativewebview/data/elements.qml b/tests/auto/declarative/qdeclarativewebview/data/elements.qml index 7c030e6..16e5788 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/elements.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/elements.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { url: "elements.html" diff --git a/tests/auto/declarative/qdeclarativewebview/data/forward.png b/tests/auto/declarative/qdeclarativewebview/data/forward.png Binary files differnew file mode 100644 index 0000000..a82533e --- /dev/null +++ b/tests/auto/declarative/qdeclarativewebview/data/forward.png diff --git a/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml b/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml index 07eee88..0e92e0e 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { url: "javaScript.html" diff --git a/tests/auto/declarative/qdeclarativewebview/data/loadError.qml b/tests/auto/declarative/qdeclarativewebview/data/loadError.qml index 1460f30..f827238 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/loadError.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/loadError.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { url: "does-not-exist.html" diff --git a/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml b/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml index 0bc8263..4d9df43 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml @@ -1,6 +1,7 @@ // Demonstrates opening new WebViews from HTML import Qt 4.6 +import org.webkit 1.0 Grid { columns: 3 diff --git a/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml index 3dd4e51..0770acf 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 Item { width: 240 @@ -30,4 +31,4 @@ Item { pressGrabTime: 200 } } -}
\ No newline at end of file +} diff --git a/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml b/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml index 063b5a8..9e17597 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { html: "<p>This is a <b>string</b> set on the WebView" diff --git a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro index 6af0a60..20173c6 100644 --- a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro +++ b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro @@ -3,8 +3,7 @@ contains(QT_CONFIG,declarative): QT += declarative contains(QT_CONFIG,webkit): QT += webkit macx:CONFIG -= app_bundle -SOURCES += tst_qdeclarativewebview.cpp testtypes.cpp -HEADERS += testtypes.h +SOURCES += tst_qdeclarativewebview.cpp # Define SRCDIR equal to test's source directory DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativewebview/testtypes.cpp b/tests/auto/declarative/qdeclarativewebview/testtypes.cpp deleted file mode 100644 index 7efc214..0000000 --- a/tests/auto/declarative/qdeclarativewebview/testtypes.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "testtypes.h" - -void MyWebView::drawContents(QPainter *p, const QRect &r) -{ - pp += r.width()*r.height(); - QDeclarativeWebView::drawContents(p,r); -} - -void registerTypes() -{ - QML_REGISTER_TYPE(Test,1,0,MyWebView,MyWebView); -} diff --git a/tests/auto/declarative/qdeclarativewebview/testtypes.h b/tests/auto/declarative/qdeclarativewebview/testtypes.h deleted file mode 100644 index 8eb703f..0000000 --- a/tests/auto/declarative/qdeclarativewebview/testtypes.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef TESTTYPES_H -#define TESTTYPES_H - -#include <private/qdeclarativewebview_p.h> - -class MyWebView : public QDeclarativeWebView -{ - Q_OBJECT - Q_PROPERTY(int pixelsPainted READ pixelsPainted); - -public: - MyWebView() : pp(0) {} - - int pixelsPainted() const { return pp; } - - void drawContents(QPainter *p, const QRect &r); - -private: - int pp; -}; - -QML_DECLARE_TYPE(MyWebView); - -void registerTypes(); - -#endif // TESTTYPES_H diff --git a/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp b/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp index 6d16056..1d6bedc 100644 --- a/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp +++ b/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp @@ -43,15 +43,12 @@ #include "../../../shared/util.h" #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativecomponent.h> -#include <private/qdeclarativewebview_p.h> -#include <private/qdeclarativewebview_p_p.h> #include <private/qdeclarativepositioners_p.h> #include <QtWebKit/qwebpage.h> #include <QtWebKit/qwebframe.h> #include <QtCore/qdir.h> #include <QtCore/qfile.h> #include <QtGui/qpainter.h> -#include "testtypes.h" class tst_qdeclarativewebview : public QObject { @@ -70,7 +67,7 @@ private slots: void setHtml(); void javaScript(); void cleanupTestCase(); - void pixelCache(); + //void pixelCache(); void newWindowParent(); void newWindowComponent(); void renderingEnabled(); @@ -89,7 +86,6 @@ private: void tst_qdeclarativewebview::initTestCase() { - registerTypes(); } static QString strippedHtml(QString html) @@ -148,81 +144,81 @@ void tst_qdeclarativewebview::basicProperties() checkNoErrors(component); QWebSettings::enablePersistentStorage(tmpDir()); - QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create()); + QObject *wv = component.create(); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); - QCOMPARE(wv->title(),QString("Basic")); - QTRY_COMPARE(wv->icon().width(), 48); - QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/basic.png")); - QCOMPARE(wv->statusText(),QString("status here")); - QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html())); - QCOMPARE(wv->width(), 123.0); - QCOMPARE(wv->preferredWidth(), 0); - QCOMPARE(wv->preferredHeight(), 0); - QCOMPARE(wv->zoomFactor(), 1.0); - QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html")); - QCOMPARE(wv->status(), QDeclarativeWebView::Ready); - QVERIFY(wv->reloadAction()); - QVERIFY(wv->reloadAction()->isEnabled()); - QVERIFY(wv->backAction()); - QVERIFY(!wv->backAction()->isEnabled()); - QVERIFY(wv->forwardAction()); - QVERIFY(!wv->forwardAction()->isEnabled()); - QVERIFY(wv->stopAction()); - QVERIFY(!wv->stopAction()->isEnabled()); - - wv->setPixelCacheSize(0); // mainly testing that it doesn't crash or anything! - QCOMPARE(wv->pixelCacheSize(),0); - wv->reloadAction()->trigger(); - QTRY_COMPARE(wv->progress(), 1.0); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); + QCOMPARE(wv->property("title").toString(),QString("Basic")); + QTRY_COMPARE(qvariant_cast<QPixmap>(wv->property("icon")).width(), 48); + QCOMPARE(qvariant_cast<QPixmap>(wv->property("icon")),QPixmap(SRCDIR "/data/basic.png")); + QCOMPARE(wv->property("statusText").toString(),QString("status here")); + QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->property("html").toString())); + QCOMPARE(wv->property("width").toDouble(), 123.0); + QCOMPARE(wv->property("preferredWidth").toInt(), 0); + QCOMPARE(wv->property("preferredHeight").toInt(), 0); + QCOMPARE(wv->property("zoomFactor").toDouble(), 1.0); + QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/basic.html")); + QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/); + QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))); + QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("back"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("back"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("forward"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("forward"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("stop"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("stop"))->isEnabled()); + + wv->setProperty("pixelCacheSize", 0); // mainly testing that it doesn't crash or anything! + QCOMPARE(wv->property("pixelCacheSize").toInt(),0); + qvariant_cast<QAction*>(wv->property("reload"))->trigger(); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); } void tst_qdeclarativewebview::settings() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml")); checkNoErrors(component); - QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create()); + QObject *wv = component.create(); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); - QDeclarativeWebSettings *s = wv->settingsObject(); + QObject *s = qvariant_cast<QObject*>(wv->property("settings")); // merely tests that setting gets stored (in QWebSettings) // behavioural tests are in WebKit. for (int b=0; b<=1; ++b) { bool on = !!b; - s->setAutoLoadImages(on); - s->setDeveloperExtrasEnabled(on); - s->setJavaEnabled(on); - s->setJavascriptCanAccessClipboard(on); - s->setJavascriptCanOpenWindows(on); - s->setJavascriptEnabled(on); - s->setLinksIncludedInFocusChain(on); - s->setLocalContentCanAccessRemoteUrls(on); - s->setLocalStorageDatabaseEnabled(on); - s->setOfflineStorageDatabaseEnabled(on); - s->setOfflineWebApplicationCacheEnabled(on); - s->setPluginsEnabled(on); - s->setPrintElementBackgrounds(on); - s->setPrivateBrowsingEnabled(on); - s->setZoomTextOnly(on); - - QVERIFY(s->autoLoadImages() == on); - QVERIFY(s->developerExtrasEnabled() == on); - QVERIFY(s->javaEnabled() == on); - QVERIFY(s->javascriptCanAccessClipboard() == on); - QVERIFY(s->javascriptCanOpenWindows() == on); - QVERIFY(s->javascriptEnabled() == on); - QVERIFY(s->linksIncludedInFocusChain() == on); - QVERIFY(s->localContentCanAccessRemoteUrls() == on); - QVERIFY(s->localStorageDatabaseEnabled() == on); - QVERIFY(s->offlineStorageDatabaseEnabled() == on); - QVERIFY(s->offlineWebApplicationCacheEnabled() == on); - QVERIFY(s->pluginsEnabled() == on); - QVERIFY(s->printElementBackgrounds() == on); - QVERIFY(s->privateBrowsingEnabled() == on); - QVERIFY(s->zoomTextOnly() == on); + s->setProperty("autoLoadImages", on); + s->setProperty("developerExtrasEnabled", on); + s->setProperty("javaEnabled", on); + s->setProperty("javascriptCanAccessClipboard", on); + s->setProperty("javascriptCanOpenWindows", on); + s->setProperty("javascriptEnabled", on); + s->setProperty("linksIncludedInFocusChain", on); + s->setProperty("localContentCanAccessRemoteUrls", on); + s->setProperty("localStorageDatabaseEnabled", on); + s->setProperty("offlineStorageDatabaseEnabled", on); + s->setProperty("offlineWebApplicationCacheEnabled", on); + s->setProperty("pluginsEnabled", on); + s->setProperty("printElementBackgrounds", on); + s->setProperty("privateBrowsingEnabled", on); + s->setProperty("zoomTextOnly", on); + + QVERIFY(s->property("autoLoadImages") == on); + QVERIFY(s->property("developerExtrasEnabled") == on); + QVERIFY(s->property("javaEnabled") == on); + QVERIFY(s->property("javascriptCanAccessClipboard") == on); + QVERIFY(s->property("javascriptCanOpenWindows") == on); + QVERIFY(s->property("javascriptEnabled") == on); + QVERIFY(s->property("linksIncludedInFocusChain") == on); + QVERIFY(s->property("localContentCanAccessRemoteUrls") == on); + QVERIFY(s->property("localStorageDatabaseEnabled") == on); + QVERIFY(s->property("offlineStorageDatabaseEnabled") == on); + QVERIFY(s->property("offlineWebApplicationCacheEnabled") == on); + QVERIFY(s->property("pluginsEnabled") == on); + QVERIFY(s->property("printElementBackgrounds") == on); + QVERIFY(s->property("privateBrowsingEnabled") == on); + QVERIFY(s->property("zoomTextOnly") == on); QVERIFY(s->property("autoLoadImages") == on); QVERIFY(s->property("developerExtrasEnabled") == on); @@ -248,65 +244,65 @@ void tst_qdeclarativewebview::historyNav() checkNoErrors(component); QWebSettings::enablePersistentStorage(tmpDir()); - QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create()); + QObject *wv = component.create(); QVERIFY(wv != 0); for (int i=1; i<=2; ++i) { - QTRY_COMPARE(wv->progress(), 1.0); - QCOMPARE(wv->title(),QString("Basic")); - QTRY_COMPARE(wv->icon().width(), 48); - QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/basic.png")); - QCOMPARE(wv->statusText(),QString("status here")); - QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html())); - QCOMPARE(wv->width(), 123.0); - QCOMPARE(wv->preferredWidth(), 0); - QCOMPARE(wv->zoomFactor(), 1.0); - QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html")); - QCOMPARE(wv->status(), QDeclarativeWebView::Ready); - QVERIFY(wv->reloadAction()); - QVERIFY(wv->reloadAction()->isEnabled()); - QVERIFY(wv->backAction()); - QVERIFY(!wv->backAction()->isEnabled()); - QVERIFY(wv->forwardAction()); - QVERIFY(!wv->forwardAction()->isEnabled()); - QVERIFY(wv->stopAction()); - QVERIFY(!wv->stopAction()->isEnabled()); - - wv->reloadAction()->trigger(); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); + QCOMPARE(wv->property("title").toString(),QString("Basic")); + QTRY_COMPARE(qvariant_cast<QPixmap>(wv->property("icon")).width(), 48); + QCOMPARE(qvariant_cast<QPixmap>(wv->property("icon")),QPixmap(SRCDIR "/data/basic.png")); + QCOMPARE(wv->property("statusText").toString(),QString("status here")); + QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->property("html").toString())); + QCOMPARE(wv->property("width").toDouble(), 123.0); + QCOMPARE(wv->property("preferredWidth").toDouble(), 0.0); + QCOMPARE(wv->property("zoomFactor").toDouble(), 1.0); + QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/basic.html")); + QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/); + QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))); + QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("back"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("back"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("forward"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("forward"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("stop"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("stop"))->isEnabled()); + + qvariant_cast<QAction*>(wv->property("reload"))->trigger(); } - wv->setUrl(QUrl::fromLocalFile(SRCDIR "/data/forward.html")); - QTRY_COMPARE(wv->progress(), 1.0); - QCOMPARE(wv->title(),QString("Forward")); - QTRY_COMPARE(wv->icon().width(), 32); - QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/forward.png")); - QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/forward.html")), strippedHtml(wv->html())); - QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/forward.html")); - QCOMPARE(wv->status(), QDeclarativeWebView::Ready); - QCOMPARE(wv->statusText(),QString("")); - QVERIFY(wv->reloadAction()); - QVERIFY(wv->reloadAction()->isEnabled()); - QVERIFY(wv->backAction()); - QVERIFY(wv->backAction()->isEnabled()); - QVERIFY(wv->forwardAction()); - QVERIFY(!wv->forwardAction()->isEnabled()); - QVERIFY(wv->stopAction()); - QVERIFY(!wv->stopAction()->isEnabled()); - - wv->backAction()->trigger(); - - QTRY_COMPARE(wv->progress(), 1.0); - QCOMPARE(wv->title(),QString("Basic")); - QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html())); - QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html")); - QCOMPARE(wv->status(), QDeclarativeWebView::Ready); - QVERIFY(wv->reloadAction()); - QVERIFY(wv->reloadAction()->isEnabled()); - QVERIFY(wv->backAction()); - QVERIFY(!wv->backAction()->isEnabled()); - QVERIFY(wv->forwardAction()); - QVERIFY(wv->forwardAction()->isEnabled()); - QVERIFY(wv->stopAction()); - QVERIFY(!wv->stopAction()->isEnabled()); + wv->setProperty("url", QUrl::fromLocalFile(SRCDIR "/data/forward.html")); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); + QCOMPARE(wv->property("title").toString(),QString("Forward")); + QTRY_COMPARE(qvariant_cast<QPixmap>(wv->property("icon")).width(), 32); + QCOMPARE(qvariant_cast<QPixmap>(wv->property("icon")),QPixmap(SRCDIR "/data/forward.png")); + QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/forward.html")), strippedHtml(wv->property("html").toString())); + QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/forward.html")); + QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/); + QCOMPARE(wv->property("statusText").toString(),QString("")); + QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))); + QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("back"))); + QVERIFY(qvariant_cast<QAction*>(wv->property("back"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("forward"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("forward"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("stop"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("stop"))->isEnabled()); + + qvariant_cast<QAction*>(wv->property("back"))->trigger(); + + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); + QCOMPARE(wv->property("title").toString(),QString("Basic")); + QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->property("html").toString())); + QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/basic.html")); + QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/); + QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))); + QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("back"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("back"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("forward"))); + QVERIFY(qvariant_cast<QAction*>(wv->property("forward"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("stop"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("stop"))->isEnabled()); } void tst_qdeclarativewebview::multipleWindows() @@ -328,16 +324,16 @@ void tst_qdeclarativewebview::loadError() checkNoErrors(component); QWebSettings::enablePersistentStorage(tmpDir()); - QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create()); + QObject *wv = component.create(); QVERIFY(wv != 0); for (int i=1; i<=2; ++i) { - QTRY_COMPARE(wv->progress(), 1.0); - QCOMPARE(wv->title(),QString("")); - QCOMPARE(wv->statusText(),QString("")); // HTML 'status bar' text, not error message - QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/does-not-exist.html")); // Unlike QWebPage, which loses url - QCOMPARE(wv->status(), QDeclarativeWebView::Error); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); + QCOMPARE(wv->property("title").toString(),QString("")); + QCOMPARE(wv->property("statusText").toString(),QString("")); // HTML 'status bar' text, not error message + QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/does-not-exist.html")); // Unlike QWebPage, which loses url + QCOMPARE(wv->property("status").toInt(), 3 /*QDeclarativeWebView::Error*/); - wv->reloadAction()->trigger(); + qvariant_cast<QAction*>(wv->property("reload"))->trigger(); } } @@ -345,12 +341,12 @@ void tst_qdeclarativewebview::setHtml() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/sethtml.qml")); checkNoErrors(component); - QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create()); + QObject *wv = component.create(); QVERIFY(wv != 0); - QCOMPARE(wv->html(),QString("<html><head></head><body><p>This is a <b>string</b> set on the WebView</p></body></html>")); + QCOMPARE(wv->property("html").toString(),QString("<html><head></head><body><p>This is a <b>string</b> set on the WebView</p></body></html>")); QSignalSpy spy(wv, SIGNAL(htmlChanged())); - wv->setHtml(QString("<html><head><title>Basic</title></head><body><p>text</p></body></html>")); + wv->setProperty("html", QString("<html><head><title>Basic</title></head><body><p>text</p></body></html>")); QCOMPARE(spy.count(),1); } @@ -358,81 +354,91 @@ void tst_qdeclarativewebview::elementAreaAt() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/elements.qml")); checkNoErrors(component); - QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create()); + QObject *wv = component.create(); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); + /* not now it's a plugin... QCOMPARE(wv->elementAreaAt(40,30,100,100),QRect(1,1,75,54)); // Area A in data/elements.html QCOMPARE(wv->elementAreaAt(130,30,200,100),QRect(78,3,110,50)); // Area B QCOMPARE(wv->elementAreaAt(40,30,400,400),QRect(0,0,310,100)); // Whole view QCOMPARE(wv->elementAreaAt(130,30,280,280),QRect(76,1,223,54)); // Area BC QCOMPARE(wv->elementAreaAt(130,30,400,400),QRect(0,0,310,100)); // Whole view + */ } void tst_qdeclarativewebview::javaScript() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/javaScript.qml")); checkNoErrors(component); - QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create()); + QObject *wv = component.create(); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); + /* not now it's a plugin... QCOMPARE(wv->evaluateJavaScript("123").toInt(), 123); QCOMPARE(wv->evaluateJavaScript("window.status").toString(), QString("status here")); QCOMPARE(wv->evaluateJavaScript("window.myjsname.qmlprop").toString(), QString("qmlvalue")); + */ } +/* +Cannot be done now that webkit is a plugin + void tst_qdeclarativewebview::pixelCache() { + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/pixelCache.qml")); checkNoErrors(component); MyWebView *wv = qobject_cast<MyWebView*>(component.create()); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); + QTRY_COMPARE(wv->property("progress"), 1.0); QPixmap pm(150,150); QPainter p(&pm); wv->paint(&p,0,0); const int expected = 120*(150+128); // 120 = width of HTML page, 150=pixmap height, 128=cache extra area - QCOMPARE(wv->pixelsPainted(), expected); + QCOMPARE(wv->property("pixelsPainted"), expected); wv->paint(&p,0,0); - QCOMPARE(wv->pixelsPainted(), expected); // nothing new needed to be painted - wv->setPixelCacheSize(0); // clears the cache + QCOMPARE(wv->property("pixelsPainted"), expected); // nothing new needed to be painted + wv->setProperty("pixelCacheSize", 0); // clears the cache wv->paint(&p,0,0); - QCOMPARE(wv->pixelsPainted(), expected*2); // everything needed to be painted + QCOMPARE(wv->property("pixelsPainted"), expected*2); // everything needed to be painted // Note that painted things always go into the cache (even if they don't "fit"), // just that they will be removed if anything else needs to be painted. - wv->setPixelCacheSize(expected); // won't clear the cache + wv->setProperty("pixelCacheSize", expected); // won't clear the cache wv->paint(&p,0,0); - QCOMPARE(wv->pixelsPainted(), expected*2); // still there - wv->setPixelCacheSize(expected-1); // too small - will clear the cache + QCOMPARE(wv->property("pixelsPainted"), expected*2); // still there + wv->setProperty("pixelCacheSize", expected-1); // too small - will clear the cache wv->paint(&p,0,0); - QCOMPARE(wv->pixelsPainted(), expected*3); // repainted + QCOMPARE(wv->property("pixelsPainted"), expected*3); // repainted } +*/ void tst_qdeclarativewebview::newWindowParent() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); checkNoErrors(component); QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create()); - QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView"); + QObject *wv = rootItem->findChild<QObject*>("webView"); QVERIFY(rootItem != 0); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); QDeclarativeItem* oldWindowParent = rootItem->findChild<QDeclarativeItem*>("oldWindowParent"); - QCOMPARE(wv->newWindowParent(), oldWindowParent); + QCOMPARE(qvariant_cast<QDeclarativeItem*>(wv->property("newWindowParent")), oldWindowParent); QSignalSpy newWindowParentSpy(wv, SIGNAL(newWindowParentChanged())); QDeclarativeItem* newWindowParent = rootItem->findChild<QDeclarativeItem*>("newWindowParent"); - wv->setNewWindowParent(newWindowParent); + wv->setProperty("newWindowParent", QVariant::fromValue(newWindowParent)); + QVERIFY(newWindowParent); QVERIFY(oldWindowParent); QVERIFY(oldWindowParent->childItems().count() == 0); - QCOMPARE(wv->newWindowParent(), newWindowParent); + QCOMPARE(wv->property("newWindowParent"), QVariant::fromValue(newWindowParent)); QCOMPARE(newWindowParentSpy.count(),1); - wv->setNewWindowParent(newWindowParent); + wv->setProperty("newWindowParent", QVariant::fromValue(newWindowParent)); QCOMPARE(newWindowParentSpy.count(),1); - wv->setNewWindowParent(0); + wv->setProperty("newWindowParent", QVariant::fromValue((QDeclarativeItem*)0)); QCOMPARE(newWindowParentSpy.count(),2); } @@ -441,23 +447,23 @@ void tst_qdeclarativewebview::newWindowComponent() QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); checkNoErrors(component); QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create()); - QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView"); + QObject *wv = rootItem->findChild<QObject*>("webView"); QVERIFY(rootItem != 0); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); QDeclarativeComponent substituteComponent(&engine); substituteComponent.setData("import Qt 4.6; WebView { objectName: 'newWebView'; url: 'basic.html'; }", QUrl::fromLocalFile("")); QSignalSpy newWindowComponentSpy(wv, SIGNAL(newWindowComponentChanged())); - wv->setNewWindowComponent(&substituteComponent); - QCOMPARE(wv->newWindowComponent(), &substituteComponent); + wv->setProperty("newWindowComponent", QVariant::fromValue(&substituteComponent)); + QCOMPARE(wv->property("newWindowComponent"), QVariant::fromValue(&substituteComponent)); QCOMPARE(newWindowComponentSpy.count(),1); - wv->setNewWindowComponent(&substituteComponent); + wv->setProperty("newWindowComponent", QVariant::fromValue(&substituteComponent)); QCOMPARE(newWindowComponentSpy.count(),1); - wv->setNewWindowComponent(0); + wv->setProperty("newWindowComponent", QVariant::fromValue((QDeclarativeComponent*)0)); QCOMPARE(newWindowComponentSpy.count(),2); } @@ -466,22 +472,22 @@ void tst_qdeclarativewebview::renderingEnabled() QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); checkNoErrors(component); QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create()); - QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView"); + QObject *wv = rootItem->findChild<QObject*>("webView"); QVERIFY(rootItem != 0); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); - QVERIFY(wv->renderingEnabled()); + QVERIFY(wv->property("renderingEnabled").toBool()); QSignalSpy renderingEnabledSpy(wv, SIGNAL(renderingEnabledChanged())); - wv->setRenderingEnabled(false); - QVERIFY(!wv->renderingEnabled()); + wv->setProperty("renderingEnabled", false); + QVERIFY(!wv->property("renderingEnabled").toBool()); QCOMPARE(renderingEnabledSpy.count(),1); - wv->setRenderingEnabled(false); + wv->setProperty("renderingEnabled", false); QCOMPARE(renderingEnabledSpy.count(),1); - wv->setRenderingEnabled(true); + wv->setProperty("renderingEnabled", true); QCOMPARE(renderingEnabledSpy.count(),2); } @@ -490,21 +496,21 @@ void tst_qdeclarativewebview::pressGrabTime() QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); checkNoErrors(component); QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create()); - QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView"); + QObject *wv = rootItem->findChild<QObject*>("webView"); QVERIFY(rootItem != 0); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); - QCOMPARE(wv->pressGrabTime(), 200); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); + QCOMPARE(wv->property("pressGrabTime").toInt(), 200); QSignalSpy pressGrabTimeSpy(wv, SIGNAL(pressGrabTimeChanged())); - wv->setPressGrabTime(100); - QCOMPARE(wv->pressGrabTime(), 100); + wv->setProperty("pressGrabTime", 100); + QCOMPARE(wv->property("pressGrabTime").toInt(), 100); QCOMPARE(pressGrabTimeSpy.count(),1); - wv->setPressGrabTime(100); + wv->setProperty("pressGrabTime", 100); QCOMPARE(pressGrabTimeSpy.count(),1); - wv->setPressGrabTime(0); + wv->setProperty("pressGrabTime", 0); QCOMPARE(pressGrabTimeSpy.count(),2); } diff --git a/tests/auto/declarative/qdeclarativeworkerlistmodel/data/model.qml b/tests/auto/declarative/qdeclarativeworkerlistmodel/data/model.qml new file mode 100644 index 0000000..be94e00 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerlistmodel/data/model.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Item { + property alias model: model + + WorkerListModel { id: model } + + function workerModifyModel(cmd) { worker.sendMessage({'command': cmd, 'model': model}) } + + WorkerScript { + id: worker + source: "script.js" + } +} diff --git a/tests/auto/declarative/qdeclarativeworkerlistmodel/data/script.js b/tests/auto/declarative/qdeclarativeworkerlistmodel/data/script.js new file mode 100644 index 0000000..8ee62b4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerlistmodel/data/script.js @@ -0,0 +1,6 @@ +WorkerScript.onMessage = function(msg) { + eval("msg.model." + msg.command) + msg.model.sync() +} + + diff --git a/tests/auto/declarative/qdeclarativeworkerlistmodel/qdeclarativeworkerlistmodel.pro b/tests/auto/declarative/qdeclarativeworkerlistmodel/qdeclarativeworkerlistmodel.pro new file mode 100644 index 0000000..960dbe1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerlistmodel/qdeclarativeworkerlistmodel.pro @@ -0,0 +1,9 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +QT += script +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativeworkerlistmodel.cpp + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeworkerlistmodel/tst_qdeclarativeworkerlistmodel.cpp b/tests/auto/declarative/qdeclarativeworkerlistmodel/tst_qdeclarativeworkerlistmodel.cpp new file mode 100644 index 0000000..11a7447 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerlistmodel/tst_qdeclarativeworkerlistmodel.cpp @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <qtest.h> +#include <QtCore/qdebug.h> + +#include <QtDeclarative/qdeclarativecomponent.h> +#include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativeitem.h> + +#include <private/qdeclarativeworkerscript_p.h> +#include <private/qdeclarativelistmodel_p.h> +#include "../../../shared/util.h" + + + +class tst_QDeclarativeWorkerListModel : public QObject +{ + Q_OBJECT +public: + tst_QDeclarativeWorkerListModel() {} +private slots: + void clear(); + void remove(); + void append(); + void insert(); + void get(); + void set(); + +private: + QByteArray modificationWarning() const { + QString file = QUrl::fromLocalFile(SRCDIR "/data/model.qml").toString(); + return QString("QML WorkerListModel (" + file + ":6:5) List can only be modified from a WorkerScript").toUtf8(); + } + + QDeclarativeEngine m_engine; +}; + +void tst_QDeclarativeWorkerListModel::clear() +{ + QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item != 0); + QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); + QVERIFY(model != 0); + + QCOMPARE(model->count(), 0); + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "append({'name': 'A'})"))); + QTRY_COMPARE(model->count(), 1); + + QTest::ignoreMessage(QtWarningMsg, modificationWarning().constData()); + model->clear(); + QCOMPARE(model->count(), 1); + + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "clear()"))); + QTRY_COMPARE(model->count(), 0); + + qApp->processEvents(); +} + +void tst_QDeclarativeWorkerListModel::remove() +{ + QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item != 0); + QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); + QVERIFY(model != 0); + + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "append({'name': 'A'})"))); + QTRY_COMPARE(model->count(), 1); + + QTest::ignoreMessage(QtWarningMsg, modificationWarning().constData()); + model->remove(0); + QCOMPARE(model->count(), 1); + + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "remove(0)"))); + QTRY_COMPARE(model->count(), 0); + + qApp->processEvents(); +} + +void tst_QDeclarativeWorkerListModel::append() +{ + QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item != 0); + QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); + QVERIFY(model != 0); + + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "append({'name': 'A'})"))); + QTRY_COMPARE(model->count(), 1); + + QTest::ignoreMessage(QtWarningMsg, modificationWarning().constData()); + model->append(QScriptValue(1)); + QCOMPARE(model->count(), 1); + + qApp->processEvents(); +} + +void tst_QDeclarativeWorkerListModel::insert() +{ + QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item != 0); + QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); + QVERIFY(model != 0); + + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "insert(0, {'name': 'A'})"))); + QTRY_COMPARE(model->count(), 1); + + QTest::ignoreMessage(QtWarningMsg, modificationWarning().constData()); + model->insert(0, QScriptValue(1)); + QCOMPARE(model->count(), 1); + + qApp->processEvents(); +} + +void tst_QDeclarativeWorkerListModel::get() +{ + QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item != 0); + QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); + QVERIFY(model != 0); + + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "append({'name': 'A'})"))); + QTRY_COMPARE(model->count(), 1); + QCOMPARE(model->get(0).property("name").toString(), QString("A")); + + qApp->processEvents(); +} + +void tst_QDeclarativeWorkerListModel::set() +{ + QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item != 0); + QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); + QVERIFY(model != 0); + + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "append({'name': 'A'})"))); + QTRY_COMPARE(model->count(), 1); + + QTest::ignoreMessage(QtWarningMsg, modificationWarning().constData()); + model->set(0, QScriptValue(1)); + + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "set(0, {'name': 'Z'})"))); + QTRY_COMPARE(model->get(0).property("name").toString(), QString("Z")); + + qApp->processEvents(); +} + +QTEST_MAIN(tst_QDeclarativeWorkerListModel) + +#include "tst_qdeclarativeworkerlistmodel.moc" + diff --git a/tests/auto/declarative/visual/qfxwebview/autosize/autosize.qml b/tests/auto/declarative/visual/qfxwebview/autosize/autosize.qml index 74c6844..3c00ee6 100644 --- a/tests/auto/declarative/visual/qfxwebview/autosize/autosize.qml +++ b/tests/auto/declarative/visual/qfxwebview/autosize/autosize.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 // The WebView size is determined by the width, height, // preferredWidth, and preferredHeight properties. diff --git a/tests/auto/declarative/visual/webview/embedding/nesting.qml b/tests/auto/declarative/visual/webview/embedding/nesting.qml index 0d76579..5e35306 100644 --- a/tests/auto/declarative/visual/webview/embedding/nesting.qml +++ b/tests/auto/declarative/visual/webview/embedding/nesting.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { width: 300 diff --git a/tests/auto/declarative/visual/webview/javascript/evaluateJavaScript.qml b/tests/auto/declarative/visual/webview/javascript/evaluateJavaScript.qml index 78d5cfc..6c01382 100644 --- a/tests/auto/declarative/visual/webview/javascript/evaluateJavaScript.qml +++ b/tests/auto/declarative/visual/webview/javascript/evaluateJavaScript.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 Column { WebView { diff --git a/tests/auto/declarative/visual/webview/javascript/windowObjects.qml b/tests/auto/declarative/visual/webview/javascript/windowObjects.qml index a41de9a..8c52aff 100644 --- a/tests/auto/declarative/visual/webview/javascript/windowObjects.qml +++ b/tests/auto/declarative/visual/webview/javascript/windowObjects.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 Column { WebView { diff --git a/tests/auto/declarative/visual/webview/settings/fontFamily.qml b/tests/auto/declarative/visual/webview/settings/fontFamily.qml index 2bb2a53..f547b0e 100644 --- a/tests/auto/declarative/visual/webview/settings/fontFamily.qml +++ b/tests/auto/declarative/visual/webview/settings/fontFamily.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { id: web diff --git a/tests/auto/declarative/visual/webview/settings/fontSize.qml b/tests/auto/declarative/visual/webview/settings/fontSize.qml index b970783..7eaa96b 100644 --- a/tests/auto/declarative/visual/webview/settings/fontSize.qml +++ b/tests/auto/declarative/visual/webview/settings/fontSize.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 Grid { columns: 3 diff --git a/tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml b/tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml index 72e672d..67f1633 100644 --- a/tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml +++ b/tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 Grid { columns: 2 diff --git a/tests/auto/declarative/visual/webview/settings/setFontFamily.qml b/tests/auto/declarative/visual/webview/settings/setFontFamily.qml index 26deed8..823469f 100644 --- a/tests/auto/declarative/visual/webview/settings/setFontFamily.qml +++ b/tests/auto/declarative/visual/webview/settings/setFontFamily.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { url: "test.html" diff --git a/tests/auto/declarative/visual/webview/zooming/pageWidth.qml b/tests/auto/declarative/visual/webview/zooming/pageWidth.qml index 86dd7d2..4a876dd 100644 --- a/tests/auto/declarative/visual/webview/zooming/pageWidth.qml +++ b/tests/auto/declarative/visual/webview/zooming/pageWidth.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { width: 200 diff --git a/tests/auto/declarative/visual/webview/zooming/renderControl.qml b/tests/auto/declarative/visual/webview/zooming/renderControl.qml index 0c8bb3b..49eb91b 100644 --- a/tests/auto/declarative/visual/webview/zooming/renderControl.qml +++ b/tests/auto/declarative/visual/webview/zooming/renderControl.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 Rectangle { width: 200 diff --git a/tests/auto/declarative/visual/webview/zooming/resolution.qml b/tests/auto/declarative/visual/webview/zooming/resolution.qml index a9d4e3a..8542768 100644 --- a/tests/auto/declarative/visual/webview/zooming/resolution.qml +++ b/tests/auto/declarative/visual/webview/zooming/resolution.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { width: 200 * zoomFactor diff --git a/tests/auto/declarative/visual/webview/zooming/zoomTextOnly.qml b/tests/auto/declarative/visual/webview/zooming/zoomTextOnly.qml index 4455b43..c2e9348 100644 --- a/tests/auto/declarative/visual/webview/zooming/zoomTextOnly.qml +++ b/tests/auto/declarative/visual/webview/zooming/zoomTextOnly.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { width: 200 diff --git a/tests/auto/declarative/visual/webview/zooming/zooming.qml b/tests/auto/declarative/visual/webview/zooming/zooming.qml index 0ea9131..9f0b865 100644 --- a/tests/auto/declarative/visual/webview/zooming/zooming.qml +++ b/tests/auto/declarative/visual/webview/zooming/zooming.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 // Note that zooming is better done using zoomFactor and careful // control of rendering to avoid excessive re-rendering during |