@@ -1,5 +1,6 @@
11/*
22 * Copyright 2013-2016 Canonical Ltd.
3+ * Copyright 2019 UBports Foundation
34 *
45 * This program is free software; you can redistribute it and/or modify
56 * it under the terms of the GNU General Public License as published by
@@ -137,16 +138,18 @@ PanelTest {
137138 when: windowShown
138139
139140 function init() {
140− indicatorsMenu.hide();
141− tryCompare(indicatorsMenu.hideAnimation, "running", false);
142− compare(indicatorsMenu.state, "initial");
143−
144141 indicatorsMenu.verticalVelocityThreshold = 0.5
142+ tryCompare(indicatorsMenu.hideAnimation, "running", false);
143+ tryCompare(indicatorsMenu, "state", "initial");
144+ wait(100);
145145 }
146146
147147 function cleanup() {
148+ touchRelease(root);
148149 clickThroughSpy.clear();
149150 showTappedSpy.clear();
151+ indicatorsMenu.hideAnimation.complete();
152+ indicatorsMenu.hideNow();
150153 }
151154
152155 function get_indicator_item(index) {
@@ -226,33 +229,45 @@ PanelTest {
226229 touchRelease(indicatorsMenu, mappedPosition.x, indicatorsMenu.minimizedPanelHeight / 2);
227230 }
228231
232+ function test_swipeForCurrentItem_data() {
233+ return [
234+ {item: 0},
235+ {item: 1},
236+ {item: 2},
237+ {item: 3},
238+ {item: 4},
239+ {item: 5},
240+ {item: 6},
241+ {item: 7},
242+ {item: 8},
243+ ]
244+ }
245+
229246 // tests swiping on an indicator item activates the correct item.
230− function test_swipeForCurrentItem()
247+ function test_swipeForCurrentItem(data)
231248 {
232249 var panelItemRow = findChild(indicatorsMenu, "panelItemRow");
233250 verify(panelItemRow !== null);
234251
235− for (var i = 0; i < root.originalModelData.length; i++) {
236− var indicatorItem = get_indicator_item(i);
252+ var indicatorItem = get_indicator_item(data.item);
237253
238− var mappedPosition = indicatorsMenu.mapFromItem(indicatorItem, indicatorItem.width/2, indicatorItem.height/2);
254+ var mappedPosition = indicatorsMenu.mapFromItem(indicatorItem, indicatorItem.width/2, indicatorItem.height/2);
239255
240− touchFlick(indicatorsMenu,
241− mappedPosition.x, mappedPosition.y,
242− mappedPosition.x, indicatorsMenu.openedHeight / 2,
243− true /* beginTouch */, false /* endTouch */);
256+ touchFlick(indicatorsMenu,
257+ mappedPosition.x, mappedPosition.y,
258+ mappedPosition.x, indicatorsMenu.openedHeight / 2,
259+ true /* beginTouch */, false /* endTouch */);
244260
245− tryCompare(panelItemRow, "currentItem", indicatorItem, undefined /*timeout, default */,
246− "Incorrect item activated at position " + i);
261+ tryCompare(panelItemRow, "currentItem", indicatorItem, undefined /*timeout, default */,
262+ "Incorrect item activated at position " + data.item);
247263
248− touchFlick(panelItemRow,
249− mappedPosition.x, indicatorsMenu.openedHeight / 2,
250− mappedPosition.x, mappedPosition.y,
251− false /* beginTouch */, true /* endTouch */);
264+ touchFlick(panelItemRow,
265+ mappedPosition.x, indicatorsMenu.openedHeight / 2,
266+ mappedPosition.x, mappedPosition.y,
267+ false /* beginTouch */, true /* endTouch */);
252268
253− // wait until fully closed
254− tryCompare(indicatorsMenu, "fullyClosed", true);
255− }
269+ // wait until fully closed
270+ tryCompare(indicatorsMenu, "fullyClosed", true);
256271 }
257272
258273 // Test the vertical velocity check when flicking the indicators open at an angle.