@@ -19,7 +19,6 @@ import QtTest 1.0
19import Unity.Test 0.1 as UT
19import Unity.Test 0.1 as UT
20import ".."
20import ".."
21import "../../../Panel"
21import "../../../Panel"
22−import Ubuntu.ChewieUI 0.1 as ChewieUI
25 This tests the Panel component using a fake model to stage data in the indicators
24 This tests the Panel component using a fake model to stage data in the indicators
@@ -31,11 +30,11 @@ Item {
31 width: units.gu(40)
30 width: units.gu(40)
32 height: units.gu(80)
31 height: units.gu(80)
34− property bool search_clicked: false
33+ property bool searchClicked: false
36 Connections {
35 Connections {
37 target: panel
36 target: panel
38− onSearchClicked: search_clicked = true
37+ onSearchClicked: searchClicked = true
@@ -55,27 +54,26 @@ Item {
57 function init() {
56 function init() {
58− search_clicked = false;
57+ searchClicked = false;
59 panel.indicators.hide();
58 panel.indicators.hide();
60 tryCompare(panel.indicators.hideAnimation, "running", false);
59 tryCompare(panel.indicators.hideAnimation, "running", false);
61 tryCompare(panel.indicators, "state", "initial");
60 tryCompare(panel.indicators, "state", "initial");
64 function get_indicator_item(index) {
63 function get_indicator_item(index) {
65− var row_repeater = findChild(panel.indicators, "rowRepeater");
64+ var rowRepeater = findChild(panel.indicators, "rowRepeater");
66− verify(row_repeater != undefined)
65+ verify(rowRepeater != undefined);
67− return row_repeater.itemAt(index);
66+ return rowRepeater.itemAt(index);
70 function get_indicator_item_position(index) {
69 function get_indicator_item_position(index) {
70+ var indicatorRow = findChild(panel.indicators, "indicatorRow");
71+ verify(indicatorRow != undefined);
72− var indicator_row = findChild(panel.indicators, "indicatorRow");
73− verify(indicator_row != undefined)
75− var indicator_item = get_indicator_item(index);
73+ var indicatorItem = get_indicator_item(index);
76− verify(indicator_item != undefined);
74+ verify(indicatorItem != undefined);
78− return panel.mapFromItem(indicator_item, indicator_item.width/2, indicator_item.height/2);
76+ return panel.mapFromItem(indicatorItem, indicatorItem.width/2, indicatorItem.height/2);
81 // Pressing on the indicator panel should activate the indicator hints
79 // Pressing on the indicator panel should activate the indicator hints
@@ -84,11 +82,11 @@ Item {
84 panel.fullscreenMode = false;
82 panel.fullscreenMode = false;
85 // Wait for the indicators to get into position.
83 // Wait for the indicators to get into position.
86 // (switches between normal and fullscreen modes are animated)
84 // (switches between normal and fullscreen modes are animated)
87− tryCompare(panel.indicators, "y", 0)
85+ tryCompare(panel.indicators, "y", 0);
89− var indicator_item_coord = get_indicator_item_position(0);
87+ var indicatorItemCoord = get_indicator_item_position(0);
91− touchPress(panel, indicator_item_coord.x, panel.panelHeight / 2)
89+ touchPress(panel, indicatorItemCoord.x, panel.panelHeight / 2);
93 // hint animation should be run, meaning that indicators will move downwards
91 // hint animation should be run, meaning that indicators will move downwards
94 // by hintValue pixels without any drag taking place
92 // by hintValue pixels without any drag taking place
@@ -97,7 +95,7 @@ Item {
97 tryCompare(panel.indicators, "partiallyOpened", true);
95 tryCompare(panel.indicators, "partiallyOpened", true);
98 tryCompare(panel.indicators, "fullyOpened", false);
96 tryCompare(panel.indicators, "fullyOpened", false);
100− touchRelease(panel, indicator_item_coord.x, panel.panelHeight/2)
98+ touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
103 // Pressing on the top edge of the screen should have no effect if the panel
101 // Pressing on the top edge of the screen should have no effect if the panel
@@ -106,31 +104,31 @@ Item {
106 panel.fullscreenMode = true;
104 panel.fullscreenMode = true;
107 // Wait for the indicators to get into position.
105 // Wait for the indicators to get into position.
108 // (switches between normal and fullscreen modes are animated)
106 // (switches between normal and fullscreen modes are animated)
109− tryCompare(panel.indicators, "y", -panel.panelHeight)
107+ tryCompare(panel.indicators, "y", -panel.panelHeight);
111− var indicator_item_coord = get_indicator_item_position(0);
109+ var indicatorItemCoord = get_indicator_item_position(0);
113− touchPress(panel, indicator_item_coord.x, panel.panelHeight / 2)
111+ touchPress(panel, indicatorItemCoord.x, panel.panelHeight / 2);
115 // Give some time for a hint animation to change things, if any
113 // Give some time for a hint animation to change things, if any
116− wait(500)
114+ wait(500);
118 // no hint animation when fullscreen
116 // no hint animation when fullscreen
119− compare(panel.indicators.y, -panel.panelHeight)
117+ compare(panel.indicators.y, -panel.panelHeight);
120 var indicatorRow = findChild(panel.indicators, "indicatorRow");
118 var indicatorRow = findChild(panel.indicators, "indicatorRow");
121− verify(indicatorRow != undefined)
119+ verify(indicatorRow != undefined);
122− compare(indicatorRow.y, 0)
120+ compare(indicatorRow.y, 0);
123− compare(panel.indicators.height, panel.indicators.panelHeight)
121+ compare(panel.indicators.height, panel.indicators.panelHeight);
124 compare(panel.indicators.partiallyOpened, false,
122 compare(panel.indicators.partiallyOpened, false,
125 "Indicator should not be partially opened when panel is pressed in" +
123 "Indicator should not be partially opened when panel is pressed in" +
126− " fullscreenmode")
124+ " fullscreenmode");
127 compare(panel.indicators.fullyOpened, false, "Indicator should not be partially" +
125 compare(panel.indicators.fullyOpened, false, "Indicator should not be partially" +
128− " opened when panel is pressed in fullscreenmode")
126+ " opened when panel is pressed in fullscreenmode");
130− touchRelease(panel, indicator_item_coord.x, panel.panelHeight/2)
128+ touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
133− function test_drag_show_data() { return get_window_data() }
131+ function test_drag_show_data() { return get_window_data(); }
135 // Dragging from a indicator item in the panel will gradually expose the
133 // Dragging from a indicator item in the panel will gradually expose the
136 // indicators, first by running the hint animation, then after dragging down will
134 // indicators, first by running the hint animation, then after dragging down will
@@ -138,53 +136,53 @@ Item {
138 function test_drag_show(data) {
136 function test_drag_show(data) {
139 panel.fullscreenMode = data.fullscreenFlag;
137 panel.fullscreenMode = data.fullscreenFlag;
141− var indicator_row = findChild(panel.indicators, "indicatorRow");
139+ var indicatorRow = findChild(panel.indicators, "indicatorRow");
142− verify(indicator_row != undefined)
140+ verify(indicatorRow != undefined);
144− var row_repeater = findChild(panel.indicators, "rowRepeater");
142+ var rowRepeater = findChild(panel.indicators, "rowRepeater");
145− verify(indicator_row != undefined)
143+ verify(indicatorRow != undefined);
147− var menu_content = findChild(panel.indicators, "menuContent");
145+ var menuContent = findChild(panel.indicators, "menuContent");
148− verify(indicator_row != undefined)
146+ verify(indicatorRow != undefined);
150 // Wait for the indicators to get into position.
148 // Wait for the indicators to get into position.
151 // (switches between normal and fullscreen modes are animated)
149 // (switches between normal and fullscreen modes are animated)
152 if (data.fullscreenFlag) {
150 if (data.fullscreenFlag) {
153− tryCompare(panel.indicators, "y", -panel.panelHeight)
151+ tryCompare(panel.indicators, "y", -panel.panelHeight);
155− tryCompare(panel.indicators, "y", 0)
153+ tryCompare(panel.indicators, "y", 0);
158 // do this for each indicator item
156 // do this for each indicator item
159− for (var i = 0; i < row_repeater.count; i++) {
157+ for (var i = 0; i < rowRepeater.count; i++) {
161− var indicator_item = get_indicator_item(i);
159+ var indicatorItem = get_indicator_item(i);
162− verify(indicator_item != undefined)
160+ verify(indicatorItem != undefined);
164− var indicator_item_coord = get_indicator_item_position(i);
162+ var indicatorItemCoord = get_indicator_item_position(i);
166 touchPress(panel,
164 touchPress(panel,
167− indicator_item_coord.x, panel.panelHeight / 2)
165+ indicatorItemCoord.x, panel.panelHeight / 2);
169 // 1) Drag the mouse down
167 // 1) Drag the mouse down
170 touchFlick(panel,
168 touchFlick(panel,
171− indicator_item_coord.x, panel.panelHeight / 2,
169+ indicatorItemCoord.x, panel.panelHeight / 2,
172− indicator_item_coord.x, panel.height * 0.8,
170+ indicatorItemCoord.x, panel.height * 0.8,
173− false /* beginTouch */, false /* endTouch */)
171+ false /* beginTouch */, false /* endTouch */);
175 // Indicators height should follow the drag, and therefore increase accordingly.
173 // Indicators height should follow the drag, and therefore increase accordingly.
176 // They should be at least half-way through the screen
174 // They should be at least half-way through the screen
177 tryCompareFunction(
175 tryCompareFunction(
178 function() {return panel.indicators.height >= panel.height * 0.5},
176 function() {return panel.indicators.height >= panel.height * 0.5},
181− touchRelease(panel, indicator_item_coord.x, panel.height * 0.8)
179+ touchRelease(panel, indicatorItemCoord.x, panel.height * 0.8);
183− compare(indicator_row.currentItem, indicator_item,
181+ compare(indicatorRow.currentItem, indicatorItem,
184− "Incorrect item activated at position " + i)
182+ "Incorrect item activated at position " + i);
185− compare(menu_content.__shown, true, "Menu conetent should be enabled for item at position " + i);
183+ compare(menuContent.currentMenuIndex, i, "Menu conetent should be enabled for item at position " + i);
187− // init for next indicator_item
185+ // init for next indicatorItem
@@ -193,26 +191,67 @@ Item {
193 panel.fullscreenMode = false;
191 panel.fullscreenMode = false;
194 panel.searchVisible = true;
192 panel.searchVisible = true;
196− var search_indicator = findChild(panel, "search");
194+ var searchIndicator = findChild(panel, "search");
197− verify(search_indicator != undefined);
195+ verify(searchIndicator != undefined);
199− tap(search_indicator, 1, 1)
197+ tap(searchIndicator, 1, 1);
201− compare(search_clicked, true,
199+ compare(searchClicked, true,
202− "Tapping search indicator while it was enabled did not emit searchClicked signal")
200+ "Tapping search indicator while it was enabled did not emit searchClicked signal");
205 function test_search_click_when_not_visible() {
203 function test_search_click_when_not_visible() {
206 panel.fullscreenMode = false;
204 panel.fullscreenMode = false;
207− panel.searchVisible = false
205+ panel.searchVisible = false;
207+ var searchIndicator = findChild(panel, "search");
208+ verify(searchIndicator != undefined);
210+ tap(searchIndicator, 1, 1);
212+ compare(searchClicked, false,
213+ "Tapping search indicator while it was not visible emitted searchClicked signal");
216+ // Test the vertical velocity check when flicking the indicators open at an angle.
217+ // If the vertical velocity is above a specific point, we shouldnt change active indicators
218+ // if the x position changes
219+ function test_vertical_velocity_detector() {
220+ panel.fullscreenMode = false;
221+ panel.searchVisible = false;
223+ var indicatorRow = findChild(panel.indicators, "indicatorRow");
224+ verify(indicatorRow != undefined);
226+ var rowRepeater = findChild(panel.indicators, "rowRepeater");
227+ verify(indicatorRow != undefined);
229+ // Get the first indicator
230+ var indicatorItemFirst = get_indicator_item(0);
231+ verify(indicatorItemFirst != undefined);
233+ var indicatorItemCoordFirst = get_indicator_item_position(0);
234+ var indicatorItemCoordNext = get_indicator_item_position(indicatorRow.count - 1);
237+ indicatorItemCoordFirst.x, panel.panelHeight / 2);
239+ // 1) Drag the mouse down to hint a bit
241+ indicatorItemCoordFirst.x, panel.panelHeight / 2,
242+ indicatorItemCoordFirst.x, panel.panelHeight * 2,
243+ false /* beginTouch */, false /* endTouch */);
209− var search_indicator = findChild(panel, "search");
245+ tryCompare(indicatorRow, "currentItem", indicatorItemFirst)
210− verify(search_indicator != undefined);
212− tap(search_indicator, 1, 1)
247+ // 1) Flick mouse down to bottom
249+ indicatorItemCoordFirst.x, panel.panelHeight * 2,
250+ indicatorItemCoordNext.x, panel.height,
251+ false /* beginTouch */, true /* endTouch */,
252+ units.gu(10) /* speed */, 30 /* iterations */); // more samples needed for accurate velocity
214− compare(search_clicked, false,
254+ compare(indicatorRow.currentItem, indicatorItemFirst, "First indicator should still be the current item");
215− "Tapping search indicator while it was not visible emitted searchClicked signal")