diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-11-16 05:46:33 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-11-16 05:46:33 (GMT) |
commit | 1c029319fb787c1ef6bce0f76fff991679b944f2 (patch) | |
tree | 35f0d2ec9bdac1ac6f1a03ae249b2f9d7765b243 /tests | |
parent | a62fbc821c3c32c0ebe63a77f2705d6f1db67394 (diff) | |
parent | ee6c7d5cdc7707a5eb50a46ba8056a6b43348159 (diff) | |
download | Qt-1c029319fb787c1ef6bce0f76fff991679b944f2.zip Qt-1c029319fb787c1ef6bce0f76fff991679b944f2.tar.gz Qt-1c029319fb787c1ef6bce0f76fff991679b944f2.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'tests')
8 files changed, 122 insertions, 10 deletions
diff --git a/tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml b/tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml index d9e9f27..32833d2 100644 --- a/tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml +++ b/tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml @@ -45,7 +45,7 @@ Rectangle { currentIndex: 5 cellWidth: 80 cellHeight: 60 - model: testModel delegate: myDelegate + model: testModel } } diff --git a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp index d09aad7..d0b7462 100644 --- a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp +++ b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp @@ -390,7 +390,11 @@ void tst_QmlGraphicsGridView::removed() gridview->setViewportY(120); gridview->setCurrentIndex(10); + // let transitions settle. + QTest::qWait(300); + model.removeItem(1); + // let transitions settle. QTest::qWait(300); diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml b/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml index 65a9d8a..74f5ef4 100644 --- a/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml +++ b/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml @@ -43,8 +43,8 @@ Rectangle { width: 240 height: 320 keyNavigationWraps: testWrap - model: testModel delegate: myDelegate highlightMoveSpeed: 1000 + model: testModel } } diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml index ccefeba..ec8bb68 100644 --- a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml +++ b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml @@ -4,6 +4,29 @@ Rectangle { width: 240 height: 320 color: "#ffffff" + function checkProperties() { + testObject.error = false; + if (list.model != testModel) { + print("model property incorrect"); + testObject.error = true; + } + if (!testObject.animate && list.delegate != myDelegate) { + print("delegate property incorrect - expected myDelegate"); + testObject.error = true; + } + if (testObject.animate && list.delegate != animatedDelegate) { + print("delegate property incorrect - expected animatedDelegate"); + testObject.error = true; + } + if (testObject.invalidHighlight && list.highlight != invalidHl) { + print("highlight property incorrect - expected invalidHl"); + testObject.error = true; + } + if (!testObject.invalidHighlight && list.highlight != myHighlight) { + print("highlight property incorrect - expected myHighlight"); + testObject.error = true; + } + } resources: [ Component { id: myDelegate @@ -70,6 +93,14 @@ Rectangle { */ } } + }, + Component { + id: myHighlight + Rectangle { color: "green" } + }, + Component { + id: invalidHl + EaseFollow {} } ] ListView { @@ -79,7 +110,8 @@ Rectangle { width: 240 height: 320 model: testModel - delegate: testAnimate ? myDelegate : animatedDelegate + delegate: testObject.animate ? animatedDelegate : myDelegate + highlight: testObject.invalidHighlight ? invalidHl : myHighlight highlightMoveSpeed: 1000 highlightResizeSpeed: 1000 } diff --git a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp index d416603..7e6dc0d 100644 --- a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp +++ b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp @@ -90,6 +90,38 @@ private: QList<T*> findItems(QmlGraphicsItem *parent, const QString &objectName); }; +class TestObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(bool error READ error WRITE setError NOTIFY changedError) + Q_PROPERTY(bool animate READ animate NOTIFY changedAnim) + Q_PROPERTY(bool invalidHighlight READ invalidHighlight NOTIFY changedHl) + +public: + TestObject(QObject *parent = 0) + : QObject(parent), mError(true), mAnimate(false), mInvalidHighlight(false) {} + + bool error() const { return mError; } + void setError(bool err) { mError = err; emit changedError(); } + + bool animate() const { return mAnimate; } + void setAnimate(bool anim) { mAnimate = anim; emit changedAnim(); } + + bool invalidHighlight() const { return mInvalidHighlight; } + void setInvalidHighlight(bool invalid) { mInvalidHighlight = invalid; emit changedHl(); } + +signals: + void changedError(); + void changedAnim(); + void changedHl(); + +public: + bool mError; + bool mAnimate; + bool mInvalidHighlight; +}; + class TestModel : public QListModelInterface { Q_OBJECT @@ -243,7 +275,9 @@ void tst_QmlGraphicsListView::items() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -254,6 +288,9 @@ void tst_QmlGraphicsListView::items() QmlGraphicsItem *viewport = listview->viewport(); QVERIFY(viewport != 0); + QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QVERIFY(testObject->error() == false); + QCOMPARE(listview->count(), model.count()); QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item @@ -269,6 +306,16 @@ void tst_QmlGraphicsListView::items() QCOMPARE(number->text(), model.number(i)); } + // switch to other delegate + testObject->setAnimate(true); + QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QVERIFY(testObject->error() == false); + + // set invalid highlight + testObject->setInvalidHighlight(true); + QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QVERIFY(testObject->error() == false); + // set an empty model and confirm that items are destroyed T model2; ctxt->setContextProperty("testModel", &model2); @@ -294,7 +341,9 @@ void tst_QmlGraphicsListView::changed() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -328,7 +377,9 @@ void tst_QmlGraphicsListView::inserted() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -415,7 +466,10 @@ void tst_QmlGraphicsListView::removed(bool animated) QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(animated)); + + TestObject *testObject = new TestObject; + testObject->setAnimate(animated); + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -526,7 +580,9 @@ void tst_QmlGraphicsListView::moved() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -665,7 +721,9 @@ void tst_QmlGraphicsListView::spacing() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -934,7 +992,9 @@ void tst_QmlGraphicsListView::cacheBuffer() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -944,6 +1004,9 @@ void tst_QmlGraphicsListView::cacheBuffer() QmlGraphicsItem *viewport = listview->viewport(); QVERIFY(viewport != 0); + QVERIFY(listview->delegate() != 0); + QVERIFY(listview->model() != 0); + QVERIFY(listview->highlight() == 0); // Confirm items positioned correctly int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count(); @@ -955,6 +1018,7 @@ void tst_QmlGraphicsListView::cacheBuffer() } listview->setCacheBuffer(400); + QVERIFY(listview->cacheBuffer() == 400); int newItemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count(); QVERIFY(newItemCount > itemCount); diff --git a/tests/auto/declarative/qmlqt/data/darker.qml b/tests/auto/declarative/qmlqt/data/darker.qml index 6369e8f..96ffa77 100644 --- a/tests/auto/declarative/qmlqt/data/darker.qml +++ b/tests/auto/declarative/qmlqt/data/darker.qml @@ -4,5 +4,8 @@ Object { property var test1: Qt.darker(Qt.rgba(1, 0.8, 0.3)) property var test2: Qt.darker() property var test3: Qt.darker(Qt.rgba(1, 0.8, 0.3), 10) + property var test4: Qt.darker("red"); + property var test5: Qt.darker("perfectred"); // Non-existant color + property var test6: Qt.darker(10); } diff --git a/tests/auto/declarative/qmlqt/data/lighter.qml b/tests/auto/declarative/qmlqt/data/lighter.qml index 6c888e7..2e9fdc8 100644 --- a/tests/auto/declarative/qmlqt/data/lighter.qml +++ b/tests/auto/declarative/qmlqt/data/lighter.qml @@ -4,4 +4,7 @@ Object { property var test1: Qt.lighter(Qt.rgba(1, 0.8, 0.3)) property var test2: Qt.lighter() property var test3: Qt.lighter(Qt.rgba(1, 0.8, 0.3), 10) + property var test4: Qt.lighter("red"); + property var test5: Qt.lighter("perfectred"); // Non-existant color + property var test6: Qt.lighter(10); } diff --git a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp index 13f4904..4d09aee 100644 --- a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp +++ b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp @@ -213,6 +213,9 @@ void tst_qmlqt::lighter() QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).lighter()); QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor()); QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").lighter()); + QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor()); delete object; } @@ -226,6 +229,9 @@ void tst_qmlqt::darker() QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).darker()); QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor()); QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").darker()); + QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor()); delete object; } |