aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel d'Andrada <daniel.dandrada@luxoft.com>2017-11-16 10:17:33 +0100
committerDaniel d'Andrada <daniel.dandrada@luxoft.com>2018-02-28 15:58:03 +0100
commitd86ed09ed45d94bde1dd0cd509ff8842119683e9 (patch)
treecd3f78c03cf43126613200e6fccb12f7271c0e57 /tests
parent08f01bf873c72f1e2c8e4a98de0603f24630e856 (diff)
WidgetGrid: Proper animations when widgets are added or removed etc
To make that possible a major refactoring was needed. Had to ditch Column{} and go for a full custom implementation. Tried to use ListView but it didn't work well as widget additions and removals also affected sizes and positions of other items in the list and ListView wasn't designed for that. There's also the case that when there's a single item in the list it should be centered and have a certain size, and I would have to torture ListView quite a lot to get this implemented. Now WidgetListModel is an integral part of WidgetGrid and thus was moved inside it. The model and the qml code work hand in hand. Removed all header dependencies from WidgetListModel and put it into a plugin so that WidgetGrid could still be used in qml tests and be fed with a model fully written in qml. Also removed appman dependencies in ApplicationInfo.
Diffstat (limited to 'tests')
-rw-r--r--tests/qmltests/tst_WidgetGrid.qml34
1 files changed, 18 insertions, 16 deletions
diff --git a/tests/qmltests/tst_WidgetGrid.qml b/tests/qmltests/tst_WidgetGrid.qml
index becac7c5..076fb5c9 100644
--- a/tests/qmltests/tst_WidgetGrid.qml
+++ b/tests/qmltests/tst_WidgetGrid.qml
@@ -93,19 +93,21 @@ Item {
}
}
+ ListModel {
+ id: fakeApplicationModel
+ function application(index) {
+ return get(index).appInfo;
+ }
+ }
+
WidgetGrid {
id: widgetGrid
anchors.fill: parent
- widgetsList: ListModel {
- id: listModel
- function application(index) {
- return get(index).appInfo;
- }
- }
Component.onCompleted: {
- listModel.append({"appInfo":redApp})
- listModel.append({"appInfo":greenApp})
- listModel.append({"appInfo":blueApp})
+ fakeApplicationModel.append({"appInfo":redApp})
+ fakeApplicationModel.append({"appInfo":greenApp})
+ fakeApplicationModel.append({"appInfo":blueApp})
+ widgetGrid.applicationModel = fakeApplicationModel
}
}
@@ -118,10 +120,10 @@ Item {
*/
function test_resizePropagates() {
// check start conditions
- compare(listModel.count, 3);
- compare(listModel.get(0).appInfo.heightRows, 1);
- compare(listModel.get(1).appInfo.heightRows, 2);
- compare(listModel.get(2).appInfo.heightRows, 2);
+ compare(fakeApplicationModel.count, 3);
+ compare(fakeApplicationModel.get(0).appInfo.heightRows, 1);
+ compare(fakeApplicationModel.get(1).appInfo.heightRows, 2);
+ compare(fakeApplicationModel.get(2).appInfo.heightRows, 2);
// get the resize handle that's under the first (top) widget, redApp.
@@ -135,9 +137,9 @@ Item {
// Both the second and the third widget (top to bottom order) should have shrunk to make space for the
// enlarged top widget
- compare(listModel.get(0).appInfo.heightRows, 3);
- compare(listModel.get(1).appInfo.heightRows, 1);
- compare(listModel.get(2).appInfo.heightRows, 1);
+ compare(fakeApplicationModel.get(0).appInfo.heightRows, 3);
+ compare(fakeApplicationModel.get(1).appInfo.heightRows, 1);
+ compare(fakeApplicationModel.get(2).appInfo.heightRows, 1);
}