@@ -17,6 +17,8 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import QtTest 1.0
18import QtTest 1.0
19import Unity.Test 0.1 as UT
19import Unity.Test 0.1 as UT
20+import Ubuntu.Components 0.1 as UC
21+import Ubuntu.Telephony 0.1 as Telephony
20import ".."
22import ".."
21import "../../../qml/Panel"
23import "../../../qml/Panel"
@@ -30,42 +32,104 @@ Item {
30 width: units.gu(40)
32 width: units.gu(40)
31 height: units.gu(80)
33 height: units.gu(80)
33− property bool searchClicked: false
37− onSearchClicked: searchClicked = true
42− anchors.fill: parent
37+ anchors {
41+ height: parent.height - row.height
42+ fullscreenMode: false
44 indicators {
44 indicators {
45 profile: "test1"
45 profile: "test1"
46+ panelHeight: units.gu(5)
52+ property real panelAndSeparatorHeight: panel.indicators.panelHeight + units.dp(2)
66+ text: panel.indicators.shown ? "Hide" : "Show"
69+ bottom: parent.bottom
71+ width: parent.width/3
74+ if (panel.indicators.shown) {
75+ panel.indicators.hide();
77+ panel.indicators.show();
83+ text: panel.fullscreenMode ? "Maximize" : "FullScreen"
86+ bottom: parent.bottom
88+ width: parent.width/3
90+ onClicked: panel.fullscreenMode = !panel.fullscreenMode
94+ text: callManager.hasCalls ? "Called" : "No Calls"
97+ bottom: parent.bottom
99+ width: parent.width/3
102+ if (callManager.foregroundCall) {
103+ callManager.foregroundCall = null;
105+ callManager.foregroundCall = phoneCall;
111+ Telephony.CallEntry {
113+ phoneNumber: "+447812221111"
49 UT.UnityTestCase {
116 UT.UnityTestCase {
50 name: "Panel"
117 name: "Panel"
51 when: windowShown
118 when: windowShown
53− function get_window_data() {
55− {tag: "pinned", fullscreenFlag: false, alreadyOpen: false },
56− {tag: "fullscreen", fullscreenFlag: true, alreadyOpen: false },
57− {tag: "pinned-alreadyOpen", fullscreenFlag: false, alreadyOpen: true },
58− {tag: "fullscreen-alreadyOpen", fullscreenFlag: true, alreadyOpen: true }
62 function init() {
120 function init() {
63 panel.indicators.initialise();
121 panel.indicators.initialise();
122+ panel.fullscreenMode = false;
65− searchClicked = false;
66 panel.indicators.hide();
124 panel.indicators.hide();
125+ // Wait for animation to complete
67 tryCompare(panel.indicators.hideAnimation, "running", false);
126 tryCompare(panel.indicators.hideAnimation, "running", false);
68− tryCompare(panel.indicators, "state", "initial");
127+ callManager.foregroundCall = null;
129+ // Wait for the indicators to get into position.
130+ // (switches between normal and fullscreen modes are animated)
131+ var indicatorArea = findChild(panel, "indicatorArea");
132+ tryCompare(indicatorArea, "y", 0);
71 function get_indicator_item(index) {
135 function get_indicator_item(index) {
@@ -88,46 +152,59 @@ Item {
88 // Pressing on the indicator panel should activate the indicator hints
152 // Pressing on the indicator panel should activate the indicator hints
89 // and expose a portion of the conent.
153 // and expose a portion of the conent.
90 function test_hint() {
154 function test_hint() {
91− panel.fullscreenMode = false;
92− // Wait for the indicators to get into position.
93− // (switches between normal and fullscreen modes are animated)
94− tryCompare(panel.indicators, "y", 0);
96 var indicatorItemCoord = get_indicator_item_position(0);
155 var indicatorItemCoord = get_indicator_item_position(0);
98− touchPress(panel, indicatorItemCoord.x, panel.panelHeight / 2);
157+ touchPress(panel, indicatorItemCoord.x, panel.indicators.panelHeight / 2);
100 // hint animation should be run, meaning that indicators will move downwards
159 // hint animation should be run, meaning that indicators will move downwards
101 // by hintValue pixels without any drag taking place
160 // by hintValue pixels without any drag taking place
102− tryCompare(panel.indicators, "height",
161+ tryCompareFunction(function() { return panel.indicators.height },
103− panel.indicators.panelHeight + panel.indicators.hintValue);
162+ panel.indicators.panelHeight + panel.indicators.hintValue);
104 tryCompare(panel.indicators, "partiallyOpened", true);
163 tryCompare(panel.indicators, "partiallyOpened", true);
105 tryCompare(panel.indicators, "fullyOpened", false);
164 tryCompare(panel.indicators, "fullyOpened", false);
107− touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
166+ touchRelease(panel, indicatorItemCoord.x, panel.indicators.panelHeight/2);
110 // Pressing on the top edge of the screen should have no effect if the panel
169 // Pressing on the top edge of the screen should have no effect if the panel
111− // is hidden (!pinned), which is the case when a fullscreen app is being shown
170+ // is hidden (fullscreen), which is the case when a fullscreen app is being shown
112 function test_noHintOnFullscreenMode() {
171 function test_noHintOnFullscreenMode() {
113 panel.fullscreenMode = true;
172 panel.fullscreenMode = true;
114 // Wait for the indicators to get into position.
173 // Wait for the indicators to get into position.
115 // (switches between normal and fullscreen modes are animated)
174 // (switches between normal and fullscreen modes are animated)
175+ var indicatorArea = findChild(panel, "indicatorArea");
116− tryCompare(panel.indicators, "y", -panel.panelHeight);
176+ tryCompare(indicatorArea, "y", -panel.panelHeight);
118 var indicatorItemCoord = get_indicator_item_position(0);
178 var indicatorItemCoord = get_indicator_item_position(0);
120− touchPress(panel, indicatorItemCoord.x, panel.panelHeight / 2);
180+ touchPress(panel, indicatorItemCoord.x, panel.indicators.panelHeight / 2);
182+ // Give some time for a hint animation to change things, if any
185+ // no hint animation when fullscreen
186+ compare(panel.indicators.partiallyOpened, false,
187+ "Indicator should not be partially opened when panel is pressed in" +
189+ compare(panel.indicators.fullyOpened, false, "Indicator should not be partially" +
190+ " opened when panel is pressed in fullscreenmode");
192+ touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
195+ // Pressing on the top edge of the indicator should have no effect if the panel
196+ // has an active call
197+ function test_noHintOnActiveCall() {
198+ callManager.foregroundCall = phoneCall;
200+ var indicatorItemCoord = get_indicator_item_position(0);
202+ touchPress(panel, indicatorItemCoord.x, panel.callHint.height + panel.indicators.panelHeight / 2);
122 // Give some time for a hint animation to change things, if any
204 // Give some time for a hint animation to change things, if any
123 wait(500);
205 wait(500);
125 // no hint animation when fullscreen
207 // no hint animation when fullscreen
126− compare(panel.indicators.y, -panel.panelHeight);
127− var indicatorRow = findChild(panel.indicators, "indicatorRow");
128− verify(indicatorRow !== null);
129− compare(indicatorRow.y, 0);
130− compare(panel.indicators.height, panel.indicators.panelHeight);
131 compare(panel.indicators.partiallyOpened, false,
208 compare(panel.indicators.partiallyOpened, false,
132 "Indicator should not be partially opened when panel is pressed in" +
209 "Indicator should not be partially opened when panel is pressed in" +
133 " fullscreenmode");
210 " fullscreenmode");
@@ -137,34 +214,47 @@ Item {
137 touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
214 touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
140− function test_drag_show_data() { return get_window_data(); }
217+ function test_drag_show_data() {
219+ { tag: "pinned", fullscreenFlag: false, alreadyOpen: false, call: null,
221+ { tag: "fullscreen", fullscreenFlag: true, alreadyOpen: false, call: null,
222+ indicatorY: -panel.panelAndSeparatorHeight },
223+ { tag: "pinned-alreadyOpen", fullscreenFlag: false, alreadyOpen: true, call: null,
225+ { tag: "fullscreen-alreadyOpen", fullscreenFlag: true, alreadyOpen: true, call: null,
227+ { tag: "pinned-callActive", fullscreenFlag: false, alreadyOpen: false, call: phoneCall,
229+ { tag: "fullscreen-callActive", fullscreenFlag: true, alreadyOpen: false, call: phoneCall,
230+ indicatorY: -panel.panelAndSeparatorHeight }
142 // Dragging from a indicator item in the panel will gradually expose the
234 // Dragging from a indicator item in the panel will gradually expose the
143 // indicators, first by running the hint animation, then after dragging down will
235 // indicators, first by running the hint animation, then after dragging down will
144 // expose more of the panel, binding it to the selected indicator and opening it's menu.
236 // expose more of the panel, binding it to the selected indicator and opening it's menu.
145 function test_drag_show(data) {
237 function test_drag_show(data) {
146 panel.fullscreenMode = data.fullscreenFlag;
238 panel.fullscreenMode = data.fullscreenFlag;
239+ callManager.foregroundCall = data.call;
147 if (data.alreadyOpen) {
241 if (data.alreadyOpen) {
148 panel.indicators.show();
242 panel.indicators.show();
149 tryCompare(panel.indicators, "fullyOpened", true);
243 tryCompare(panel.indicators, "fullyOpened", true);
152− var indicatorRow = findChild(panel.indicators, "indicatorRow");
246+ var indicatorRow = findChild(panel.indicators, "indicatorRow");
153 verify(indicatorRow !== null);
247 verify(indicatorRow !== null);
155 var menuContent = findChild(panel.indicators, "menuContent");
249 var menuContent = findChild(panel.indicators, "menuContent");
156− verify(indicatorRow !== null);
250+ verify(menuContent !== null);
158− var menuContent = findChild(panel.indicators, "menuContent");
252+ var indicatorArea = findChild(panel, "indicatorArea");
159− verify(indicatorRow !== null);
253+ verify(indicatorArea !== null);
161 // Wait for the indicators to get into position.
255 // Wait for the indicators to get into position.
162 // (switches between normal and fullscreen modes are animated)
256 // (switches between normal and fullscreen modes are animated)
163− if (data.fullscreenFlag) {
257+ tryCompareFunction(function() { return indicatorArea.y }, data.indicatorY);
164− tryCompare(panel.indicators, "y", -panel.panelHeight);
166− tryCompare(panel.indicators, "y", 0);
169 // do this for each indicator item
259 // do this for each indicator item
170 for (var i = 0; i < indicatorRow.row.count; i++) {
260 for (var i = 0; i < indicatorRow.row.count; i++) {
@@ -178,12 +268,12 @@ Item {
178 var indicatorItemCoord = get_indicator_item_position(i);
268 var indicatorItemCoord = get_indicator_item_position(i);
180 touchPress(panel,
270 touchPress(panel,
181− indicatorItemCoord.x, panel.panelHeight / 2);
271+ indicatorItemCoord.x, panel.indicators.panelHeight / 2);
183 // 1) Drag the mouse down
273 // 1) Drag the mouse down
184 touchFlick(panel,
274 touchFlick(panel,
185− indicatorItemCoord.x, panel.panelHeight / 2,
275+ indicatorItemCoord.x, panel.indicators.panelHeight / 2,
186− indicatorItemCoord.x, panel.height * 0.8,
276+ indicatorItemCoord.x, panel.height,
187 false /* beginTouch */, false /* endTouch */);
277 false /* beginTouch */, false /* endTouch */);
189 // Indicators height should follow the drag, and therefore increase accordingly.
279 // Indicators height should follow the drag, and therefore increase accordingly.
@@ -192,7 +282,7 @@ Item {
192 function() {return panel.indicators.height >= panel.height * 0.5},
282 function() {return panel.indicators.height >= panel.height * 0.5},
195− touchRelease(panel, indicatorItemCoord.x, panel.height * 0.8);
285+ touchRelease(panel, indicatorItemCoord.x, panel.height);
197 compare(indicatorRow.currentItem, indicatorItem,
287 compare(indicatorRow.currentItem, indicatorItem,
198 "Incorrect item activated at position " + i);
288 "Incorrect item activated at position " + i);
@@ -200,43 +290,18 @@ Item {
201 // init for next indicatorItem
291 // init for next indicatorItem
202 if (!data.alreadyOpen) {
292 if (!data.alreadyOpen) {
203− init();
293+ panel.indicators.hide();
294+ tryCompare(panel.indicators.hideAnimation, "running", false);
295+ tryCompare(panel.indicators, "state", "initial");
208− function test_search_click_when_visible() {
209− panel.fullscreenMode = false;
210− panel.searchVisible = true;
212− var searchIndicator = findChild(panel, "search");
213− verify(searchIndicator !== null);
215− tap(searchIndicator, 1, 1);
217− compare(searchClicked, true,
218− "Tapping search indicator while it was enabled did not emit searchClicked signal");
221− function test_search_click_when_not_visible() {
222− panel.fullscreenMode = false;
223− panel.searchVisible = false;
225− var searchIndicator = findChild(panel, "search");
226− verify(searchIndicator !== null);
228− tap(searchIndicator, 1, 1);
230− compare(searchClicked, false,
231− "Tapping search indicator while it was not visible emitted searchClicked signal");
234 // Test the vertical velocity check when flicking the indicators open at an angle.
300 // Test the vertical velocity check when flicking the indicators open at an angle.
235 // If the vertical velocity is above a specific point, we shouldnt change active indicators
301 // If the vertical velocity is above a specific point, we shouldnt change active indicators
236 // if the x position changes
302 // if the x position changes
237 function test_vertical_velocity_detector() {
303 function test_vertical_velocity_detector() {
238 panel.fullscreenMode = false;
304 panel.fullscreenMode = false;
239− panel.searchVisible = false;
241 var indicatorRow = findChild(panel.indicators, "indicatorRow");
306 var indicatorRow = findChild(panel.indicators, "indicatorRow");
242 verify(indicatorRow !== null);
307 verify(indicatorRow !== null);
@@ -249,19 +314,19 @@ Item {
249 var indicatorItemCoordNext = get_indicator_item_position(indicatorRow.row.count - 1);
314 var indicatorItemCoordNext = get_indicator_item_position(indicatorRow.row.count - 1);
251 touchPress(panel,
316 touchPress(panel,
252− indicatorItemCoordFirst.x, panel.panelHeight / 2);
317+ indicatorItemCoordFirst.x, panel.indicators.panelHeight / 2);
254 // 1) Drag the mouse down to hint a bit
319 // 1) Drag the mouse down to hint a bit
255 touchFlick(panel,
320 touchFlick(panel,
256− indicatorItemCoordFirst.x, panel.panelHeight / 2,
321+ indicatorItemCoordFirst.x, panel.indicators.panelHeight / 2,
257− indicatorItemCoordFirst.x, panel.panelHeight * 2,
322+ indicatorItemCoordFirst.x, panel.indicators.panelHeight * 2,
258 false /* beginTouch */, false /* endTouch */);
323 false /* beginTouch */, false /* endTouch */);
260 tryCompare(indicatorRow, "currentItem", indicatorItemFirst)
325 tryCompare(indicatorRow, "currentItem", indicatorItemFirst)
262 // 1) Flick mouse down to bottom
327 // 1) Flick mouse down to bottom
263 touchFlick(panel,
328 touchFlick(panel,
264− indicatorItemCoordFirst.x, panel.panelHeight * 2,
329+ indicatorItemCoordFirst.x, panel.indicators.panelHeight * 2,
265 indicatorItemCoordNext.x, panel.height,
330 indicatorItemCoordNext.x, panel.height,
266 false /* beginTouch */, true /* endTouch */,
331 false /* beginTouch */, true /* endTouch */,
267 units.gu(10) /* speed */, 30 /* iterations */); // more samples needed for accurate velocity
332 units.gu(10) /* speed */, 30 /* iterations */); // more samples needed for accurate velocity