summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-12-10 22:50:28 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-12-10 22:50:28 (GMT)
commit98115cf6f3d2a60c7eecc7ddfe6a491f98a60866 (patch)
treebf3aeefa0996c44949cd3a79b68e6ed55e6a6cb0 /tests
parenteabde99a0e9e4c5e49a05187530cf643258d5719 (diff)
parent8738c328012484062fa927c26cc3a70dbd432cc8 (diff)
downloadQt-98115cf6f3d2a60c7eecc7ddfe6a491f98a60866.zip
Qt-98115cf6f3d2a60c7eecc7ddfe6a491f98a60866.tar.gz
Qt-98115cf6f3d2a60c7eecc7ddfe6a491f98a60866.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: QmlViewer: Remove trailing whitespace QmlViewer: Remove trailing whitespace QmlViewer: Fix crash on exit PathView: removing the currentIndex could make it invalid. Fix broken database creation caused by previous fix Improvements to anchoring docs QDeclarativeProperty doc improvements Update QtGui bwins def file for QTBUG-15615 highlightFollowsCurrentItem: false was not always honored ListView: Fix calculation of currentItem position when out of view. Update QtGui def files Fix openDatabaseSync() to not create unused directory Document support for QVariantList and QVariantMap type conversion Some doc clarification for components and javascript integration Cursor shouldn't blink while dragging cursor position Qt.include() docs weren't being picked up by qdoc Doc: make it clear that "z" affects sibling stacking order.
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/manual-highlight.qml4
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp15
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/displaylist.qml9
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/manual-highlight.qml2
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp97
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp4
6 files changed, 121 insertions, 10 deletions
diff --git a/tests/auto/declarative/qdeclarativegridview/data/manual-highlight.qml b/tests/auto/declarative/qdeclarativegridview/data/manual-highlight.qml
index 7bb2c95..d082847 100644
--- a/tests/auto/declarative/qdeclarativegridview/data/manual-highlight.qml
+++ b/tests/auto/declarative/qdeclarativegridview/data/manual-highlight.qml
@@ -28,8 +28,8 @@ Item {
objectName: "highlight"
width: 80; height: 80
color: "lightsteelblue"; radius: 5
- y: grid.currentItem.y
- x: grid.currentItem.x
+ y: grid.currentItem.y+5
+ x: grid.currentItem.x+5
}
}
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 7998e30..fd5d140 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -1215,15 +1215,22 @@ void tst_QDeclarativeGridView::manualHighlight()
QTRY_COMPARE(gridview->currentIndex(), 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());
+ QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
+ QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
gridview->setCurrentIndex(2);
QTRY_COMPARE(gridview->currentIndex(), 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());
+ QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
+ QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
+
+ gridview->positionViewAtIndex(8, QDeclarativeGridView::Contain);
+
+ QTRY_COMPARE(gridview->currentIndex(), 2);
+ QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 2));
+ QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
+ QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
}
void tst_QDeclarativeGridView::footer()
diff --git a/tests/auto/declarative/qdeclarativelistview/data/displaylist.qml b/tests/auto/declarative/qdeclarativelistview/data/displaylist.qml
index 487b70e..9d58530 100644
--- a/tests/auto/declarative/qdeclarativelistview/data/displaylist.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/displaylist.qml
@@ -1,6 +1,8 @@
import QtQuick 1.0
Rectangle {
+ id: root
+ property real delegateHeight: 20
width: 240
height: 320
color: "#ffffff"
@@ -10,7 +12,8 @@ Rectangle {
Rectangle {
id: wrapper
objectName: "wrapper"
- height: 20
+ height: root.delegateHeight
+ Behavior on height { NumberAnimation {} }
width: 240
Text {
text: index
@@ -20,6 +23,10 @@ Rectangle {
objectName: "displayText"
text: display
}
+ Text {
+ x: 200
+ text: wrapper.y
+ }
color: ListView.isCurrentItem ? "lightsteelblue" : "white"
}
},
diff --git a/tests/auto/declarative/qdeclarativelistview/data/manual-highlight.qml b/tests/auto/declarative/qdeclarativelistview/data/manual-highlight.qml
index d8cfd9a..a32a194 100644
--- a/tests/auto/declarative/qdeclarativelistview/data/manual-highlight.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/manual-highlight.qml
@@ -28,7 +28,7 @@ Item {
objectName: "highlight"
width: 180; height: 20
color: "lightsteelblue"; radius: 5
- y: list.currentItem.y
+ y: list.currentItem.y+5
}
}
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index 759caf2..ff90d32 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -103,6 +103,7 @@ private slots:
void resizeView();
void sizeLessThan1();
void QTBUG_14821();
+ void resizeDelegate();
private:
template <class T> void items();
@@ -1406,6 +1407,8 @@ void tst_QDeclarativeListView::resetModel()
QTRY_VERIFY(display != 0);
QTRY_COMPARE(display->text(), strings.at(i));
}
+
+ delete canvas;
}
void tst_QDeclarativeListView::propertyChanges()
@@ -1606,13 +1609,22 @@ void tst_QDeclarativeListView::manualHighlight()
QTRY_COMPARE(listview->currentIndex(), 0);
QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 0));
- QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
+ QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
listview->setCurrentIndex(2);
QTRY_COMPARE(listview->currentIndex(), 2);
QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 2));
- QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
+ QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
+
+ // QTBUG-15972
+ listview->positionViewAtIndex(3, QDeclarativeListView::Contain);
+
+ QTRY_COMPARE(listview->currentIndex(), 2);
+ QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 2));
+ QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
+
+ delete canvas;
}
void tst_QDeclarativeListView::QTBUG_11105()
@@ -1752,6 +1764,8 @@ void tst_QDeclarativeListView::footer()
model.clear();
QTRY_COMPARE(footer->y(), 0.0);
+
+ delete canvas;
}
void tst_QDeclarativeListView::resizeView()
@@ -1794,6 +1808,8 @@ void tst_QDeclarativeListView::resizeView()
QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
QCOMPARE(heightRatio.toReal(), 0.25);
+
+ delete canvas;
}
void tst_QDeclarativeListView::sizeLessThan1()
@@ -1849,6 +1865,83 @@ void tst_QDeclarativeListView::QTBUG_14821()
listview->incrementCurrentIndex();
QCOMPARE(listview->currentIndex(), 0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::resizeDelegate()
+{
+ QDeclarativeView *canvas = createView();
+
+ QStringList strings;
+ for (int i = 0; i < 30; ++i)
+ strings << QString::number(i);
+ QStringListModel model(strings);
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaylist.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(listview->count(), model.rowCount());
+
+ listview->setCurrentIndex(25);
+ listview->setContentY(0);
+
+ for (int i = 0; i < 16; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ QVERIFY(item != 0);
+ QCOMPARE(item->y(), i*20.0);
+ }
+
+ QCOMPARE(listview->currentItem()->y(), 500.0);
+ QTRY_COMPARE(listview->highlightItem()->y(), 500.0);
+
+ canvas->rootObject()->setProperty("delegateHeight", 30);
+ qApp->processEvents();
+
+ for (int i = 0; i < 11; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ QVERIFY(item != 0);
+ QTRY_COMPARE(item->y(), i*30.0);
+ }
+
+ QTRY_COMPARE(listview->currentItem()->y(), 750.0);
+ QTRY_COMPARE(listview->highlightItem()->y(), 750.0);
+
+ listview->setCurrentIndex(1);
+ listview->positionViewAtIndex(25, QDeclarativeListView::Beginning);
+ listview->positionViewAtIndex(5, QDeclarativeListView::Beginning);
+
+ for (int i = 5; i < 16; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ QVERIFY(item != 0);
+ QCOMPARE(item->y(), i*30.0);
+ }
+
+ QTRY_COMPARE(listview->currentItem()->y(), 30.0);
+ QTRY_COMPARE(listview->highlightItem()->y(), 30.0);
+
+ canvas->rootObject()->setProperty("delegateHeight", 20);
+ qApp->processEvents();
+
+ for (int i = 5; i < 11; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
+ QVERIFY(item != 0);
+ QTRY_COMPARE(item->y(), 150 + (i-5)*20.0);
+ }
+
+ QTRY_COMPARE(listview->currentItem()->y(), 70.0);
+ QTRY_COMPARE(listview->highlightItem()->y(), 70.0);
+
+ delete canvas;
}
void tst_QDeclarativeListView::qListModelInterface_items()
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index a2a5363..9193707 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -429,6 +429,10 @@ void tst_QDeclarativePathView::dataModel()
pathview->setOffset(0);
QCOMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 5);
+ pathview->setCurrentIndex(model.count()-1);
+ model.removeItem(model.count()-1);
+ QCOMPARE(pathview->currentIndex(), model.count()-1);
+
delete canvas;
}