@@ -20,6 +20,7 @@ import "../../../qml/Components"
20import Ubuntu.Components.ListItems 0.1 as ListItem
20import Ubuntu.Components.ListItems 0.1 as ListItem
21import Ubuntu.Components 0.1
21import Ubuntu.Components 0.1
22import Unity.Test 0.1 as UT
22import Unity.Test 0.1 as UT
25 You should see 6 green squares (from "A" to "F") and a button "View all (12)".
26 You should see 6 green squares (from "A" to "F") and a button "View all (12)".
@@ -69,6 +70,20 @@ Rectangle {
69 ListElement { name: "L" }
70 ListElement { name: "L" }
74+ id: fakeModelTwoItems
75+ ListElement { name: "A" }
76+ ListElement { name: "B" }
80+ id: fakeModelFourItems
81+ ListElement { name: "A" }
82+ ListElement { name: "B" }
83+ ListElement { name: "C" }
84+ ListElement { name: "D" }
72 Rectangle {
87 Rectangle {
73 id: gridRect
88 id: gridRect
74 width: units.gu(30)
89 width: units.gu(30)
@@ -109,15 +124,21 @@ Rectangle {
109 name: "FilterGrid"
124 name: "FilterGrid"
110 when: windowShown
125 when: windowShown
128+ filterGrid.model = fakeModel
131+ function cleanup() {
132+ filterCheckBox.checked = true
133+ collapsedRowCountSelector.selectedIndex = 1
112 function test_turningFilterOffShowsAllElements() {
136 function test_turningFilterOffShowsAllElements() {
113 tryCompareFunction(countVisibleDelegates, 6)
137 tryCompareFunction(countVisibleDelegates, 6)
115 filterCheckBox.checked = false
139 filterCheckBox.checked = false
117 tryCompareFunction(countVisibleDelegates, 12)
141 tryCompareFunction(countVisibleDelegates, 12)
119− // back to initial state
120− filterCheckBox.checked = true
123 function test_collapsedRowCount() {
144 function test_collapsedRowCount() {
@@ -127,9 +148,27 @@ Rectangle {
127 // row count == index + 1
148 // row count == index + 1
128 tryCompareFunction(countVisibleDelegates, 3*(i+1))
149 tryCompareFunction(countVisibleDelegates, 3*(i+1))
131− // back to initial state
153+ function test_modelSizeAffectsCollapsedRowCount_data() {
155+ { tag: "2 items, collapsedRows 1", model: fakeModelTwoItems, collapsedRowCountIndex: 0,
156+ rowsWhenCollapsed: 1, visibleDelegates: 2 },
157+ { tag: "2 items, collapsedRows 2", model: fakeModelTwoItems, collapsedRowCountIndex: 1,
158+ rowsWhenCollapsed: 1, visibleDelegates: 2 },
159+ { tag: "4 items, collapsedRows 1", model: fakeModelFourItems, collapsedRowCountIndex: 0,
160+ rowsWhenCollapsed: 1, visibleDelegates: 3 },
161+ { tag: "4 items, collapsedRows 2", model: fakeModelFourItems, collapsedRowCountIndex: 1,
162+ rowsWhenCollapsed: 2, visibleDelegates: 4 },
166+ function test_modelSizeAffectsCollapsedRowCount(data) {
167+ filterGrid.model = data.model
132− collapsedRowCountSelector.selectedIndex = 1
168+ collapsedRowCountSelector.selectedIndex = data.collapsedRowCountIndex
170+ tryCompare(filterGrid, "rowsWhenCollapsed", data.rowsWhenCollapsed)
171+ tryCompareFunction(countVisibleDelegates, data.visibleDelegates)
135 function countVisibleDelegates() {
174 function countVisibleDelegates() {