summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-02-02 04:01:04 (GMT)
committerMartin Jones <martin.jones@nokia.com>2011-02-02 04:01:04 (GMT)
commit13d59acef59952e07d98c2947c25da33418c2465 (patch)
tree7b50f12cafbdf720cbab27d149830867b2fb3e99 /tests
parent08fc37fbb09173bad771b36d2be14a2a359c140e (diff)
downloadQt-13d59acef59952e07d98c2947c25da33418c2465.zip
Qt-13d59acef59952e07d98c2947c25da33418c2465.tar.gz
Qt-13d59acef59952e07d98c2947c25da33418c2465.tar.bz2
Changing header or footer failed to delete the previous.
Also ensure that the view is repositioned if the change of header results in the view being out of bounds. Task-number: QTBUG-16522 Reviewed-by: Michael Brasser
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/footer.qml8
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/header.qml8
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp30
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/footer.qml8
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/header.qml9
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp30
6 files changed, 92 insertions, 1 deletions
diff --git a/tests/auto/declarative/qdeclarativegridview/data/footer.qml b/tests/auto/declarative/qdeclarativegridview/data/footer.qml
index ad69a25..b41e2ac 100644
--- a/tests/auto/declarative/qdeclarativegridview/data/footer.qml
+++ b/tests/auto/declarative/qdeclarativegridview/data/footer.qml
@@ -1,6 +1,9 @@
import QtQuick 1.0
Rectangle {
+ function changeFooter() {
+ grid.footer = footer2
+ }
width: 240
height: 320
color: "#ffffff"
@@ -29,4 +32,9 @@ Rectangle {
delegate: myDelegate
footer: Text { objectName: "footer"; text: "Footer"; height: 30 }
}
+
+ Component {
+ id: footer2
+ Text { objectName: "footer2"; text: "Footer 2"; height: 20 }
+ }
}
diff --git a/tests/auto/declarative/qdeclarativegridview/data/header.qml b/tests/auto/declarative/qdeclarativegridview/data/header.qml
index 99baacd..f39da55 100644
--- a/tests/auto/declarative/qdeclarativegridview/data/header.qml
+++ b/tests/auto/declarative/qdeclarativegridview/data/header.qml
@@ -1,6 +1,9 @@
import QtQuick 1.0
Rectangle {
+ function changeHeader() {
+ grid.header = header2
+ }
width: 240
height: 320
color: "#ffffff"
@@ -29,4 +32,9 @@ Rectangle {
delegate: myDelegate
header: Text { objectName: "header"; text: "Header"; height: 30 }
}
+
+ Component {
+ id: header2
+ Text { objectName: "header2"; text: "Header 2"; height: 20 }
+ }
}
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index a6a8b90..82a1a4a 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -1370,12 +1370,27 @@ void tst_QDeclarativeGridView::footer()
QVERIFY(footer);
QCOMPARE(footer->y(), 180.0);
+ QCOMPARE(footer->height(), 30.0);
model.removeItem(2);
QTRY_COMPARE(footer->y(), 120.0);
model.clear();
QTRY_COMPARE(footer->y(), 0.0);
+
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter");
+
+ footer = findItem<QDeclarativeText>(contentItem, "footer");
+ QVERIFY(!footer);
+ footer = findItem<QDeclarativeText>(contentItem, "footer2");
+ QVERIFY(footer);
+
+ QCOMPARE(footer->y(), 0.0);
+ QCOMPARE(footer->height(), 20.0);
+ QCOMPARE(gridview->contentY(), 0.0);
}
void tst_QDeclarativeGridView::header()
@@ -1402,6 +1417,7 @@ void tst_QDeclarativeGridView::header()
QVERIFY(header);
QCOMPARE(header->y(), 0.0);
+ QCOMPARE(header->height(), 30.0);
QCOMPARE(gridview->contentY(), 0.0);
QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 0);
@@ -1410,6 +1426,20 @@ void tst_QDeclarativeGridView::header()
model.clear();
QTRY_COMPARE(header->y(), 0.0);
+
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader");
+
+ header = findItem<QDeclarativeText>(contentItem, "header");
+ QVERIFY(!header);
+ header = findItem<QDeclarativeText>(contentItem, "header2");
+ QVERIFY(header);
+
+ QCOMPARE(header->y(), 0.0);
+ QCOMPARE(header->height(), 20.0);
+ QCOMPARE(gridview->contentY(), 0.0);
}
void tst_QDeclarativeGridView::indexAt()
diff --git a/tests/auto/declarative/qdeclarativelistview/data/footer.qml b/tests/auto/declarative/qdeclarativelistview/data/footer.qml
index 4cbd33b..33e04f1 100644
--- a/tests/auto/declarative/qdeclarativelistview/data/footer.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/footer.qml
@@ -1,6 +1,9 @@
import QtQuick 1.0
Rectangle {
+ function changeFooter() {
+ list.footer = footer2
+ }
width: 240
height: 320
color: "#ffffff"
@@ -27,4 +30,9 @@ Rectangle {
delegate: myDelegate
footer: Text { objectName: "footer"; text: "Footer"; height: 30 }
}
+
+ Component {
+ id: footer2
+ Text { objectName: "footer2"; text: "Footer 2"; height: 20 }
+ }
}
diff --git a/tests/auto/declarative/qdeclarativelistview/data/header.qml b/tests/auto/declarative/qdeclarativelistview/data/header.qml
index 6da996e..38cdd6e 100644
--- a/tests/auto/declarative/qdeclarativelistview/data/header.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/header.qml
@@ -1,6 +1,9 @@
import QtQuick 1.0
Rectangle {
+ function changeHeader() {
+ list.header = header2
+ }
width: 240
height: 320
color: "#ffffff"
@@ -26,6 +29,10 @@ Rectangle {
snapMode: ListView.SnapToItem
model: testModel
delegate: myDelegate
- header: Text { objectName: "header"; text: "Header"; height: 10 }
+ header: Text { objectName: "header"; text: "Header"; height: 20 }
+ }
+ Component {
+ id: header2
+ Text { objectName: "header2"; text: "Header 2"; height: 10 }
}
}
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index 4fff071..86b68ca 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -1736,12 +1736,27 @@ void tst_QDeclarativeListView::header()
QDeclarativeText *header = findItem<QDeclarativeText>(contentItem, "header");
QVERIFY(header);
QCOMPARE(header->y(), 0.0);
+ QCOMPARE(header->height(), 20.0);
QCOMPARE(listview->contentY(), 0.0);
model.clear();
QTRY_COMPARE(header->y(), 0.0);
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader");
+
+ header = findItem<QDeclarativeText>(contentItem, "header");
+ QVERIFY(!header);
+ header = findItem<QDeclarativeText>(contentItem, "header2");
+ QVERIFY(header);
+
+ QCOMPARE(header->y(), 0.0);
+ QCOMPARE(header->height(), 10.0);
+ QCOMPARE(listview->contentY(), 0.0);
+
delete canvas;
}
{
@@ -1796,6 +1811,7 @@ void tst_QDeclarativeListView::footer()
QDeclarativeText *footer = findItem<QDeclarativeText>(contentItem, "footer");
QVERIFY(footer);
QCOMPARE(footer->y(), 60.0);
+ QCOMPARE(footer->height(), 30.0);
model.removeItem(1);
QTRY_COMPARE(footer->y(), 40.0);
@@ -1803,6 +1819,20 @@ void tst_QDeclarativeListView::footer()
model.clear();
QTRY_COMPARE(footer->y(), 0.0);
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter");
+
+ footer = findItem<QDeclarativeText>(contentItem, "footer");
+ QVERIFY(!footer);
+ footer = findItem<QDeclarativeText>(contentItem, "footer2");
+ QVERIFY(footer);
+
+ QCOMPARE(footer->y(), 0.0);
+ QCOMPARE(footer->height(), 20.0);
+ QCOMPARE(listview->contentY(), 0.0);
+
delete canvas;
}