summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/runningTrueBug.qml30
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp15
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/eval.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/function.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp13
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml2
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp231
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml2
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp274
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments.qml43
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_cb.pngbin0 -> 528 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_cc.pngbin0 -> 549 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_ct.pngbin0 -> 564 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_lb.pngbin0 -> 522 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_lc.pngbin0 -> 541 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_lt.pngbin0 -> 558 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_rb.pngbin0 -> 530 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_rc.pngbin0 -> 550 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_rt.pngbin0 -> 564 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp66
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments.qml43
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.pngbin0 -> 528 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.pngbin0 -> 549 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.pngbin0 -> 564 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.pngbin0 -> 522 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.pngbin0 -> 541 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.pngbin0 -> 558 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.pngbin0 -> 530 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.pngbin0 -> 550 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.pngbin0 -> 564 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp54
-rw-r--r--tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp6
36 files changed, 542 insertions, 265 deletions
diff --git a/tests/auto/declarative/qdeclarativeanimations/data/runningTrueBug.qml b/tests/auto/declarative/qdeclarativeanimations/data/runningTrueBug.qml
new file mode 100644
index 0000000..2c5207e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimations/data/runningTrueBug.qml
@@ -0,0 +1,30 @@
+import Qt 4.7
+Rectangle {
+ color: "skyblue"
+ width: 500
+ height: 200
+ Rectangle {
+ objectName: "cloud"
+ color: "white"
+ y: 50
+ width: 100
+ height: 100
+
+ SequentialAnimation on x {
+ loops: Animation.Infinite
+ running: true
+ NumberAnimation {
+ id: firstAnimation
+ from: 0
+ to: 500
+ duration: 5000
+ }
+ NumberAnimation {
+ id: secondAnimation
+ from: -100
+ to: 0
+ duration: 1000
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
index 5cf4c23..a965ef3 100644
--- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
+++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
@@ -81,6 +81,7 @@ private slots:
void dontStart();
void easingProperties();
void rotation();
+ void runningTrueBug();
};
#define QTIMED_COMPARE(lhs, rhs) do { \
@@ -733,6 +734,20 @@ void tst_qdeclarativeanimations::rotation()
QTIMED_COMPARE(rr->rotation() + rr2->rotation() + rr3->rotation() + rr4->rotation(), qreal(370*4));
}
+void tst_qdeclarativeanimations::runningTrueBug()
+{
+ //ensure we start correctly when "running: true" is explicitly set
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/runningTrueBug.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *cloud = rect->findChild<QDeclarativeRectangle*>("cloud");
+ QVERIFY(cloud);
+ QTest::qWait(1000);
+ QVERIFY(cloud->x() > qreal(0));
+}
+
QTEST_MAIN(tst_qdeclarativeanimations)
#include "tst_qdeclarativeanimations.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml
index bc2df98..aab39be 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml
@@ -16,7 +16,11 @@ QtObject {
test1 = (eval("a") == 7);
test2 = (eval("b") == 9);
- test3 = (eval("c") == undefined);
+ try {
+ eval("c");
+ } catch(e) {
+ test3 = true;
+ }
test4 = (eval("console") == console);
test5 = (eval("Qt") == Qt);
}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml
index b435f58..80d6ef4 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml
@@ -14,6 +14,10 @@ QtObject {
test1 = (func1(4) == 11);
test2 = (func2("Hello World!") == Qt.atob("Hello World!"));
- test3 = (func3() == undefined);
+ try {
+ func3();
+ } catch(e) {
+ test3 = true;
+ }
}
}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml
index e8f7b62..f601f49 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml
@@ -4,7 +4,7 @@ import "scriptErrors.js" as Script
MyQmlObject {
property int t: a.value
property int w: Script.getValue();
- property int x: undefinedObject
+ property int x: undefined
property int y: (a.value, undefinedObject)
onBasicSignal: { console.log(a.value); }
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 16e7ec5..50da55d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -1002,10 +1002,10 @@ void tst_qdeclarativeecmascript::scriptErrors()
QString url = component.url().toString();
QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\"";
- QString warning2 = url + ":5: TypeError: Result of expression 'a' [undefined] is not an object.";
+ QString warning2 = url + ":5: ReferenceError: Can't find variable: a";
QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\"";
- QString warning4 = url + ":10: TypeError: Result of expression 'a' [undefined] is not an object.";
- QString warning5 = url + ":8: TypeError: Result of expression 'a' [undefined] is not an object.";
+ QString warning4 = url + ":10: ReferenceError: Can't find variable: a";
+ QString warning5 = url + ":8: ReferenceError: Can't find variable: a";
QString warning6 = url + ":7: Unable to assign [undefined] to int x";
QString warning7 = url + ":12: Error: Cannot assign to read-only property \"trueProperty\"";
QString warning8 = url + ":13: Error: Cannot assign to non-existent property \"fakeProperty\"";
@@ -1322,7 +1322,12 @@ void tst_qdeclarativeecmascript::callQtInvokables()
QDeclarativeEngine qmlengine;
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(&qmlengine);
QScriptEngine *engine = &ep->scriptEngine;
- ep->globalClass->explicitSetProperty("object", ep->objectClass->newQObject(&o));
+
+ QStringList names; QList<QScriptValue> values;
+ names << QLatin1String("object"); values << ep->objectClass->newQObject(&o);
+ names << QLatin1String("undefined"); values << engine->undefinedValue();
+
+ ep->globalClass->explicitSetProperty(names, values);
// Non-existent methods
o.reset();
diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml
index aa156ed..a840a01 100644
--- a/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml
+++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml
@@ -1,6 +1,12 @@
import Qt 4.7
Flickable {
+ property bool ok: false
+ function check() {
+ if (column.parent == contentItem)
+ ok = true;
+ }
+
width: 100; height: 100
contentWidth: column.width; contentHeight: column.height
pressDelay: 200; boundsBehavior: Flickable.StopAtBounds; interactive: false
diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
index 2ba5574..678996b 100644
--- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
+++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
@@ -147,6 +147,10 @@ void tst_qdeclarativeflickable::properties()
QCOMPARE(obj->pressDelay(), 200);
QCOMPARE(obj->maximumFlickVelocity(), 2000.);
+ QVERIFY(obj->property("ok").toBool() == false);
+ QMetaObject::invokeMethod(obj, "check");
+ QVERIFY(obj->property("ok").toBool() == true);
+
delete obj;
}
diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml
index 9331243..a5d651d 100644
--- a/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml
+++ b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml
@@ -43,7 +43,7 @@ Rectangle {
focus: true
width: 240
height: 320
- currentIndex: 5
+ currentIndex: 35
cellWidth: 80
cellHeight: 60
delegate: myDelegate
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 4e35bc0..a67c56f 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -178,17 +178,17 @@ void tst_QDeclarativeGridView::items()
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QTRY_COMPARE(gridview->count(), model.count());
- QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
for (int i = 0; i < model.count(); ++i) {
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", i);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(i));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", i);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(i));
}
@@ -197,7 +197,7 @@ void tst_QDeclarativeGridView::items()
TestModel model2;
ctxt->setContextProperty("testModel", &model2);
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
QTRY_VERIFY(itemCount == 0);
delete canvas;
@@ -226,14 +226,14 @@ void tst_QDeclarativeGridView::changed()
QDeclarativeFlickable *gridview = findItem<QDeclarativeFlickable>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.modifyItem(1, "Will", "9876");
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(1));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(1));
@@ -259,17 +259,17 @@ void tst_QDeclarativeGridView::inserted()
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.insertItem(1, "Will", "9876");
- QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(1));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(1));
@@ -279,19 +279,19 @@ void tst_QDeclarativeGridView::inserted()
// Confirm items positioned correctly
for (int i = 0; i < model.count(); ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
QTRY_COMPARE(item->x(), (i%3)*80.0);
QTRY_COMPARE(item->y(), (i/3)*60.0);
}
model.insertItem(0, "Foo", "1111"); // zero index, and current item
- QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
- name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ name = findItem<QDeclarativeText>(contentItem, "textName", 0);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", 0);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(0));
@@ -299,7 +299,7 @@ void tst_QDeclarativeGridView::inserted()
// Confirm items positioned correctly
for (int i = 0; i < model.count(); ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
QTRY_VERIFY(item->x() == (i%3)*80);
QTRY_VERIFY(item->y() == (i/3)*60);
}
@@ -335,15 +335,15 @@ void tst_QDeclarativeGridView::removed()
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.removeItem(1);
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(1));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(1));
@@ -352,9 +352,9 @@ void tst_QDeclarativeGridView::removed()
QTRY_COMPARE(removed, QString("Item1"));
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->x() == (i%3)*80);
@@ -364,17 +364,17 @@ void tst_QDeclarativeGridView::removed()
// Remove first item (which is the current item);
model.removeItem(0);
- name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ name = findItem<QDeclarativeText>(contentItem, "textName", 0);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", 0);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(0));
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->x() == (i%3)*80);
@@ -385,9 +385,9 @@ void tst_QDeclarativeGridView::removed()
model.removeItem(25);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->x() == (i%3)*80);
@@ -405,7 +405,7 @@ void tst_QDeclarativeGridView::removed()
// Confirm items positioned correctly
for (int i = 6; i < 18; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->x() == (i%3)*80);
@@ -424,9 +424,9 @@ void tst_QDeclarativeGridView::removed()
QTest::qWait(100);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->x() == (i%3)*80);
@@ -478,29 +478,29 @@ void tst_QDeclarativeGridView::moved()
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.moveItem(1, 8);
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(1));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(1));
- name = findItem<QDeclarativeText>(viewport, "textName", 8);
+ name = findItem<QDeclarativeText>(contentItem, "textName", 8);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(8));
- number = findItem<QDeclarativeText>(viewport, "textNumber", 8);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", 8);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(8));
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->x() == (i%3)*80);
@@ -513,17 +513,17 @@ void tst_QDeclarativeGridView::moved()
model.moveItem(1, 25);
// Confirm items positioned correctly and indexes correct
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count()-1;
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count()-1;
for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), qreal((i%3)*80));
QTRY_COMPARE(item->y(), qreal((i/3)*60));
- name = findItem<QDeclarativeText>(viewport, "textName", i);
+ name = findItem<QDeclarativeText>(contentItem, "textName", i);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", i);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(i));
}
@@ -533,15 +533,15 @@ void tst_QDeclarativeGridView::moved()
// Confirm items positioned correctly and indexes correct
for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->x() == (i%3)*80);
QTRY_VERIFY(item->y() == (i/3)*60);
- name = findItem<QDeclarativeText>(viewport, "textName", i);
+ name = findItem<QDeclarativeText>(contentItem, "textName", i);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", i);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(i));
}
@@ -557,7 +557,7 @@ void tst_QDeclarativeGridView::moved()
void tst_QDeclarativeGridView::currentIndex()
{
TestModel model;
- for (int i = 0; i < 30; i++)
+ for (int i = 0; i < 60; i++)
model.addItem("Item" + QString::number(i), QString::number(i));
QDeclarativeView *canvas = new QDeclarativeView(0);
@@ -572,57 +572,58 @@ void tst_QDeclarativeGridView::currentIndex()
qApp->processEvents();
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
+ QVERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
// current item should be third item
- QTRY_COMPARE(gridview->currentIndex(), 5);
- QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 5));
- QTRY_COMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
+ QCOMPARE(gridview->currentIndex(), 35);
+ QCOMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 35));
+ QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
+ QCOMPARE(gridview->contentY(), 399.0);
gridview->moveCurrentIndexRight();
- QTRY_COMPARE(gridview->currentIndex(), 6);
+ QCOMPARE(gridview->currentIndex(), 36);
gridview->moveCurrentIndexDown();
- QTRY_COMPARE(gridview->currentIndex(), 9);
+ QCOMPARE(gridview->currentIndex(), 39);
gridview->moveCurrentIndexUp();
- QTRY_COMPARE(gridview->currentIndex(), 6);
+ QCOMPARE(gridview->currentIndex(), 36);
gridview->moveCurrentIndexLeft();
- QTRY_COMPARE(gridview->currentIndex(), 5);
+ QCOMPARE(gridview->currentIndex(), 35);
// no wrap
gridview->setCurrentIndex(0);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->moveCurrentIndexUp();
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->moveCurrentIndexLeft();
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->setCurrentIndex(model.count()-1);
- QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
gridview->moveCurrentIndexRight();
- QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
gridview->moveCurrentIndexDown();
- QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
// with wrap
gridview->setWrapEnabled(true);
gridview->setCurrentIndex(0);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->moveCurrentIndexLeft();
- QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
- QTRY_COMPARE(gridview->contentY(), 279.0);
+ QTRY_COMPARE(gridview->contentY(), 879.0);
gridview->moveCurrentIndexRight();
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
QTRY_COMPARE(gridview->contentY(), 0.0);
@@ -638,30 +639,30 @@ void tst_QDeclarativeGridView::currentIndex()
qApp->processEvents();
QTest::keyClick(canvas, Qt::Key_Down);
- QTRY_COMPARE(gridview->currentIndex(), 3);
+ QCOMPARE(gridview->currentIndex(), 3);
QTest::keyClick(canvas, Qt::Key_Up);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->setFlow(QDeclarativeGridView::TopToBottom);
QTest::keyClick(canvas, Qt::Key_Right);
- QTRY_COMPARE(gridview->currentIndex(), 5);
+ QCOMPARE(gridview->currentIndex(), 5);
QTest::keyClick(canvas, Qt::Key_Left);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
QTest::keyClick(canvas, Qt::Key_Down);
- QTRY_COMPARE(gridview->currentIndex(), 1);
+ QCOMPARE(gridview->currentIndex(), 1);
QTest::keyClick(canvas, Qt::Key_Up);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
// turn off auto highlight
gridview->setHighlightFollowsCurrentItem(false);
- QTRY_VERIFY(gridview->highlightFollowsCurrentItem() == false);
- QTRY_VERIFY(gridview->highlightItem());
+ QVERIFY(gridview->highlightFollowsCurrentItem() == false);
+ QVERIFY(gridview->highlightItem());
qreal hlPosX = gridview->highlightItem()->x();
qreal hlPosY = gridview->highlightItem()->y();
@@ -695,21 +696,21 @@ void tst_QDeclarativeGridView::changeFlow()
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
// Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), qreal((i%3)*80));
QTRY_COMPARE(item->y(), qreal((i/3)*60));
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", i);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(i));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", i);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(i));
}
@@ -717,17 +718,17 @@ void tst_QDeclarativeGridView::changeFlow()
ctxt->setContextProperty("testTopToBottom", QVariant(true));
// Confirm items positioned correctly and indexes correct
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), qreal((i/5)*80));
QTRY_COMPARE(item->y(), qreal((i%5)*60));
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", i);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(i));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", i);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(i));
}
@@ -913,13 +914,13 @@ void tst_QDeclarativeGridView::positionViewAtIndex()
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), (i%3)*80.);
@@ -931,9 +932,9 @@ void tst_QDeclarativeGridView::positionViewAtIndex()
QTRY_COMPARE(gridview->contentY(), 60.);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), (i%3)*80.);
@@ -945,9 +946,9 @@ void tst_QDeclarativeGridView::positionViewAtIndex()
QTRY_COMPARE(gridview->contentY(), 420.);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), (i%3)*80.);
@@ -959,9 +960,9 @@ void tst_QDeclarativeGridView::positionViewAtIndex()
QTRY_COMPARE(gridview->contentY(), 520.);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), (i%3)*80.);
@@ -973,9 +974,9 @@ void tst_QDeclarativeGridView::positionViewAtIndex()
QTRY_COMPARE(gridview->contentY(), 0.);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), (i%3)*80.);
@@ -1043,13 +1044,13 @@ void tst_QDeclarativeGridView::resetModel()
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QTRY_COMPARE(gridview->count(), model.rowCount());
for (int i = 0; i < model.rowCount(); ++i) {
- QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QDeclarativeText *display = findItem<QDeclarativeText>(contentItem, "displayText", i);
QTRY_VERIFY(display != 0);
QTRY_COMPARE(display->text(), strings.at(i));
}
@@ -1061,7 +1062,7 @@ void tst_QDeclarativeGridView::resetModel()
QTRY_COMPARE(gridview->count(), model.rowCount());
for (int i = 0; i < model.rowCount(); ++i) {
- QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QDeclarativeText *display = findItem<QDeclarativeText>(contentItem, "displayText", i);
QTRY_VERIFY(display != 0);
QTRY_COMPARE(display->text(), strings.at(i));
}
@@ -1088,22 +1089,22 @@ void tst_QDeclarativeGridView::enforceRange()
QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0);
QTRY_COMPARE(gridview->highlightRangeMode(), QDeclarativeGridView::StrictlyEnforceRange);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
// view should be positioned at the top of the range.
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 0);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 0);
QTRY_VERIFY(item);
QTRY_COMPARE(gridview->contentY(), -100.0);
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 0);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(0));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 0);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(0));
- // Check currentIndex is updated when viewport moves
+ // Check currentIndex is updated when contentItem moves
gridview->setContentY(0);
QTRY_COMPARE(gridview->currentIndex(), 2);
@@ -1145,18 +1146,18 @@ void tst_QDeclarativeGridView::manualHighlight()
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QTRY_COMPARE(gridview->currentIndex(), 0);
- QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0));
+ QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 0));
QTRY_COMPARE(gridview->highlightItem()->y(), gridview->currentItem()->y());
QTRY_COMPARE(gridview->highlightItem()->x(), gridview->currentItem()->x());
gridview->setCurrentIndex(2);
QTRY_COMPARE(gridview->currentIndex(), 2);
- QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 2));
+ QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 2));
QTRY_COMPARE(gridview->highlightItem()->y(), gridview->currentItem()->y());
QTRY_COMPARE(gridview->highlightItem()->x(), gridview->currentItem()->x());
}
diff --git a/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml b/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml
index 0599ddd..f3c2910 100644
--- a/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml
@@ -40,7 +40,7 @@ Rectangle {
id: list
objectName: "list"
focus: true
- currentIndex: 3
+ currentIndex: 20
width: 240
height: 320
keyNavigationWraps: testWrap
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index cd42b63..048f0f3 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -336,24 +336,24 @@ void tst_QDeclarativeListView::items()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
QTRY_VERIFY(testObject->error() == false);
QTRY_VERIFY(listview->highlightItem() != 0);
QTRY_COMPARE(listview->count(), model.count());
- QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
// current item should be first item
- QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0));
+ QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 0));
for (int i = 0; i < model.count(); ++i) {
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", i);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(i));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", i);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(i));
}
@@ -382,7 +382,7 @@ void tst_QDeclarativeListView::items()
T model2;
ctxt->setContextProperty("testModel", &model2);
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
QTRY_VERIFY(itemCount == 0);
QTRY_COMPARE(listview->highlightResizeSpeed(), 1000.0);
@@ -414,14 +414,14 @@ void tst_QDeclarativeListView::changed()
QDeclarativeFlickable *listview = findItem<QDeclarativeFlickable>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.modifyItem(1, "Will", "9876");
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(1));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(1));
@@ -450,34 +450,34 @@ void tst_QDeclarativeListView::inserted()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.insertItem(1, "Will", "9876");
- QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(1));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(1));
// Confirm items positioned correctly
for (int i = 0; i < model.count(); ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
QTRY_COMPARE(item->y(), i*20.0);
}
model.insertItem(0, "Foo", "1111"); // zero index, and current item
- QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
- name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ name = findItem<QDeclarativeText>(contentItem, "textName", 0);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", 0);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(0));
@@ -485,7 +485,7 @@ void tst_QDeclarativeListView::inserted()
// Confirm items positioned correctly
for (int i = 0; i < model.count(); ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
QTRY_COMPARE(item->y(), i*20.0);
}
@@ -501,13 +501,13 @@ void tst_QDeclarativeListView::inserted()
// Confirm items positioned correctly
for (int i = 5; i < 5+15; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.0 - 20.0);
}
-// QTRY_COMPARE(listview->viewportHeight(), model.count() * 20.0);
+// QTRY_COMPARE(listview->contentItemHeight(), model.count() * 20.0);
delete canvas;
}
@@ -534,22 +534,22 @@ void tst_QDeclarativeListView::removed(bool animated)
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.removeItem(1);
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(1));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(1));
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->y() == i*20);
@@ -560,17 +560,17 @@ void tst_QDeclarativeListView::removed(bool animated)
QTest::qWait(300);
- name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ name = findItem<QDeclarativeText>(contentItem, "textName", 0);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", 0);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(0));
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(),i*20.0 + 20.0);
@@ -581,9 +581,9 @@ void tst_QDeclarativeListView::removed(bool animated)
qApp->processEvents();
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(),i*20.0+20.0);
@@ -598,7 +598,7 @@ void tst_QDeclarativeListView::removed(bool animated)
// Confirm items positioned correctly
for (int i = 2; i < 18; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(),40+i*20.0);
@@ -617,9 +617,9 @@ void tst_QDeclarativeListView::removed(bool animated)
QTest::qWait(300);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(),40+i*20.0);
@@ -665,8 +665,8 @@ void tst_QDeclarativeListView::clear()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.clear();
@@ -699,29 +699,29 @@ void tst_QDeclarativeListView::moved()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.moveItem(1, 4);
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(1));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(1));
- name = findItem<QDeclarativeText>(viewport, "textName", 4);
+ name = findItem<QDeclarativeText>(contentItem, "textName", 4);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(4));
- number = findItem<QDeclarativeText>(viewport, "textNumber", 4);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", 4);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(4));
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->y() == i*20);
@@ -734,14 +734,14 @@ void tst_QDeclarativeListView::moved()
// Confirm items positioned correctly and indexes correct
for (int i = 3; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.0 + 20);
- name = findItem<QDeclarativeText>(viewport, "textName", i);
+ name = findItem<QDeclarativeText>(contentItem, "textName", i);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", i);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(i));
}
@@ -751,14 +751,14 @@ void tst_QDeclarativeListView::moved()
// Confirm items positioned correctly and indexes correct
for (int i = 3; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.0 + 20);
- name = findItem<QDeclarativeText>(viewport, "textName", i);
+ name = findItem<QDeclarativeText>(contentItem, "textName", i);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", i);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(i));
}
@@ -787,22 +787,22 @@ void tst_QDeclarativeListView::enforceRange()
QTRY_COMPARE(listview->preferredHighlightEnd(), 100.0);
QTRY_COMPARE(listview->highlightRangeMode(), QDeclarativeListView::StrictlyEnforceRange);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
// view should be positioned at the top of the range.
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 0);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 0);
QTRY_VERIFY(item);
QTRY_COMPARE(listview->contentY(), -100.0);
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 0);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(0));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 0);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(0));
- // Check currentIndex is updated when viewport moves
+ // Check currentIndex is updated when contentItem moves
listview->setContentY(20);
QTRY_COMPARE(listview->currentIndex(), 6);
@@ -838,13 +838,13 @@ void tst_QDeclarativeListView::spacing()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->y() == i*20);
@@ -854,9 +854,9 @@ void tst_QDeclarativeListView::spacing()
QTRY_VERIFY(listview->spacing() == 10);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->y() == i*30);
@@ -865,9 +865,9 @@ void tst_QDeclarativeListView::spacing()
listview->setSpacing(0);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.0);
@@ -893,13 +893,13 @@ void tst_QDeclarativeListView::sections()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20));
}
@@ -908,29 +908,29 @@ void tst_QDeclarativeListView::sections()
model.removeItem(5);
// New section header created
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 5);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 5);
QTRY_VERIFY(item);
QTRY_COMPARE(item->height(), 40.0);
model.insertItem(3, "New Item", "0");
// Section header moved
- item = findItem<QDeclarativeItem>(viewport, "wrapper", 5);
+ item = findItem<QDeclarativeItem>(contentItem, "wrapper", 5);
QTRY_VERIFY(item);
QTRY_COMPARE(item->height(), 20.0);
- item = findItem<QDeclarativeItem>(viewport, "wrapper", 6);
+ item = findItem<QDeclarativeItem>(contentItem, "wrapper", 6);
QTRY_VERIFY(item);
QTRY_COMPARE(item->height(), 40.0);
// insert item which will become a section header
model.insertItem(6, "Replace header", "1");
- item = findItem<QDeclarativeItem>(viewport, "wrapper", 6);
+ item = findItem<QDeclarativeItem>(contentItem, "wrapper", 6);
QTRY_VERIFY(item);
QTRY_COMPARE(item->height(), 40.0);
- item = findItem<QDeclarativeItem>(viewport, "wrapper", 7);
+ item = findItem<QDeclarativeItem>(contentItem, "wrapper", 7);
QTRY_VERIFY(item);
QTRY_COMPARE(item->height(), 20.0);
@@ -942,7 +942,7 @@ void tst_QDeclarativeListView::sections()
listview->setContentY(20);
QTRY_COMPARE(listview->currentSection(), QString("0"));
- item = findItem<QDeclarativeItem>(viewport, "wrapper", 1);
+ item = findItem<QDeclarativeItem>(contentItem, "wrapper", 1);
QTRY_VERIFY(item);
QTRY_COMPARE(item->height(), 20.0);
@@ -970,37 +970,39 @@ void tst_QDeclarativeListView::currentIndex()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
- // current item should be third item
- QTRY_COMPARE(listview->currentIndex(), 3);
- QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 3));
- QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
+ // current item should be 20th item at startup
+ // and current item should be in view
+ QCOMPARE(listview->currentIndex(), 20);
+ QCOMPARE(listview->contentY(), 99.0);
+ QCOMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 20));
+ QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
// no wrap
listview->setCurrentIndex(0);
- QTRY_COMPARE(listview->currentIndex(), 0);
+ QCOMPARE(listview->currentIndex(), 0);
listview->incrementCurrentIndex();
- QTRY_COMPARE(listview->currentIndex(), 1);
+ QCOMPARE(listview->currentIndex(), 1);
listview->decrementCurrentIndex();
- QTRY_COMPARE(listview->currentIndex(), 0);
+ QCOMPARE(listview->currentIndex(), 0);
listview->decrementCurrentIndex();
- QTRY_COMPARE(listview->currentIndex(), 0);
+ QCOMPARE(listview->currentIndex(), 0);
// with wrap
ctxt->setContextProperty("testWrap", QVariant(true));
- QTRY_VERIFY(listview->isWrapEnabled());
+ QVERIFY(listview->isWrapEnabled());
listview->decrementCurrentIndex();
- QTRY_COMPARE(listview->currentIndex(), model.count()-1);
+ QCOMPARE(listview->currentIndex(), model.count()-1);
QTRY_COMPARE(listview->contentY(), 279.0);
listview->incrementCurrentIndex();
- QTRY_COMPARE(listview->currentIndex(), 0);
+ QCOMPARE(listview->currentIndex(), 0);
QTRY_COMPARE(listview->contentY(), 0.0);
@@ -1016,16 +1018,16 @@ void tst_QDeclarativeListView::currentIndex()
qApp->processEvents();
QTest::keyClick(canvas, Qt::Key_Down);
- QTRY_COMPARE(listview->currentIndex(), 1);
+ QCOMPARE(listview->currentIndex(), 1);
QTest::keyClick(canvas, Qt::Key_Up);
- QTRY_COMPARE(listview->currentIndex(), 0);
+ QCOMPARE(listview->currentIndex(), 0);
// turn off auto highlight
listview->setHighlightFollowsCurrentItem(false);
- QTRY_VERIFY(listview->highlightFollowsCurrentItem() == false);
+ QVERIFY(listview->highlightFollowsCurrentItem() == false);
- QTRY_VERIFY(listview->highlightItem());
+ QVERIFY(listview->highlightItem());
qreal hlPos = listview->highlightItem()->y();
listview->setCurrentIndex(4);
@@ -1049,8 +1051,8 @@ void tst_QDeclarativeListView::itemList()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "view");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QDeclarativeVisualItemModel *model = canvas->rootObject()->findChild<QDeclarativeVisualItemModel*>("itemModel");
QTRY_VERIFY(model != 0);
@@ -1058,21 +1060,21 @@ void tst_QDeclarativeListView::itemList()
QTRY_VERIFY(model->count() == 3);
QTRY_COMPARE(listview->currentIndex(), 0);
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "item1");
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "item1");
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), 0.0);
- QDeclarativeText *text = findItem<QDeclarativeText>(viewport, "text1");
+ QDeclarativeText *text = findItem<QDeclarativeText>(contentItem, "text1");
QTRY_VERIFY(text);
QTRY_COMPARE(text->text(), QLatin1String("index: 0"));
listview->setCurrentIndex(2);
- item = findItem<QDeclarativeItem>(viewport, "item3");
+ item = findItem<QDeclarativeItem>(contentItem, "item3");
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), 480.0);
- text = findItem<QDeclarativeText>(viewport, "text3");
+ text = findItem<QDeclarativeText>(contentItem, "text3");
QTRY_VERIFY(text);
QTRY_COMPARE(text->text(), QLatin1String("index: 2"));
@@ -1099,16 +1101,16 @@ void tst_QDeclarativeListView::cacheBuffer()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QTRY_VERIFY(listview->delegate() != 0);
QTRY_VERIFY(listview->model() != 0);
QTRY_VERIFY(listview->highlight() != 0);
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->y() == i*20);
@@ -1117,12 +1119,12 @@ void tst_QDeclarativeListView::cacheBuffer()
testObject->setCacheBuffer(400);
QTRY_VERIFY(listview->cacheBuffer() == 400);
- int newItemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int newItemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
QTRY_VERIFY(newItemCount > itemCount);
// Confirm items positioned correctly
for (int i = 0; i < model.count() && i < newItemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->y() == i*20);
@@ -1151,13 +1153,13 @@ void tst_QDeclarativeListView::positionViewAtIndex()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.);
@@ -1168,9 +1170,9 @@ void tst_QDeclarativeListView::positionViewAtIndex()
QTRY_COMPARE(listview->contentY(), 60.);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.);
@@ -1181,9 +1183,9 @@ void tst_QDeclarativeListView::positionViewAtIndex()
QTRY_COMPARE(listview->contentY(), 440.);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.);
@@ -1194,9 +1196,9 @@ void tst_QDeclarativeListView::positionViewAtIndex()
QTRY_COMPARE(listview->contentY(), 480.);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.);
@@ -1207,9 +1209,9 @@ void tst_QDeclarativeListView::positionViewAtIndex()
QTRY_COMPARE(listview->contentY(), 0.);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.);
@@ -1276,13 +1278,13 @@ void tst_QDeclarativeListView::resetModel()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QTRY_COMPARE(listview->count(), model.rowCount());
for (int i = 0; i < model.rowCount(); ++i) {
- QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QDeclarativeText *display = findItem<QDeclarativeText>(contentItem, "displayText", i);
QTRY_VERIFY(display != 0);
QTRY_COMPARE(display->text(), strings.at(i));
}
@@ -1294,7 +1296,7 @@ void tst_QDeclarativeListView::resetModel()
QTRY_COMPARE(listview->count(), model.rowCount());
for (int i = 0; i < model.rowCount(); ++i) {
- QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QDeclarativeText *display = findItem<QDeclarativeText>(contentItem, "displayText", i);
QTRY_VERIFY(display != 0);
QTRY_COMPARE(display->text(), strings.at(i));
}
@@ -1453,8 +1455,8 @@ void tst_QDeclarativeListView::QTBUG_9791()
QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(canvas->rootObject());
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QTRY_VERIFY(listview->delegate() != 0);
QTRY_VERIFY(listview->model() != 0);
@@ -1462,11 +1464,11 @@ void tst_QDeclarativeListView::QTBUG_9791()
qApp->processEvents();
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
QVERIFY(itemCount == 3);
for (int i = 0; i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), i*300.0);
@@ -1493,17 +1495,17 @@ void tst_QDeclarativeListView::manualHighlight()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QTRY_COMPARE(listview->currentIndex(), 0);
- QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0));
+ QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 0));
QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
listview->setCurrentIndex(2);
QTRY_COMPARE(listview->currentIndex(), 2);
- QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 2));
+ QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 2));
QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
}
@@ -1527,13 +1529,13 @@ void tst_QDeclarativeListView::QTBUG_11105()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->y() == i*20);
@@ -1548,7 +1550,7 @@ void tst_QDeclarativeListView::QTBUG_11105()
ctxt->setContextProperty("testModel", &model2);
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
QCOMPARE(itemCount, 5);
delete canvas;
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments.qml b/tests/auto/declarative/qdeclarativetext/data/alignments.qml
new file mode 100644
index 0000000..b10c335
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments.qml
@@ -0,0 +1,43 @@
+import Qt 4.7
+
+Rectangle {
+ id: top
+ width: 70; height: 70;
+
+ property alias horizontalAlignment: t.horizontalAlignment
+ property alias verticalAlignment: t.verticalAlignment
+ property alias wrapMode: t.wrapMode
+ property alias running: timer.running
+ property string txt: "Test"
+
+ Rectangle {
+ anchors.centerIn: parent
+ width: 40
+ height: 40
+ color: "green"
+
+ Text {
+ id: t
+
+ anchors.fill: parent
+ font.family: "Misc Fixed"
+ font.pixelSize: 8
+ horizontalAlignment: TextEdit.AlignRight
+ verticalAlignment: TextEdit.AlignBottom
+ wrapMode: TextEdit.WordWrap
+ text: top.txt
+ }
+ Timer {
+ id: timer
+
+ interval: 1
+ running: true
+ repeat: true
+ onTriggered: {
+ top.txt = top.txt + "<br>more " + top.txt.length;
+ if (top.txt.length > 50)
+ running = false
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png b/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png
new file mode 100644
index 0000000..b0ad381
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png
new file mode 100644
index 0000000..98232ce
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png b/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png
new file mode 100644
index 0000000..b606ba5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lb.png b/tests/auto/declarative/qdeclarativetext/data/alignments_lb.png
new file mode 100644
index 0000000..a8f095d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_lb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_lc.png
new file mode 100644
index 0000000..c2a0679
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_lc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lt.png b/tests/auto/declarative/qdeclarativetext/data/alignments_lt.png
new file mode 100644
index 0000000..c019551
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_lt.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rb.png b/tests/auto/declarative/qdeclarativetext/data/alignments_rb.png
new file mode 100644
index 0000000..08d581a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_rb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_rc.png
new file mode 100644
index 0000000..d607955
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_rc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rt.png b/tests/auto/declarative/qdeclarativetext/data/alignments_rt.png
new file mode 100644
index 0000000..2acfb9e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_rt.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
index 01120b1..91b3ca0 100644
--- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
+++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
@@ -47,6 +47,7 @@
#include <QFontMetrics>
#include <QGraphicsSceneMouseEvent>
#include <qmath.h>
+#include <QDeclarativeView>
#include "../../../shared/util.h"
#include "testhttpserver.h"
@@ -70,6 +71,9 @@ private slots:
void elide();
void textFormat();
+ void alignments_data();
+ void alignments();
+
void embeddedImages_data();
void embeddedImages();
@@ -108,6 +112,8 @@ private:
QStringList colorStrings;
QDeclarativeEngine engine;
+
+ QDeclarativeView *createView(const QString &filename);
};
tst_qdeclarativetext::tst_qdeclarativetext()
@@ -163,6 +169,14 @@ tst_qdeclarativetext::tst_qdeclarativetext()
//
}
+QDeclarativeView *tst_qdeclarativetext::createView(const QString &filename)
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+ return canvas;
+}
+
void tst_qdeclarativetext::text()
{
{
@@ -383,6 +397,58 @@ void tst_qdeclarativetext::textFormat()
}
}
+
+void tst_qdeclarativetext::alignments_data()
+{
+ QTest::addColumn<int>("hAlign");
+ QTest::addColumn<int>("vAlign");
+ QTest::addColumn<QString>("expectfile");
+
+ QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << SRCDIR "/data/alignments_lt.png";
+ QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << SRCDIR "/data/alignments_rt.png";
+ QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << SRCDIR "/data/alignments_ct.png";
+
+ QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_lb.png";
+ QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_rb.png";
+ QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_cb.png";
+
+ QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_lc.png";
+ QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_rc.png";
+ QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_cc.png";
+}
+
+
+void tst_qdeclarativetext::alignments()
+{
+ QFETCH(int, hAlign);
+ QFETCH(int, vAlign);
+ QFETCH(QString, expectfile);
+
+ QDeclarativeView *canvas = createView(SRCDIR "/data/alignments.qml");
+
+ canvas->show();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QObject *ob = canvas->rootObject();
+ QVERIFY(ob != 0);
+ ob->setProperty("horizontalAlignment",hAlign);
+ ob->setProperty("verticalAlignment",vAlign);
+ QTRY_COMPARE(ob->property("running").toBool(),false);
+ QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32);
+ actual.fill(qRgb(255,255,255));
+ QPainter p(&actual);
+ canvas->render(&p);
+
+ QImage expect(expectfile);
+
+#ifdef Q_OS_LINUX
+ // Font-specific, but not likely platform-specific, so only test on one platform
+ QCOMPARE(actual,expect);
+#endif
+}
+
//the alignment tests may be trivial o.oa
void tst_qdeclarativetext::horizontalAlignment()
{
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml b/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml
new file mode 100644
index 0000000..b10c335
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml
@@ -0,0 +1,43 @@
+import Qt 4.7
+
+Rectangle {
+ id: top
+ width: 70; height: 70;
+
+ property alias horizontalAlignment: t.horizontalAlignment
+ property alias verticalAlignment: t.verticalAlignment
+ property alias wrapMode: t.wrapMode
+ property alias running: timer.running
+ property string txt: "Test"
+
+ Rectangle {
+ anchors.centerIn: parent
+ width: 40
+ height: 40
+ color: "green"
+
+ Text {
+ id: t
+
+ anchors.fill: parent
+ font.family: "Misc Fixed"
+ font.pixelSize: 8
+ horizontalAlignment: TextEdit.AlignRight
+ verticalAlignment: TextEdit.AlignBottom
+ wrapMode: TextEdit.WordWrap
+ text: top.txt
+ }
+ Timer {
+ id: timer
+
+ interval: 1
+ running: true
+ repeat: true
+ onTriggered: {
+ top.txt = top.txt + "<br>more " + top.txt.length;
+ if (top.txt.length > 50)
+ running = false
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.png
new file mode 100644
index 0000000..b0ad381
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.png
new file mode 100644
index 0000000..98232ce
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.png
new file mode 100644
index 0000000..b606ba5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.png
new file mode 100644
index 0000000..a8f095d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.png
new file mode 100644
index 0000000..c2a0679
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.png
new file mode 100644
index 0000000..c019551
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.png
new file mode 100644
index 0000000..08d581a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.png
new file mode 100644
index 0000000..d607955
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.png
new file mode 100644
index 0000000..2acfb9e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index f7ba7a1..009d354 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -73,6 +73,8 @@ private slots:
void width();
void wrap();
void textFormat();
+ void alignments();
+ void alignments_data();
// ### these tests may be trivial
void hAlign();
@@ -297,6 +299,58 @@ void tst_qdeclarativetextedit::textFormat()
}
}
+void tst_qdeclarativetextedit::alignments_data()
+{
+ QTest::addColumn<int>("hAlign");
+ QTest::addColumn<int>("vAlign");
+ QTest::addColumn<QString>("expectfile");
+
+ QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << SRCDIR "/data/alignments_lt.png";
+ QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << SRCDIR "/data/alignments_rt.png";
+ QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << SRCDIR "/data/alignments_ct.png";
+
+ QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_lb.png";
+ QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_rb.png";
+ QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_cb.png";
+
+ QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_lc.png";
+ QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_rc.png";
+ QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_cc.png";
+}
+
+
+void tst_qdeclarativetextedit::alignments()
+{
+ QFETCH(int, hAlign);
+ QFETCH(int, vAlign);
+ QFETCH(QString, expectfile);
+
+ QDeclarativeView *canvas = createView(SRCDIR "/data/alignments.qml");
+
+ canvas->show();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QObject *ob = canvas->rootObject();
+ QVERIFY(ob != 0);
+ ob->setProperty("horizontalAlignment",hAlign);
+ ob->setProperty("verticalAlignment",vAlign);
+ QTRY_COMPARE(ob->property("running").toBool(),false);
+ QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32);
+ actual.fill(qRgb(255,255,255));
+ QPainter p(&actual);
+ canvas->render(&p);
+
+ QImage expect(expectfile);
+
+#ifdef Q_OS_LINUX
+ // Font-specific, but not likely platform-specific, so only test on one platform
+ QCOMPARE(actual,expect);
+#endif
+}
+
+
//the alignment tests may be trivial o.oa
void tst_qdeclarativetextedit::hAlign()
{
diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
index f30f758..1ea2a95 100644
--- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
+++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
@@ -261,7 +261,7 @@ void tst_QDeclarativeViewer::resizing()
QCOMPARE(rootItem->width(), 150.0);
QCOMPARE(rootItem->height(), 200.0);
- QCOMPARE(viewer->view()->size(), QSize(150, 200));
+ QTRY_COMPARE(viewer->view()->size(), QSize(150, 200));
QCOMPARE(viewer->view()->initialSize(), QSize(200, 300));
QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(150, 200));
QCOMPARE(viewer->size(), QSize(150, 200+viewer->menuBar()->height()));
@@ -279,7 +279,7 @@ void tst_QDeclarativeViewer::resizing()
QTRY_COMPARE(rootItem->width(), 250.0);
QTRY_COMPARE(rootItem->height(), 350.0-viewer->menuBar()->height());
- QCOMPARE(viewer->view()->size(), QSize(250, 350-viewer->menuBar()->height()));
+ QTRY_COMPARE(viewer->view()->size(), QSize(250, 350-viewer->menuBar()->height()));
QCOMPARE(viewer->view()->initialSize(), QSize(200, 300));
QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350-viewer->menuBar()->height()));
QCOMPARE(viewer->size(), QSize(250, 350));
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
index 90c9c6f..43d4d06 100644
--- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
@@ -173,10 +173,10 @@ void tst_qdeclarativevisualdatamodel::objectListModel()
QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject());
QVERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "name", 0);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "name", 0);
QCOMPARE(name->text(), QString("Item 1"));
dataList[0]->setProperty("name", QLatin1String("Changed"));