summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp14
-rw-r--r--tests/auto/declarative/layouts/data/grid-spacing.qml20
-rw-r--r--tests/auto/declarative/layouts/data/grid.qml20
-rw-r--r--tests/auto/declarative/layouts/data/horizontal-spacing.qml12
-rw-r--r--tests/auto/declarative/layouts/data/horizontal.qml12
-rw-r--r--tests/auto/declarative/layouts/data/vertical-spacing.qml12
-rw-r--r--tests/auto/declarative/layouts/data/vertical.qml12
-rw-r--r--tests/auto/declarative/layouts/tst_layouts.cpp76
-rw-r--r--tests/auto/declarative/listview/data/listview.qml4
-rw-r--r--tests/auto/declarative/listview/tst_listview.cpp28
10 files changed, 96 insertions, 114 deletions
diff --git a/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp b/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp
index 67cff02..556912e 100644
--- a/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp
+++ b/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp
@@ -2,6 +2,7 @@
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
#include <QtDeclarative/qmldatetimeformatter.h>
+#include <QDebug>
class tst_datetimeformatter : public QObject
{
@@ -18,8 +19,11 @@ private slots:
void tst_datetimeformatter::date()
{
QmlEngine engine;
- QmlComponent formatterComponent(&engine, "DateTimeFormatter { date: \"2008-12-24\" }");
+ QmlComponent formatterComponent(&engine, QByteArray("import Qt 4.6\n DateTimeFormatter { date: \"2008-12-24\" }"),
+ QUrl("file://"));
QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
QVERIFY(formatter != 0);
QDate date(2008,12,24);
@@ -38,8 +42,10 @@ void tst_datetimeformatter::date()
void tst_datetimeformatter::time()
{
QmlEngine engine;
- QmlComponent formatterComponent(&engine, "DateTimeFormatter { time: \"14:15:38.200\" }");
+ QmlComponent formatterComponent(&engine, "import Qt 4.6\n DateTimeFormatter { time: \"14:15:38.200\" }", QUrl("file://"));
QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
QVERIFY(formatter != 0);
QTime time(14,15,38,200);
@@ -64,8 +70,10 @@ void tst_datetimeformatter::time()
void tst_datetimeformatter::dateTime()
{
QmlEngine engine;
- QmlComponent formatterComponent(&engine, "DateTimeFormatter { dateTime: \"1978-03-04T09:13:54\" }");
+ QmlComponent formatterComponent(&engine, "import Qt 4.6\n DateTimeFormatter { dateTime: \"1978-03-04T09:13:54\" }", QUrl("file://"));
QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
QVERIFY(formatter != 0);
QDateTime dateTime(QDate(1978,03,04),QTime(9,13,54));
diff --git a/tests/auto/declarative/layouts/data/grid-spacing.qml b/tests/auto/declarative/layouts/data/grid-spacing.qml
index f9ae204..5b4a30d 100644
--- a/tests/auto/declarative/layouts/data/grid-spacing.qml
+++ b/tests/auto/declarative/layouts/data/grid-spacing.qml
@@ -6,32 +6,32 @@ Item {
Grid {
columns: 3
spacing: 4
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "green"
width: 20
height: 50
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "blue"
width: 50
height: 20
}
- Rect {
- id: four
+ Rectangle {
+ objectName: "four"
color: "cyan"
width: 50
height: 50
}
- Rect {
- id: five
+ Rectangle {
+ objectName: "five"
color: "magenta"
width: 10
height: 10
diff --git a/tests/auto/declarative/layouts/data/grid.qml b/tests/auto/declarative/layouts/data/grid.qml
index 3861f63..830df6a 100644
--- a/tests/auto/declarative/layouts/data/grid.qml
+++ b/tests/auto/declarative/layouts/data/grid.qml
@@ -5,32 +5,32 @@ Item {
height: 480
Grid {
columns: 3
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "green"
width: 20
height: 50
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "blue"
width: 50
height: 20
}
- Rect {
- id: four
+ Rectangle {
+ objectName: "four"
color: "cyan"
width: 50
height: 50
}
- Rect {
- id: five
+ Rectangle {
+ objectName: "five"
color: "magenta"
width: 10
height: 10
diff --git a/tests/auto/declarative/layouts/data/horizontal-spacing.qml b/tests/auto/declarative/layouts/data/horizontal-spacing.qml
index 8594ee6..32bf775 100644
--- a/tests/auto/declarative/layouts/data/horizontal-spacing.qml
+++ b/tests/auto/declarative/layouts/data/horizontal-spacing.qml
@@ -5,20 +5,20 @@ Item {
height: 480
Row {
spacing: 10
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "red"
width: 20
height: 10
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "red"
width: 40
height: 20
diff --git a/tests/auto/declarative/layouts/data/horizontal.qml b/tests/auto/declarative/layouts/data/horizontal.qml
index 673e77e..06ae151 100644
--- a/tests/auto/declarative/layouts/data/horizontal.qml
+++ b/tests/auto/declarative/layouts/data/horizontal.qml
@@ -4,20 +4,20 @@ Item {
width: 640
height: 480
Row {
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "red"
width: 20
height: 10
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "red"
width: 40
height: 20
diff --git a/tests/auto/declarative/layouts/data/vertical-spacing.qml b/tests/auto/declarative/layouts/data/vertical-spacing.qml
index 49bd8c6..69a8256 100644
--- a/tests/auto/declarative/layouts/data/vertical-spacing.qml
+++ b/tests/auto/declarative/layouts/data/vertical-spacing.qml
@@ -5,20 +5,20 @@ Item {
height: 480
Column {
spacing: 10
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "red"
width: 20
height: 10
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "red"
width: 40
height: 20
diff --git a/tests/auto/declarative/layouts/data/vertical.qml b/tests/auto/declarative/layouts/data/vertical.qml
index c8d3a11..856c180 100644
--- a/tests/auto/declarative/layouts/data/vertical.qml
+++ b/tests/auto/declarative/layouts/data/vertical.qml
@@ -4,20 +4,20 @@ Item {
width: 640
height: 480
Column {
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "red"
width: 20
height: 10
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "red"
width: 40
height: 20
diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp
index cd4678e..3416b2e 100644
--- a/tests/auto/declarative/layouts/tst_layouts.cpp
+++ b/tests/auto/declarative/layouts/tst_layouts.cpp
@@ -20,8 +20,6 @@ private slots:
private:
QFxView *createView(const QString &filename);
- template<typename T>
- T *findItem(QFxItem *parent, const QString &id, int index=-1);
};
tst_QFxLayouts::tst_QFxLayouts()
@@ -35,13 +33,13 @@ void tst_QFxLayouts::test_horizontal()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
QCOMPARE(one->x(), 0.0);
@@ -59,13 +57,13 @@ void tst_QFxLayouts::test_horizontal_spacing()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
QCOMPARE(one->x(), 0.0);
@@ -83,13 +81,13 @@ void tst_QFxLayouts::test_vertical()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
QCOMPARE(one->x(), 0.0);
@@ -107,13 +105,13 @@ void tst_QFxLayouts::test_vertical_spacing()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
QCOMPARE(one->x(), 0.0);
@@ -131,15 +129,15 @@ void tst_QFxLayouts::test_grid()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
- QFxRect *four = findItem<QFxRect>(canvas->root(), "four");
+ QFxRect *four = canvas->root()->findChild<QFxRect*>("four");
QVERIFY(four != 0);
- QFxRect *five = findItem<QFxRect>(canvas->root(), "five");
+ QFxRect *five = canvas->root()->findChild<QFxRect*>("five");
QVERIFY(five != 0);
QCOMPARE(one->x(), 0.0);
@@ -161,15 +159,15 @@ void tst_QFxLayouts::test_grid_spacing()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
- QFxRect *four = findItem<QFxRect>(canvas->root(), "four");
+ QFxRect *four = canvas->root()->findChild<QFxRect*>("four");
QVERIFY(four != 0);
- QFxRect *five = findItem<QFxRect>(canvas->root(), "five");
+ QFxRect *five = canvas->root()->findChild<QFxRect*>("five");
QVERIFY(five != 0);
QCOMPARE(one->x(), 0.0);
@@ -196,36 +194,6 @@ QFxView *tst_QFxLayouts::createView(const QString &filename)
return canvas;
}
-/*
- Find an item with the specified objectName. If index is supplied then the
- item must also evaluate the {index} expression equal to index
-*/
-template<typename T>
-T *tst_QFxLayouts::findItem(QFxItem *parent, const QString &objectName, int index)
-{
- const QMetaObject &mo = T::staticMetaObject;
- for (int i = 0; i < parent->QGraphicsObject::children().count(); ++i) {
- QFxItem *item = qobject_cast<QFxItem*>(parent->QGraphicsObject::children().at(i));
- if(!item)
- continue;
- //qDebug() << item << item->objectName();
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- if (index != -1) {
- QmlExpression e(qmlContext(item), "index", item);
- e.setTrackChange(false);
- if (e.value().toInt() == index)
- return static_cast<T*>(item);
- } else {
- return static_cast<T*>(item);
- }
- }
- item = findItem<T>(item, objectName, index);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
QTEST_MAIN(tst_QFxLayouts)
diff --git a/tests/auto/declarative/listview/data/listview.qml b/tests/auto/declarative/listview/data/listview.qml
index 7a3d76f..1a241eb 100644
--- a/tests/auto/declarative/listview/data/listview.qml
+++ b/tests/auto/declarative/listview/data/listview.qml
@@ -9,6 +9,7 @@ Rectangle {
id: Delegate
Item {
id: wrapper
+ objectName: "wrapper"
height: 20
width: 240
Text {
@@ -17,11 +18,13 @@ Rectangle {
Text {
x: 30
id: textName
+ objectName: "textName"
text: name
}
Text {
x: 120
id: textNumber
+ objectName: "textNumber"
text: number
}
Text {
@@ -33,6 +36,7 @@ Rectangle {
]
ListView {
id: list
+ objectName: "list"
width: 240
height: 320
model: testModel
diff --git a/tests/auto/declarative/listview/tst_listview.cpp b/tests/auto/declarative/listview/tst_listview.cpp
index 8bf9c8a..ebc3053 100644
--- a/tests/auto/declarative/listview/tst_listview.cpp
+++ b/tests/auto/declarative/listview/tst_listview.cpp
@@ -188,7 +188,7 @@ void tst_QFxListView::items()
QFxItem *viewport = listview->viewport();
QVERIFY(viewport != 0);
- QCOMPARE(viewport->children()->count(), model.count()); // assumes all are visible
+ QCOMPARE(viewport->childItems().count(), model.count()); // assumes all are visible
for (int i = 0; i < model.count(); ++i) {
QFxText *name = findItem<QFxText>(viewport, "textName", i);
@@ -262,7 +262,7 @@ void tst_QFxListView::inserted()
// let transitions settle.
QTest::qWait(1000);
- QCOMPARE(viewport->children()->count(), model.count()); // assumes all are visible
+ QCOMPARE(viewport->childItems().count(), model.count()); // assumes all are visible
QFxText *name = findItem<QFxText>(viewport, "textName", 1);
QVERIFY(name != 0);
@@ -282,7 +282,7 @@ void tst_QFxListView::inserted()
// let transitions settle.
QTest::qWait(1000);
- QCOMPARE(viewport->children()->count(), model.count()); // assumes all are visible
+ QCOMPARE(viewport->childItems().count(), model.count()); // assumes all are visible
name = findItem<QFxText>(viewport, "textName", 0);
QVERIFY(name != 0);
@@ -336,7 +336,7 @@ void tst_QFxListView::removed()
QCOMPARE(number->text(), model.number(1));
// Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < viewport->children()->count(); ++i) {
+ for (int i = 0; i < model.count() && i < viewport->childItems().count(); ++i) {
QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
QVERIFY(item->y() == i*20);
}
@@ -355,7 +355,7 @@ void tst_QFxListView::removed()
QCOMPARE(number->text(), model.number(0));
// Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < viewport->children()->count(); ++i) {
+ for (int i = 0; i < model.count() && i < viewport->childItems().count(); ++i) {
QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
QCOMPARE(item->y(),i*20.0 + 20.0);
}
@@ -366,13 +366,13 @@ void tst_QFxListView::removed()
QTest::qWait(1000);
// Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < viewport->children()->count(); ++i) {
+ for (int i = 0; i < model.count() && i < viewport->childItems().count(); ++i) {
QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
QCOMPARE(item->y(),i*20.0+20.0);
}
// Remove items before visible
- listview->setYPosition(80);
+ listview->setViewportY(80);
listview->setCurrentIndex(10);
model.removeItem(1); // post: top item will be at 40
@@ -385,12 +385,12 @@ void tst_QFxListView::removed()
QCOMPARE(item->y(),40+i*20.0);
}
- listview->setYPosition(40); // That's the top now
+ listview->setViewportY(40); // That's the top now
// let transitions settle.
QTest::qWait(1000);
// Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < viewport->children()->count(); ++i) {
+ for (int i = 0; i < model.count() && i < viewport->childItems().count(); ++i) {
QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
QCOMPARE(item->y(),40+i*20.0);
}
@@ -459,10 +459,12 @@ template<typename T>
T *tst_QFxListView::findItem(QFxItem *parent, const QString &objectName, int index)
{
const QMetaObject &mo = T::staticMetaObject;
- qDebug() << parent->children()->count() << "children";
- for (int i = 0; i < parent->children()->count(); ++i) {
- QFxItem *item = parent->children()->at(i);
- qDebug() << "try" << item;
+ //qDebug() << parent->QGraphicsObject::children().count() << "children";
+ for (int i = 0; i < parent->QGraphicsObject::children().count(); ++i) {
+ QFxItem *item = qobject_cast<QFxItem*>(parent->QGraphicsObject::children().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
if (index != -1) {
QmlExpression e(qmlContext(item), "index", item);