summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml2
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp9
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml16
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp61
5 files changed, 82 insertions, 7 deletions
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml b/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml
index 804559c..d41add3 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml
@@ -11,7 +11,7 @@ Rectangle {
width: 100
height: 100
Behavior on x {
- NumberAnimation {}
+ NumberAnimation { duration: 500 }
}
}
}
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 896d69e..d4d8bf6 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -655,6 +655,15 @@ void tst_QDeclarativeGridView::currentIndex()
gridview->setFlow(QDeclarativeGridView::TopToBottom);
+ qApp->setActiveWindow(canvas);
+#ifdef Q_WS_X11
+ // to be safe and avoid failing setFocus with window managers
+ qt_x11_wait_for_window_manager(canvas);
+#endif
+ QTRY_VERIFY(canvas->hasFocus());
+ QTRY_VERIFY(canvas->scene()->hasFocus());
+ qApp->processEvents();
+
QTest::keyClick(canvas, Qt::Key_Right);
QCOMPARE(gridview->currentIndex(), 5);
diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
index 6d5a357..d0afc8a 100644
--- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
+++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
@@ -389,6 +389,7 @@ void tst_qdeclarativeimageprovider::threadTest()
}
provider->ok = true;
provider->cond.wakeAll();
+ QTest::qWait(250);
foreach(QDeclarativeImage *img, images) {
TRY_WAIT(img->status() == QDeclarativeImage::Ready);
}
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml b/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml
index a798f77..c5e945a 100644
--- a/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml
@@ -4,12 +4,16 @@ ListView {
width: 100
height: 100
anchors.fill: parent
- model: myModel
- delegate: Component {
- Rectangle {
- height: 25
- width: 100
- Text { objectName: "display"; text: display }
+ model: VisualDataModel {
+ id: visualModel
+ objectName: "visualModel"
+ model: myModel
+ delegate: Component {
+ Rectangle {
+ height: 25
+ width: 100
+ Text { objectName: "display"; text: display }
+ }
}
}
}
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
index 3cd786f..95ef4fc 100644
--- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
@@ -84,6 +84,7 @@ public:
private slots:
void rootIndex();
void updateLayout();
+ void childChanged();
void objectListModel();
private:
@@ -174,22 +175,82 @@ void tst_qdeclarativevisualdatamodel::updateLayout()
QVERIFY(contentItem != 0);
QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 1 Item"));
name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 2 Item"));
name = findItem<QDeclarativeText>(contentItem, "display", 2);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 3 Item"));
model.invisibleRootItem()->sortChildren(0, Qt::DescendingOrder);
name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 3 Item"));
name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 2 Item"));
name = findItem<QDeclarativeText>(contentItem, "display", 2);
+ QVERIFY(name);
QCOMPARE(name->text(), QString("Row 1 Item"));
}
+void tst_qdeclarativevisualdatamodel::childChanged()
+{
+ QDeclarativeView view;
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+
+ view.rootContext()->setContextProperty("myModel", &model);
+
+ view.setSource(QUrl::fromLocalFile(SRCDIR "/data/datalist.qml"));
+
+ QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QDeclarativeVisualDataModel *vdm = listview->findChild<QDeclarativeVisualDataModel*>("visualModel");
+ vdm->setRootIndex(QVariant::fromValue(model.indexFromItem(model.item(1,0))));
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 Child Item"));
+
+ model.item(1,0)->child(0,0)->setText("Row 2 updated child");
+
+ name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 updated child"));
+
+ model.item(1,0)->appendRow(new QStandardItem(QLatin1String("Row 2 Child Item 2")));
+ QTest::qWait(300);
+
+ name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QString("Row 2 Child Item 2"));
+
+ model.item(1,0)->takeRow(1);
+ name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name == 0);
+
+ vdm->setRootIndex(QVariant::fromValue(QModelIndex()));
+ QTest::qWait(300);
+ name = findItem<QDeclarativeText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 1 Item"));
+ name = findItem<QDeclarativeText>(contentItem, "display", 1);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 Item"));
+ name = findItem<QDeclarativeText>(contentItem, "display", 2);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 3 Item"));
+}
+
void tst_qdeclarativevisualdatamodel::objectListModel()
{
QDeclarativeView view;