@@ -17,6 +17,7 @@
1717import QtQuick 2.0
1818import QtTest 1.0
1919import Unity.Test 0.1 as UT
20+import Ubuntu.Telephony 0.1 as Telephony
2021import ".."
2122import "../../../qml/Panel"
2223
@@ -40,26 +41,23 @@ Item {
4041 Panel {
4142 id: panel
4243 anchors.fill: parent
43− fullscreenMode: true
44+ fullscreenMode: false
4445
4546 indicators {
4647 profile: "test1"
48+ panelHeight: units.gu(5)
4749 }
4850 }
4951
52+ Telephony.CallEntry {
53+ id: phoneCall
54+ phoneNumber: "+447812221111"
55+ }
56+
5057 UT.UnityTestCase {
5158 name: "Panel"
5259 when: windowShown
5360
54− function get_window_data() {
55− return [
56− {tag: "pinned", fullscreenFlag: false, alreadyOpen: false },
57− {tag: "fullscreen", fullscreenFlag: true, alreadyOpen: false },
58− {tag: "pinned-alreadyOpen", fullscreenFlag: false, alreadyOpen: true },
59− {tag: "fullscreen-alreadyOpen", fullscreenFlag: true, alreadyOpen: true }
60− ];
61− }
62−
6361 function init() {
6462 panel.indicators.initialise();
6563
@@ -67,6 +65,7 @@ Item {
6765 panel.indicators.hide();
6866 tryCompare(panel.indicators.hideAnimation, "running", false);
6967 tryCompare(panel.indicators, "state", "initial");
68+ callManager.foregroundCall = null;
7069 }
7170
7271 function get_indicator_item(index) {
@@ -114,7 +113,8 @@ Item {
114113 panel.fullscreenMode = true;
115114 // Wait for the indicators to get into position.
116115 // (switches between normal and fullscreen modes are animated)
117− tryCompare(panel.indicators, "y", -panel.panelHeight);
116+ var indicatorArea = findChild(panel, "indicatorArea");
117+ tryCompare(indicatorArea, "y", -panel.panelHeight);
118118
119119 var indicatorItemCoord = get_indicator_item_position(0);
120120
@@ -124,7 +124,7 @@ Item {
124124 wait(500);
125125
126126 // no hint animation when fullscreen
127− compare(panel.indicators.y, -panel.panelHeight);
127+ compare(indicatorArea.y, -panel.panelHeight);
128128 var indicatorRow = findChild(panel.indicators, "indicatorRow");
129129 verify(indicatorRow !== null);
130130 compare(indicatorRow.y, 0);
@@ -138,34 +138,48 @@ Item {
138138 touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
139139 }
140140
141− function test_drag_show_data() { return get_window_data(); }
141+ function test_drag_show_data() {
142+ return [
143+ { tag: "pinned", fullscreenFlag: false, alreadyOpen: false, call: null,
144+ indicatorY: function() { return 0 } },
145+ { tag: "fullscreen", fullscreenFlag: true, alreadyOpen: false, call: null,
146+ indicatorY: function() {return -panel.panelHeight } },
147+ { tag: "pinned-alreadyOpen", fullscreenFlag: false, alreadyOpen: true, call: null,
148+ indicatorY: function() { return 0 } },
149+ { tag: "fullscreen-alreadyOpen", fullscreenFlag: true, alreadyOpen: true, call: null,
150+ indicatorY: function() {return -panel.panelHeight } },
151+ { tag: "pinned-callActive", fullscreenFlag: false, alreadyOpen: false, call: phoneCall,
152+ indicatorY: function() { return units.gu(3) } },
153+ { tag: "fullscreen-callActive", fullscreenFlag: true, alreadyOpen: false, call: phoneCall,
154+ indicatorY: function() {return units.gu(3) - (panel.panelHeight - units.gu(3)) } }
155+ ];
156+ }
142157
143158 // Dragging from a indicator item in the panel will gradually expose the
144159 // indicators, first by running the hint animation, then after dragging down will
145160 // expose more of the panel, binding it to the selected indicator and opening it's menu.
146161 function test_drag_show(data) {
147162 panel.fullscreenMode = data.fullscreenFlag;
163+
164+ callManager.foregroundCall = data.call;
165+
148166 if (data.alreadyOpen) {
149167 panel.indicators.show();
150168 tryCompare(panel.indicators, "fullyOpened", true);
151169 }
152170
153− var indicatorRow = findChild(panel.indicators, "indicatorRow");
171+ var indicatorRow = findChild(panel.indicators, "indicatorRow");
154172 verify(indicatorRow !== null);
155173
156174 var menuContent = findChild(panel.indicators, "menuContent");
157− verify(indicatorRow !== null);
175+ verify(menuContent !== null);
158176
159− var menuContent = findChild(panel.indicators, "menuContent");
160− verify(indicatorRow !== null);
177+ var indicatorArea = findChild(panel, "indicatorArea");
178+ verify(indicatorArea !== null);
161179
162180 // Wait for the indicators to get into position.
163181 // (switches between normal and fullscreen modes are animated)
164− if (data.fullscreenFlag) {
165− tryCompare(panel.indicators, "y", -panel.panelHeight);
166− } else {
167− tryCompare(panel.indicators, "y", 0);
168− }
182+ tryCompare(indicatorArea, "y", data.indicatorY());
169183
170184 // do this for each indicator item
171185 for (var i = 0; i < indicatorRow.row.count; i++) {
@@ -184,7 +198,7 @@ Item {
184198 // 1) Drag the mouse down
185199 touchFlick(panel,
186200 indicatorItemCoord.x, panel.panelHeight / 2,
187− indicatorItemCoord.x, panel.height * 0.8,
201+ indicatorItemCoord.x, panel.height,
188202 false /* beginTouch */, false /* endTouch */);
189203
190204 // Indicators height should follow the drag, and therefore increase accordingly.
@@ -193,7 +207,7 @@ Item {
193207 function() {return panel.indicators.height >= panel.height * 0.5},
194208 true);
195209
196− touchRelease(panel, indicatorItemCoord.x, panel.height * 0.8);
210+ touchRelease(panel, indicatorItemCoord.x, panel.height);
197211
198212 compare(indicatorRow.currentItem, indicatorItem,
199213 "Incorrect item activated at position " + i);
@@ -201,7 +215,9 @@ Item {
201215
202216 // init for next indicatorItem
203217 if (!data.alreadyOpen) {
204− init();
218+ panel.indicators.hide();
219+ tryCompare(panel.indicators.hideAnimation, "running", false);
220+ tryCompare(panel.indicators, "state", "initial");
205221 }
206222 }
207223 }