diff options
Diffstat (limited to 'tests/auto')
52 files changed, 710 insertions, 306 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/qtbug_11600.js b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.js new file mode 100644 index 0000000..092bc2b --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.js @@ -0,0 +1 @@ +; diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml new file mode 100644 index 0000000..56e7885 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml @@ -0,0 +1,8 @@ +import Qt 4.7 +import "qtbug_11600.js" as Test + +QtObject { + id: goo + + property bool test: undefined == goo.Test.foo +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml new file mode 100644 index 0000000..6efb9c1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml @@ -0,0 +1,12 @@ +import Qt 4.7 + +QtObject { + property bool test: false + Component.onCompleted: { + try { + console.log(sorryNoSuchProperty); + } catch (e) { + test = true; + } + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml index 4395ba3..2548005 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml @@ -1,10 +1,10 @@ import Qt 4.7 +import Qt.test 1.0 -Item { +MyQmlObject { id: root property int foo: 12 - property int console: 11 property bool test1: foo == 12 property bool test2: console != 11 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/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index 7bb8a8e..849879e 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -86,6 +86,7 @@ class MyQmlObject : public QObject Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT) Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT) Q_PROPERTY(int value READ value WRITE setValue) + Q_PROPERTY(int console READ console CONSTANT) Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged) Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged) Q_PROPERTY(QDeclarativeListProperty<QObject> objectListProperty READ objectListProperty CONSTANT) @@ -142,6 +143,7 @@ public: QRegExp regExp() { return m_regExp; } void setRegExp(const QRegExp ®Exp) { m_regExp = regExp; } + int console() const { return 11; } signals: void basicSignal(); void argumentSignal(int a, QString b, qreal c); @@ -555,7 +557,9 @@ Q_DECLARE_METATYPE(QScriptValue); class MyInvokableObject : public QObject { Q_OBJECT + Q_ENUMS(TestEnum) public: + enum TestEnum { EnumValue1, EnumValue2 }; MyInvokableObject() { reset(); } int invoked() const { return m_invoked; } @@ -587,6 +591,8 @@ public: Q_INVOKABLE void method_overload(int a) { invoke(16); m_actuals << a; } Q_INVOKABLE void method_overload(int a, int b) { invoke(17); m_actuals << a << b; } + Q_INVOKABLE void method_with_enum(TestEnum e) { invoke(18); m_actuals << (int)e; } + private: void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;} int m_invoked; diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 16e7ec5..43900ae 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -155,6 +155,8 @@ private slots: void eval(); void function(); void qtbug_10696(); + void qtbug_11606(); + void qtbug_11600(); void include(); @@ -1002,10 +1004,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 +1324,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(); @@ -1714,6 +1721,13 @@ void tst_qdeclarativeecmascript::callQtInvokables() QCOMPARE(o.actuals().count(), 2); QCOMPARE(o.actuals().at(0), QVariant(10)); QCOMPARE(o.actuals().at(1), QVariant(11)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_with_enum(9)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 18); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(9)); } // QTBUG-5675 @@ -2498,6 +2512,25 @@ void tst_qdeclarativeecmascript::qtbug_10696() delete o; } +void tst_qdeclarativeecmascript::qtbug_11606() +{ + QDeclarativeComponent component(&engine, TEST_FILE("qtbug_11606.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test").toBool(), true); + delete o; +} + +void tst_qdeclarativeecmascript::qtbug_11600() +{ + QDeclarativeComponent component(&engine, TEST_FILE("qtbug_11600.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test").toBool(), true); + delete o; +} + + QTEST_MAIN(tst_qdeclarativeecmascript) #include "tst_qdeclarativeecmascript.moc" 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/qdeclarativelanguage/data/invalidProperty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.errors.txt new file mode 100644 index 0000000..c83e5ae --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.errors.txt @@ -0,0 +1 @@ +4:5:Illegal property name diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml new file mode 100644 index 0000000..6077de4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml @@ -0,0 +1,5 @@ +import Qt 4.7 + +QtObject { + property int parseInt +} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 413843a..3ce356e 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -370,6 +370,7 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("destroyedSignal") << "destroyedSignal.qml" << "destroyedSignal.errors.txt" << false; QTest::newRow("assignToNamespace") << "assignToNamespace.qml" << "assignToNamespace.errors.txt" << false; QTest::newRow("invalidOn") << "invalidOn.qml" << "invalidOn.errors.txt" << false; + QTest::newRow("invalidProperty") << "invalidProperty.qml" << "invalidProperty.errors.txt" << false; } diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index 3d66733..f15ac8f 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -559,6 +559,18 @@ void tst_qdeclarativelistmodel::error_data() QTest::newRow("QML elements not allowed in ListElement") << "import Qt 4.7\nListModel { ListElement { a: Item { } } }" << "ListElement: cannot contain nested elements"; + + QTest::newRow("qualified ListElement supported") + << "import Qt 4.7 as Foo\nFoo.ListModel { Foo.ListElement { a: 123 } }" + << ""; + + QTest::newRow("qualified ListElement required") + << "import Qt 4.7 as Foo\nFoo.ListModel { ListElement { a: 123 } }" + << "ListElement is not a type"; + + QTest::newRow("unknown qualified ListElement not allowed") + << "import Qt 4.7\nListModel { Foo.ListElement { a: 123 } }" + << "Foo.ListElement - Foo is not a namespace"; } void tst_qdeclarativelistmodel::error() 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/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index d047a2a..b0b7a3b 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -47,6 +47,7 @@ #include <QtDeclarative/qdeclarativecomponent.h> #include <private/qdeclarativeloader_p.h> #include "testhttpserver.h" +#include "../../../shared/util.h" #define SERVER_PORT 14450 @@ -176,9 +177,7 @@ void tst_QDeclarativeLoader::clear() QCOMPARE(loader->progress(), 1.0); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); - QTest::qWait(500); - - QVERIFY(loader->item() == 0); + QTRY_VERIFY(loader->item() == 0); QCOMPARE(loader->progress(), 0.0); QCOMPARE(loader->status(), QDeclarativeLoader::Null); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0); @@ -239,8 +238,8 @@ void tst_QDeclarativeLoader::urlToComponent() "}" ) , TEST_FILE("")); QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create()); - QTest::qWait(500); - QVERIFY(loader != 0); + QTest::qWait(200); + QTRY_VERIFY(loader != 0); QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); diff --git a/tests/auto/declarative/qdeclarativepositioners/data/flow-testimplicitsize.qml b/tests/auto/declarative/qdeclarativepositioners/data/flow-testimplicitsize.qml new file mode 100644 index 0000000..6dd108e --- /dev/null +++ b/tests/auto/declarative/qdeclarativepositioners/data/flow-testimplicitsize.qml @@ -0,0 +1,16 @@ +import Qt 4.7 + +Rectangle { + width: 300; height: 200; + + property bool leftToRight: false + + Flow { + objectName: "flow" + flow: leftToRight ? Flow.LeftToRight : Flow.TopToBottom + spacing: 20 + anchors.horizontalCenter: parent.horizontalCenter + Rectangle { color: "red"; width: 100; height: 50 } + Rectangle { color: "blue"; width: 100; height: 50 } + } +}
\ No newline at end of file diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index 62ec707..0663991 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -75,6 +75,7 @@ private slots: void test_repeater(); void test_flow(); void test_flow_resize(); + void test_flow_implicit_resize(); void test_conflictinganchors(); private: QDeclarativeView *createView(const QString &filename); @@ -655,6 +656,28 @@ void tst_QDeclarativePositioners::test_flow_resize() delete canvas; } +void tst_QDeclarativePositioners::test_flow_implicit_resize() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/flow-testimplicitsize.qml"); + QVERIFY(canvas->rootObject() != 0); + + QDeclarativeFlow *flow = canvas->rootObject()->findChild<QDeclarativeFlow*>("flow"); + QVERIFY(flow != 0); + + QCOMPARE(flow->width(), 100.0); + QCOMPARE(flow->height(), 120.0); + + canvas->rootObject()->setProperty("leftToRight", true); + QCOMPARE(flow->width(), 220.0); + QCOMPARE(flow->height(), 50.0); + + canvas->rootObject()->setProperty("leftToRight", false); + QCOMPARE(flow->width(), 100.0); + QCOMPARE(flow->height(), 120.0); + + delete canvas; +} + QString warningMessage; void interceptWarnings(QtMsgType type, const char *msg) diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js index c165e29..30499e9 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js +++ b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js @@ -5,3 +5,7 @@ function loadComponent() { return component.status; } +function createComponent() { + var component = Qt.createComponent("createComponentData.qml"); + return component.createObject(null); +} diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml index aae7a91..33203c7 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml @@ -3,8 +3,10 @@ import "createComponent_lib.js" as Test Item { property int status: Component.Null + property int readValue: 0 Component.onCompleted: { status = Test.loadComponent() + readValue = Test.createComponent().test; } } diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index fb100a5..895ee6c 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -365,14 +365,12 @@ void tst_qdeclarativeqt::createComponent() void tst_qdeclarativeqt::createComponent_pragmaLibrary() { // Currently, just loading createComponent_lib.qml causes crash on some platforms - /* QDeclarativeComponent component(&engine, TEST_FILE("createComponent_lib.qml")); QObject *object = component.create(); QVERIFY(object != 0); - - QEXPECT_FAIL("", "QTBUG-11507", Continue); QCOMPARE(object->property("status").toInt(), int(QDeclarativeComponent::Ready)); - */ + QCOMPARE(object->property("readValue").toInt(), int(1913)); + delete object; } void tst_qdeclarativeqt::createQmlObject() diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index 2913ddd..639b2f3 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -263,7 +263,6 @@ void tst_qdeclarativestates::attachedPropertyChanges() MyAttached *att = qobject_cast<MyAttached*>(attObj); QVERIFY(att); - QEXPECT_FAIL("", "QTBUG-11283", Abort); QCOMPARE(att->foo(), 1); } diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments.qml b/tests/auto/declarative/qdeclarativetext/data/alignments.qml new file mode 100644 index 0000000..b1f701b --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments.qml @@ -0,0 +1,41 @@ +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 + 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 Binary files differnew file mode 100644 index 0000000..99de219 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png Binary files differnew file mode 100644 index 0000000..cb85251 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png b/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png Binary files differnew file mode 100644 index 0000000..ddca549 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lb.png b/tests/auto/declarative/qdeclarativetext/data/alignments_lb.png Binary files differnew file mode 100644 index 0000000..1b50a81 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_lb.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_lc.png Binary files differnew file mode 100644 index 0000000..f041b86 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_lc.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lt.png b/tests/auto/declarative/qdeclarativetext/data/alignments_lt.png Binary files differnew file mode 100644 index 0000000..c75e0d1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_lt.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rb.png b/tests/auto/declarative/qdeclarativetext/data/alignments_rb.png Binary files differnew file mode 100644 index 0000000..b06a5da --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_rb.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_rc.png Binary files differnew file mode 100644 index 0000000..e468857 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_rc.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rt.png b/tests/auto/declarative/qdeclarativetext/data/alignments_rt.png Binary files differnew file mode 100644 index 0000000..576715f --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/alignments_rt.png diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index 01120b1..8a4f152 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,65 @@ 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); + +#ifdef Q_WS_X11 + // Font-specific, but not likely platform-specific, so only test on one platform + QFont fn; + fn.setRawName("-misc-fixed-medium-r-*-*-8-*-*-*-*-*-*-*"); + QApplication::setFont(fn); +#endif + + 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_WS_X11 + // 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..b1f701b --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml @@ -0,0 +1,41 @@ +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 + 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 Binary files differnew file mode 100644 index 0000000..99de219 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.png Binary files differnew file mode 100644 index 0000000..cb85251 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.png Binary files differnew file mode 100644 index 0000000..ddca549 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.png Binary files differnew file mode 100644 index 0000000..1b50a81 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.png Binary files differnew file mode 100644 index 0000000..f041b86 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.png Binary files differnew file mode 100644 index 0000000..c75e0d1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.png Binary files differnew file mode 100644 index 0000000..b06a5da --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.png Binary files differnew file mode 100644 index 0000000..e468857 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.png Binary files differnew file mode 100644 index 0000000..576715f --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.png diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index f7ba7a1..f1a367f 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,65 @@ 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); + +#ifdef Q_WS_X11 + // Font-specific, but not likely platform-specific, so only test on one platform + QFont fn; + fn.setRawName("-misc-fixed-medium-r-*-*-8-*-*-*-*-*-*-*"); + QApplication::setFont(fn); +#endif + + 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_WS_X11 + // 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..9660430 100644 --- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -43,6 +43,7 @@ #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativeview.h> #include <QtDeclarative/qdeclarativeitem.h> +#include <QtGui/qmenubar.h> #include "../../../shared/util.h" #include "qmlruntime.h" #include "../../../shared/util.h" @@ -52,6 +53,12 @@ #define SRCDIR "." #endif +#if defined(Q_OS_MAC) || defined(Q_WS_MAEMO_5) || defined(Q_WS_S60) +# define MENUBAR_HEIGHT(mw) 0 +#else +# define MENUBAR_HEIGHT(mw) (mw->menuBar()->height()) +#endif + class tst_QDeclarativeViewer : public QObject { @@ -75,47 +82,55 @@ tst_QDeclarativeViewer::tst_QDeclarativeViewer() { } +#define TEST_INITIAL_SIZES(viewer) { \ + QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject()); \ + QVERIFY(rootItem); \ +\ + QCOMPARE(rootItem->width(), 200.0); \ + QCOMPARE(rootItem->height(), 300.0); \ + QTRY_COMPARE(viewer->view()->size(), QSize(200, 300)); \ + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); \ + QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); \ + QCOMPARE(viewer->size(), viewer->sizeHint()); \ +} + void tst_QDeclarativeViewer::orientation() { - QWidget window; - QDeclarativeViewer *viewer = new QDeclarativeViewer(&window); + QDeclarativeViewer *viewer = new QDeclarativeViewer(); QVERIFY(viewer); viewer->open(SRCDIR "/data/orientation.qml"); QVERIFY(viewer->view()); QVERIFY(viewer->menuBar()); QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject()); QVERIFY(rootItem); - window.show(); + viewer->show(); - QApplication::setActiveWindow(&window); - QTest::qWaitForWindowShown(&window); - QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&window)); + QApplication::setActiveWindow(viewer); + QTest::qWaitForWindowShown(viewer); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(viewer)); - QCOMPARE(rootItem->width(), 200.0); - QCOMPARE(rootItem->height(), 300.0); - QTRY_COMPARE(viewer->view()->size(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); - QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); - QCOMPARE(viewer->size(), viewer->sizeHint()); + TEST_INITIAL_SIZES(viewer); viewer->rotateOrientation(); qApp->processEvents(); + qApp->processEvents(); // one extra round for the delayed updateSizeHints() call QCOMPARE(rootItem->width(), 300.0); QCOMPARE(rootItem->height(), 200.0); QTRY_COMPARE(viewer->view()->size(), QSize(300, 200)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(300, 200)); - QCOMPARE(viewer->size(), QSize(300, 200+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), QSize(300, 200 + MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->size(), viewer->sizeHint()); viewer->rotateOrientation(); qApp->processEvents(); + qApp->processEvents(); // one extra round for the delayed updateSizeHints() call QCOMPARE(rootItem->width(), 200.0); QCOMPARE(rootItem->height(), 300.0); QTRY_COMPARE(viewer->view()->size(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); - QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->size(), viewer->sizeHint()); } @@ -135,13 +150,7 @@ void tst_QDeclarativeViewer::loading() QTest::qWaitForWindowShown(viewer); QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(viewer)); - // initial size - QTRY_COMPARE(rootItem->width(), 200.0); - QTRY_COMPARE(rootItem->height(), 300.0); - QCOMPARE(viewer->view()->size(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); - QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); - QCOMPARE(viewer->size(), viewer->sizeHint()); + TEST_INITIAL_SIZES(viewer); viewer->resize(QSize(400, 500)); qApp->processEvents(); @@ -243,14 +252,7 @@ void tst_QDeclarativeViewer::resizing() QTest::qWaitForWindowShown(viewer); QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(viewer)); - // initial size - QCOMPARE(rootItem->width(), 200.0); - QCOMPARE(rootItem->height(), 300.0); - QCOMPARE(viewer->view()->size(), QSize(200, 300)); - QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); - QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); - QCOMPARE(viewer->size(), viewer->sizeHint()); + TEST_INITIAL_SIZES(viewer); viewer->setSizeToView(false); @@ -261,7 +263,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 +281,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")); |