@@ -17,6 +17,8 @@
1717import QtQuick 2.0
1818import QtTest 1.0
1919import Unity.Test 0.1 as UT
20+import Ubuntu.Components 0.1 as UC
21+import Ubuntu.Telephony 0.1 as Telephony
2022import ".."
2123import "../../../qml/Panel"
2224
@@ -32,32 +34,102 @@ Item {
3234
3335 Panel {
3436 id: panel
35− anchors.fill: parent
37+ anchors {
38+ left: parent.left
39+ right: parent.right
40+ }
41+ height: parent.height - row.height
42+ fullscreenMode: false
3643
3744 indicators {
3845 profile: "test1"
46+ panelHeight: units.gu(5)
47+ }
48+ callHint {
49+ height: units.gu(4)
3950 }
51+
52+ property real panelAndSeparatorHeight: panel.indicators.panelHeight + units.dp(2)
53+ }
54+
55+
56+ Row {
57+ id: row
58+ anchors {
59+ bottom: shell.bottom
60+ left: parent.left
61+ right: parent.right
62+ }
63+ height: 50
64+
65+ UC.Button {
66+ text: panel.indicators.shown ? "Hide" : "Show"
67+ anchors {
68+ top: parent.top
69+ bottom: parent.bottom
70+ }
71+ width: parent.width/3
72+
73+ onClicked: {
74+ if (panel.indicators.shown) {
75+ panel.indicators.hide();
76+ } else {
77+ panel.indicators.show();
78+ }
79+ }
80+ }
81+
82+ UC.Button {
83+ text: panel.fullscreenMode ? "Maximize" : "FullScreen"
84+ anchors {
85+ top: parent.top
86+ bottom: parent.bottom
87+ }
88+ width: parent.width/3
89+
90+ onClicked: panel.fullscreenMode = !panel.fullscreenMode
91+ }
92+
93+ UC.Button {
94+ text: callManager.hasCalls ? "Called" : "No Calls"
95+ anchors {
96+ top: parent.top
97+ bottom: parent.bottom
98+ }
99+ width: parent.width/3
100+
101+ onClicked: {
102+ if (callManager.foregroundCall) {
103+ callManager.foregroundCall = null;
104+ } else {
105+ callManager.foregroundCall = phoneCall;
106+ }
107+ }
108+ }
109+ }
110+
111+ Telephony.CallEntry {
112+ id: phoneCall
113+ phoneNumber: "+447812221111"
40114 }
41115
42116 UT.UnityTestCase {
43117 name: "Panel"
44118 when: windowShown
45119
46− function get_window_data() {
47− return [
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 }
52− ];
53− }
54−
55120 function init() {
56121 panel.indicators.initialise();
122+ panel.fullscreenMode = false;
57123
58124 panel.indicators.hide();
125+ // Wait for animation to complete
59126 tryCompare(panel.indicators.hideAnimation, "running", false);
60− tryCompare(panel.indicators, "state", "initial");
127+ callManager.foregroundCall = null;
128+
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);
61133 }
62134
63135 function get_indicator_item(index) {
@@ -80,46 +152,37 @@ Item {
80152 // Pressing on the indicator panel should activate the indicator hints
81153 // and expose a portion of the conent.
82154 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);
87−
88155 var indicatorItemCoord = get_indicator_item_position(0);
89156
90− touchPress(panel, indicatorItemCoord.x, panel.panelHeight / 2);
157+ touchPress(panel, indicatorItemCoord.x, panel.indicators.panelHeight / 2);
91158
92159 // hint animation should be run, meaning that indicators will move downwards
93160 // by hintValue pixels without any drag taking place
94− tryCompare(panel.indicators, "height",
95− panel.indicators.panelHeight + panel.indicators.hintValue);
161+ tryCompareFunction(function() { return panel.indicators.height },
162+ panel.indicators.panelHeight + panel.indicators.hintValue);
96163 tryCompare(panel.indicators, "partiallyOpened", true);
97164 tryCompare(panel.indicators, "fullyOpened", false);
98165
99− touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
166+ touchRelease(panel, indicatorItemCoord.x, panel.indicators.panelHeight/2);
100167 }
101168
102169 // 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
104171 function test_noHintOnFullscreenMode() {
105172 panel.fullscreenMode = true;
106173 // Wait for the indicators to get into position.
107174 // (switches between normal and fullscreen modes are animated)
108− tryCompare(panel.indicators, "y", -panel.panelHeight);
175+ var indicatorArea = findChild(panel, "indicatorArea");
176+ tryCompare(indicatorArea, "y", -panel.panelHeight);
109177
110178 var indicatorItemCoord = get_indicator_item_position(0);
111179
112− touchPress(panel, indicatorItemCoord.x, panel.panelHeight / 2);
180+ touchPress(panel, indicatorItemCoord.x, panel.indicators.panelHeight / 2);
113181
114182 // Give some time for a hint animation to change things, if any
115183 wait(500);
116184
117185 // 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);
123186 compare(panel.indicators.partiallyOpened, false,
124187 "Indicator should not be partially opened when panel is pressed in" +
125188 " fullscreenmode");
@@ -129,34 +192,69 @@ Item {
129192 touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
130193 }
131194
132− function test_drag_show_data() { return get_window_data(); }
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;
199+
200+ var indicatorItemCoord = get_indicator_item_position(0);
201+
202+ touchPress(panel, indicatorItemCoord.x, panel.callHint.height + panel.indicators.panelHeight / 2);
203+
204+ // Give some time for a hint animation to change things, if any
205+ wait(500);
206+
207+ // no hint animation when fullscreen
208+ compare(panel.indicators.partiallyOpened, false,
209+ "Indicator should not be partially opened when panel is pressed in" +
210+ " fullscreenmode");
211+ compare(panel.indicators.fullyOpened, false, "Indicator should not be partially" +
212+ " opened when panel is pressed in fullscreenmode");
213+
214+ touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
215+ }
216+
217+ function test_drag_show_data() {
218+ return [
219+ { tag: "pinned", fullscreenFlag: false, alreadyOpen: false, call: null,
220+ indicatorY: 0 },
221+ { tag: "fullscreen", fullscreenFlag: true, alreadyOpen: false, call: null,
222+ indicatorY: -panel.panelAndSeparatorHeight },
223+ { tag: "pinned-alreadyOpen", fullscreenFlag: false, alreadyOpen: true, call: null,
224+ indicatorY: 0 },
225+ { tag: "fullscreen-alreadyOpen", fullscreenFlag: true, alreadyOpen: true, call: null,
226+ indicatorY: 0 },
227+ { tag: "pinned-callActive", fullscreenFlag: false, alreadyOpen: false, call: phoneCall,
228+ indicatorY: 0},
229+ { tag: "fullscreen-callActive", fullscreenFlag: true, alreadyOpen: false, call: phoneCall,
230+ indicatorY: -panel.panelAndSeparatorHeight }
231+ ];
232+ }
133233
134234 // Dragging from a indicator item in the panel will gradually expose the
135235 // indicators, first by running the hint animation, then after dragging down will
136236 // expose more of the panel, binding it to the selected indicator and opening it's menu.
137237 function test_drag_show(data) {
138238 panel.fullscreenMode = data.fullscreenFlag;
239+ callManager.foregroundCall = data.call;
240+
139241 if (data.alreadyOpen) {
140242 panel.indicators.show();
141243 tryCompare(panel.indicators, "fullyOpened", true);
142244 }
143245
144− var indicatorRow = findChild(panel.indicators, "indicatorRow");
246+ var indicatorRow = findChild(panel.indicators, "indicatorRow");
145247 verify(indicatorRow !== null);
146248
147249 var menuContent = findChild(panel.indicators, "menuContent");
148− verify(indicatorRow !== null);
250+ verify(menuContent !== null);
149251
150− var menuContent = findChild(panel.indicators, "menuContent");
151− verify(indicatorRow !== null);
252+ var indicatorArea = findChild(panel, "indicatorArea");
253+ verify(indicatorArea !== null);
152254
153255 // Wait for the indicators to get into position.
154256 // (switches between normal and fullscreen modes are animated)
155− if (data.fullscreenFlag) {
156− tryCompare(panel.indicators, "y", -panel.panelHeight);
157− } else {
158− tryCompare(panel.indicators, "y", 0);
159− }
257+ tryCompareFunction(function() { return indicatorArea.y }, data.indicatorY);
160258
161259 // do this for each indicator item
162260 for (var i = 0; i < indicatorRow.row.count; i++) {
@@ -170,12 +268,12 @@ Item {
170268 var indicatorItemCoord = get_indicator_item_position(i);
171269
172270 touchPress(panel,
173− indicatorItemCoord.x, panel.panelHeight / 2);
271+ indicatorItemCoord.x, panel.indicators.panelHeight / 2);
174272
175273 // 1) Drag the mouse down
176274 touchFlick(panel,
177− indicatorItemCoord.x, panel.panelHeight / 2,
178− indicatorItemCoord.x, panel.height * 0.8,
275+ indicatorItemCoord.x, panel.indicators.panelHeight / 2,
276+ indicatorItemCoord.x, panel.height,
179277 false /* beginTouch */, false /* endTouch */);
180278
181279 // Indicators height should follow the drag, and therefore increase accordingly.
@@ -184,7 +282,7 @@ Item {
184282 function() {return panel.indicators.height >= panel.height * 0.5},
185283 true);
186284
187− touchRelease(panel, indicatorItemCoord.x, panel.height * 0.8);
285+ touchRelease(panel, indicatorItemCoord.x, panel.height);
188286
189287 compare(indicatorRow.currentItem, indicatorItem,
190288 "Incorrect item activated at position " + i);
@@ -192,7 +290,9 @@ Item {
192290
193291 // init for next indicatorItem
194292 if (!data.alreadyOpen) {
195− init();
293+ panel.indicators.hide();
294+ tryCompare(panel.indicators.hideAnimation, "running", false);
295+ tryCompare(panel.indicators, "state", "initial");
196296 }
197297 }
198298 }
@@ -214,19 +314,19 @@ Item {
214314 var indicatorItemCoordNext = get_indicator_item_position(indicatorRow.row.count - 1);
215315
216316 touchPress(panel,
217− indicatorItemCoordFirst.x, panel.panelHeight / 2);
317+ indicatorItemCoordFirst.x, panel.indicators.panelHeight / 2);
218318
219319 // 1) Drag the mouse down to hint a bit
220320 touchFlick(panel,
221− indicatorItemCoordFirst.x, panel.panelHeight / 2,
222− indicatorItemCoordFirst.x, panel.panelHeight * 2,
321+ indicatorItemCoordFirst.x, panel.indicators.panelHeight / 2,
322+ indicatorItemCoordFirst.x, panel.indicators.panelHeight * 2,
223323 false /* beginTouch */, false /* endTouch */);
224324
225325 tryCompare(indicatorRow, "currentItem", indicatorItemFirst)
226326
227327 // 1) Flick mouse down to bottom
228328 touchFlick(panel,
229− indicatorItemCoordFirst.x, panel.panelHeight * 2,
329+ indicatorItemCoordFirst.x, panel.indicators.panelHeight * 2,
230330 indicatorItemCoordNext.x, panel.height,
231331 false /* beginTouch */, true /* endTouch */,
232332 units.gu(10) /* speed */, 30 /* iterations */); // more samples needed for accurate velocity