summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/gridview.qml6
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp59
2 files changed, 39 insertions, 26 deletions
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/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 2a60fee..7a6a060 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -47,6 +47,7 @@
#include <qdeclarativeview.h>
#include <private/qdeclarativegridview_p.h>
#include <private/qdeclarativetext_p.h>
+#include <private/qdeclarativerectangle_p.h>
#include <qdeclarativecontext.h>
#include <qdeclarativeexpression.h>
@@ -253,7 +254,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 +265,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 +279,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 +301,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 +339,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 +348,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 +366,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 +388,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 +402,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 +414,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 +428,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 +449,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 +457,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 +503,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 +535,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 +557,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 +600,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 +627,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 +686,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 +736,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();