on xenial help sign in
Fix horizontal list activation and add test for it.
bd77b2fMichał Sawicz
qml/Dash/CardHorizontalList.qml+2−2
@@ -54,8 +54,8 @@ DashRenderer {
54 }
54 }
55 Connections {
55 Connections {
56 target: loader.item
56 target: loader.item
57− onClicked: root.clicked(index, result)
57+ onClicked: root.clicked(index, result, loader.item, model)
58− onPressAndHold: root.pressAndHold(index)
58+ onPressAndHold: root.pressAndHold(index, model)
59 }
59 }
60 }
60 }
61 }
61 }
tests/mocks/Unity/fake_categories.cpp+3
@@ -149,6 +149,9 @@ Categories::data(const QModelIndex& index, int role) const
149 map["card-size"] = "medium";
149 map["card-size"] = "medium";
150 map["overlay"] = true;
150 map["overlay"] = true;
151 }
151 }
152+ if (index.row() == 18) {
153+ map["category-layout"] = "horizontal-list";
154+ }
152 if (index.row() == 19) {
155 if (index.row() == 19) {
153 map["category-layout"] = "grid";
156 map["category-layout"] = "grid";
154 map["collapsed-rows"] = 0;
157 map["collapsed-rows"] = 0;
tests/qmltests/Dash/tst_GenericScopeView.qml+48−17
@@ -76,6 +76,20 @@ Item {
76 spy.signalName = "";
76 spy.signalName = "";
77 }
77 }
78
78
79+ function scrollToCategory(category) {
80+ var categoryListView = findChild(genericScopeView, "categoryListView");
81+ tryCompareFunction(function() {
82+ if (findChild(genericScopeView, category)) return true;
83+ mouseFlick(genericScopeView, genericScopeView.width/2, genericScopeView.height,
84+ genericScopeView.width/2, genericScopeView.y)
85+ tryCompare(categoryListView, "moving", false);
86+ return findChild(genericScopeView, category) !== null;
87+ }, true);
88+
89+ tryCompareFunction(function() { return findChild(genericScopeView, "delegate0") !== null; }, true);
90+ return findChild(genericScopeView, category);
91+ }
92+
79 function test_isActive() {
93 function test_isActive() {
80 tryCompare(genericScopeView.scope, "isActive", false)
94 tryCompare(genericScopeView.scope, "isActive", false)
81 genericScopeView.isCurrent = true
95 genericScopeView.isCurrent = true
@@ -222,12 +236,7 @@ Item {
222 }
236 }
223
237
224 function test_forced_category_expansion() {
238 function test_forced_category_expansion() {
225− tryCompareFunction(function() {
226− mouseFlick(genericScopeView, genericScopeView.width/2, genericScopeView.height,
227− genericScopeView.width/2, genericScopeView.y)
228− return findChild(genericScopeView, "dashCategory19") !== null;
229− }, true);
230− var category = findChild(genericScopeView, "dashCategory19")
239+ var category = scrollToCategory("dashCategory19");
231 compare(category.expandable, false, "Category with collapsed-rows: 0 should not be expandable");
240 compare(category.expandable, false, "Category with collapsed-rows: 0 should not be expandable");
232
241
233 var grid = findChild(category, "19");
242 var grid = findChild(category, "19");
@@ -285,20 +294,13 @@ Item {
285 }
294 }
286
295
287 function test_showPreviewCarousel() {
296 function test_showPreviewCarousel() {
288− tryCompareFunction(function() {
297+ var category = scrollToCategory("dashCategory1");
289− var dashCategory1 = findChild(genericScopeView, "dashCategory1");
290− if (dashCategory1 != null) {
291− var tile = findChild(dashCategory1, "carouselDelegate1");
292− return tile != null;
293− }
294− return false;
295− },
296− true);
297
298
298 tryCompare(testCase.previewListView, "open", false);
299 tryCompare(testCase.previewListView, "open", false);
299
300
300− var dashCategory1 = findChild(genericScopeView, "dashCategory1");
301− var tile = findChild(dashCategory1, "carouselDelegate1");
301+ var tile = findChild(category, "carouselDelegate1");
302+ verify(tile, "Could not find delegate");
303+
302 mouseClick(tile, tile.width / 2, tile.height / 2);
304 mouseClick(tile, tile.width / 2, tile.height / 2);
303 tryCompare(tile, "explicitlyScaled", true);
305 tryCompare(tile, "explicitlyScaled", true);
304 mouseClick(tile, tile.width / 2, tile.height / 2);
306 mouseClick(tile, tile.width / 2, tile.height / 2);
@@ -306,6 +308,35 @@ Item {
306 tryCompare(testCase.previewListView, "x", 0);
308 tryCompare(testCase.previewListView, "x", 0);
307
309
308 closePreview();
310 closePreview();
311+
312+ mousePress(tile, tile.width / 2, tile.height / 2);
313+ tryCompare(testCase.previewListView, "open", true);
314+ tryCompare(testCase.previewListView, "x", 0);
315+ mouseRelease(tile, tile.width / 2, tile.height / 2);
316+
317+ closePreview();
318+ }
319+
320+ function test_showPreviewHorizontalList() {
321+ var category = scrollToCategory("dashCategory18");
322+
323+ tryCompare(testCase.previewListView, "open", false);
324+
325+ var tile = findChild(category, "delegate1");
326+ verify(tile, "Could not find delegate");
327+
328+ mouseClick(tile, tile.width / 2, tile.height / 2);
329+ tryCompare(testCase.previewListView, "open", true);
330+ tryCompare(testCase.previewListView, "x", 0);
331+
332+ closePreview();
333+
334+ mousePress(tile, tile.width / 2, tile.height / 2);
335+ tryCompare(testCase.previewListView, "open", true);
336+ tryCompare(testCase.previewListView, "x", 0);
337+ mouseRelease(tile, tile.width / 2, tile.height / 2);
338+
339+ closePreview();
309 }
340 }
310
341
311 function test_previewCycle() {
342 function test_previewCycle() {