summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativepathview
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-02-25 00:21:52 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-02-25 00:21:52 (GMT)
commit950f3849e3bd2edd6bcc2784dbeadcb604c38e2d (patch)
treea8a55a3f9f4ddef85bab6d789a3ffb9e7e560a64 /tests/auto/declarative/qdeclarativepathview
parentf39bb2af2d81640d30222cd5abc31b076105dd8b (diff)
downloadQt-950f3849e3bd2edd6bcc2784dbeadcb604c38e2d.zip
Qt-950f3849e3bd2edd6bcc2784dbeadcb604c38e2d.tar.gz
Qt-950f3849e3bd2edd6bcc2784dbeadcb604c38e2d.tar.bz2
React to QAbstractItemModel::modelReset() signal.
Task-number: QTBUG-8494
Diffstat (limited to 'tests/auto/declarative/qdeclarativepathview')
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/displaypath.qml60
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp41
2 files changed, 101 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml b/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml
new file mode 100644
index 0000000..627f38a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml
@@ -0,0 +1,60 @@
+import Qt 4.6
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "#ffffff"
+ resources: [
+ Component {
+ id: delegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ height: 20
+ width: 60
+ color: "white"
+ border.color: "black"
+ Text {
+ text: index
+ }
+ Text {
+ x: 20
+ id: displayText
+ objectName: "displayText"
+ text: display
+ }
+ }
+ }
+ ]
+ PathView {
+ id: view
+ objectName: "view"
+ width: 240
+ height: 320
+ model: testModel
+ delegate: delegate
+ snapPosition: 0.01
+ path: Path {
+ startY: 120
+ startX: 160
+ PathQuad {
+ y: 120
+ x: 80
+ controlY: 330
+ controlX: 100
+ }
+ PathLine {
+ y: 160
+ x: 20
+ }
+ PathCubic {
+ y: 120
+ x: 160
+ control1Y: 0
+ control1X: 100
+ control2Y: 000
+ control2X: 200
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index 09f0f79..79bc607 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -49,6 +49,7 @@
#include <QtDeclarative/private/qdeclarativetext_p.h>
#include <QtDeclarative/private/qdeclarativerectangle_p.h>
#include <QAbstractListModel>
+#include <QStringListModel>
#include <QFile>
#include <private/qdeclarativevaluetype_p.h>
#include "../../../shared/util.h"
@@ -67,6 +68,7 @@ private slots:
void pathview3();
void path();
void pathMoved();
+ void resetModel();
private:
QDeclarativeView *createView();
@@ -425,6 +427,45 @@ void tst_QDeclarativePathView::pathMoved()
delete canvas;
}
+void tst_QDeclarativePathView::resetModel()
+{
+ QDeclarativeView *canvas = createView();
+
+ QStringList strings;
+ strings << "one" << "two" << "three";
+ QStringListModel model(strings);
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaypath.qml"));
+ qApp->processEvents();
+
+ QDeclarativePathView *pathview = findItem<QDeclarativePathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ QCOMPARE(pathview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(pathview, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+
+ strings.clear();
+ strings << "four" << "five" << "six" << "seven";
+ model.setStringList(strings);
+
+ QCOMPARE(pathview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(pathview, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+}
+
+
QDeclarativeView *tst_QDeclarativePathView::createView()
{
QDeclarativeView *canvas = new QDeclarativeView(0);