@@ -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"
@@ -32,32 +34,102 @@ Item {
35− anchors.fill: parent
37+ anchors {
41+ height: parent.height - row.height
42+ fullscreenMode: false
37 indicators {
44 indicators {
38 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"
42 UT.UnityTestCase {
116 UT.UnityTestCase {
43 name: "Panel"
117 name: "Panel"
44 when: windowShown
118 when: windowShown
46− function get_window_data() {
48− {tag: "pinned", fullscreenFlag: false, alreadyOpen: false },
49− {tag: "fullscreen", fullscreenFlag: true, alreadyOpen: false },
50− {tag: "pinned-alreadyOpen", fullscreenFlag: false, alreadyOpen: true },
51− {tag: "fullscreen-alreadyOpen", fullscreenFlag: true, alreadyOpen: true }
55 function init() {
120 function init() {
56 panel.indicators.initialise();
121 panel.indicators.initialise();
122+ panel.fullscreenMode = false;
58 panel.indicators.hide();
124 panel.indicators.hide();
125+ // Wait for animation to complete
59 tryCompare(panel.indicators.hideAnimation, "running", false);
126 tryCompare(panel.indicators.hideAnimation, "running", false);
60− 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);
63 function get_indicator_item(index) {
135 function get_indicator_item(index) {
@@ -80,46 +152,37 @@ Item {
80 // Pressing on the indicator panel should activate the indicator hints
152 // Pressing on the indicator panel should activate the indicator hints
81 // and expose a portion of the conent.
153 // and expose a portion of the conent.
82 function test_hint() {
154 function test_hint() {
83− panel.fullscreenMode = false;
84− // Wait for the indicators to get into position.
85− // (switches between normal and fullscreen modes are animated)
86− tryCompare(panel.indicators, "y", 0);
88 var indicatorItemCoord = get_indicator_item_position(0);
155 var indicatorItemCoord = get_indicator_item_position(0);
90− touchPress(panel, indicatorItemCoord.x, panel.panelHeight / 2);
157+ touchPress(panel, indicatorItemCoord.x, panel.indicators.panelHeight / 2);
92 // hint animation should be run, meaning that indicators will move downwards
159 // hint animation should be run, meaning that indicators will move downwards
93 // by hintValue pixels without any drag taking place
160 // by hintValue pixels without any drag taking place
94− tryCompare(panel.indicators, "height",
161+ tryCompareFunction(function() { return panel.indicators.height },
95− panel.indicators.panelHeight + panel.indicators.hintValue);
162+ panel.indicators.panelHeight + panel.indicators.hintValue);
96 tryCompare(panel.indicators, "partiallyOpened", true);
163 tryCompare(panel.indicators, "partiallyOpened", true);
97 tryCompare(panel.indicators, "fullyOpened", false);
164 tryCompare(panel.indicators, "fullyOpened", false);
99− touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
166+ touchRelease(panel, indicatorItemCoord.x, panel.indicators.panelHeight/2);
102 // 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
103− // 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
104 function test_noHintOnFullscreenMode() {
171 function test_noHintOnFullscreenMode() {
105 panel.fullscreenMode = true;
172 panel.fullscreenMode = true;
106 // Wait for the indicators to get into position.
173 // Wait for the indicators to get into position.
107 // (switches between normal and fullscreen modes are animated)
174 // (switches between normal and fullscreen modes are animated)
175+ var indicatorArea = findChild(panel, "indicatorArea");
108− tryCompare(panel.indicators, "y", -panel.panelHeight);
176+ tryCompare(indicatorArea, "y", -panel.panelHeight);
110 var indicatorItemCoord = get_indicator_item_position(0);
178 var indicatorItemCoord = get_indicator_item_position(0);
112− touchPress(panel, indicatorItemCoord.x, panel.panelHeight / 2);
180+ touchPress(panel, indicatorItemCoord.x, panel.indicators.panelHeight / 2);
114 // Give some time for a hint animation to change things, if any
182 // Give some time for a hint animation to change things, if any
115 wait(500);
183 wait(500);
117 // no hint animation when fullscreen
185 // no hint animation when fullscreen
118− compare(panel.indicators.y, -panel.panelHeight);
119− var indicatorRow = findChild(panel.indicators, "indicatorRow");
120− verify(indicatorRow !== null);
121− compare(indicatorRow.y, 0);
122− compare(panel.indicators.height, panel.indicators.panelHeight);
123 compare(panel.indicators.partiallyOpened, false,
186 compare(panel.indicators.partiallyOpened, false,
124 "Indicator should not be partially opened when panel is pressed in" +
187 "Indicator should not be partially opened when panel is pressed in" +
125 " fullscreenmode");
188 " fullscreenmode");
@@ -129,34 +192,69 @@ Item {
129 touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
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);
204+ // Give some time for a hint animation to change things, if any
207+ // no hint animation when fullscreen
208+ compare(panel.indicators.partiallyOpened, false,
209+ "Indicator should not be partially opened when panel is pressed in" +
211+ compare(panel.indicators.fullyOpened, false, "Indicator should not be partially" +
212+ " opened when panel is pressed in fullscreenmode");
214+ touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
132− 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 }
134 // 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
135 // 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
136 // 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.
137 function test_drag_show(data) {
237 function test_drag_show(data) {
138 panel.fullscreenMode = data.fullscreenFlag;
238 panel.fullscreenMode = data.fullscreenFlag;
239+ callManager.foregroundCall = data.call;
139 if (data.alreadyOpen) {
241 if (data.alreadyOpen) {
140 panel.indicators.show();
242 panel.indicators.show();
141 tryCompare(panel.indicators, "fullyOpened", true);
243 tryCompare(panel.indicators, "fullyOpened", true);
144− var indicatorRow = findChild(panel.indicators, "indicatorRow");
246+ var indicatorRow = findChild(panel.indicators, "indicatorRow");
145 verify(indicatorRow !== null);
247 verify(indicatorRow !== null);
147 var menuContent = findChild(panel.indicators, "menuContent");
249 var menuContent = findChild(panel.indicators, "menuContent");
148− verify(indicatorRow !== null);
250+ verify(menuContent !== null);
150− var menuContent = findChild(panel.indicators, "menuContent");
252+ var indicatorArea = findChild(panel, "indicatorArea");
151− verify(indicatorRow !== null);
253+ verify(indicatorArea !== null);
153 // Wait for the indicators to get into position.
255 // Wait for the indicators to get into position.
154 // (switches between normal and fullscreen modes are animated)
256 // (switches between normal and fullscreen modes are animated)
155− if (data.fullscreenFlag) {
257+ tryCompareFunction(function() { return indicatorArea.y }, data.indicatorY);
156− tryCompare(panel.indicators, "y", -panel.panelHeight);
158− tryCompare(panel.indicators, "y", 0);
161 // do this for each indicator item
259 // do this for each indicator item
162 for (var i = 0; i < indicatorRow.row.count; i++) {
260 for (var i = 0; i < indicatorRow.row.count; i++) {
@@ -170,12 +268,12 @@ Item {
170 var indicatorItemCoord = get_indicator_item_position(i);
268 var indicatorItemCoord = get_indicator_item_position(i);
172 touchPress(panel,
270 touchPress(panel,
173− indicatorItemCoord.x, panel.panelHeight / 2);
271+ indicatorItemCoord.x, panel.indicators.panelHeight / 2);
175 // 1) Drag the mouse down
273 // 1) Drag the mouse down
176 touchFlick(panel,
274 touchFlick(panel,
177− indicatorItemCoord.x, panel.panelHeight / 2,
275+ indicatorItemCoord.x, panel.indicators.panelHeight / 2,
178− indicatorItemCoord.x, panel.height * 0.8,
276+ indicatorItemCoord.x, panel.height,
179 false /* beginTouch */, false /* endTouch */);
277 false /* beginTouch */, false /* endTouch */);
181 // Indicators height should follow the drag, and therefore increase accordingly.
279 // Indicators height should follow the drag, and therefore increase accordingly.
@@ -184,7 +282,7 @@ Item {
184 function() {return panel.indicators.height >= panel.height * 0.5},
282 function() {return panel.indicators.height >= panel.height * 0.5},
187− touchRelease(panel, indicatorItemCoord.x, panel.height * 0.8);
285+ touchRelease(panel, indicatorItemCoord.x, panel.height);
189 compare(indicatorRow.currentItem, indicatorItem,
287 compare(indicatorRow.currentItem, indicatorItem,
190 "Incorrect item activated at position " + i);
288 "Incorrect item activated at position " + i);
@@ -192,7 +290,9 @@ Item {
193 // init for next indicatorItem
291 // init for next indicatorItem
194 if (!data.alreadyOpen) {
292 if (!data.alreadyOpen) {
195− init();
293+ panel.indicators.hide();
294+ tryCompare(panel.indicators.hideAnimation, "running", false);
295+ tryCompare(panel.indicators, "state", "initial");
@@ -214,19 +314,19 @@ Item {
214 var indicatorItemCoordNext = get_indicator_item_position(indicatorRow.row.count - 1);
314 var indicatorItemCoordNext = get_indicator_item_position(indicatorRow.row.count - 1);
216 touchPress(panel,
316 touchPress(panel,
217− indicatorItemCoordFirst.x, panel.panelHeight / 2);
317+ indicatorItemCoordFirst.x, panel.indicators.panelHeight / 2);
219 // 1) Drag the mouse down to hint a bit
319 // 1) Drag the mouse down to hint a bit
220 touchFlick(panel,
320 touchFlick(panel,
221− indicatorItemCoordFirst.x, panel.panelHeight / 2,
321+ indicatorItemCoordFirst.x, panel.indicators.panelHeight / 2,
222− indicatorItemCoordFirst.x, panel.panelHeight * 2,
322+ indicatorItemCoordFirst.x, panel.indicators.panelHeight * 2,
223 false /* beginTouch */, false /* endTouch */);
323 false /* beginTouch */, false /* endTouch */);
225 tryCompare(indicatorRow, "currentItem", indicatorItemFirst)
325 tryCompare(indicatorRow, "currentItem", indicatorItemFirst)
227 // 1) Flick mouse down to bottom
327 // 1) Flick mouse down to bottom
228 touchFlick(panel,
328 touchFlick(panel,
229− indicatorItemCoordFirst.x, panel.panelHeight * 2,
329+ indicatorItemCoordFirst.x, panel.indicators.panelHeight * 2,
230 indicatorItemCoordNext.x, panel.height,
330 indicatorItemCoordNext.x, panel.height,
231 false /* beginTouch */, true /* endTouch */,
331 false /* beginTouch */, true /* endTouch */,
232 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