@@ -1,337 +0,0 @@
2− * Copyright 2013 Canonical Ltd.
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
19−import Unity.Test 0.1 as UT
20−import Ubuntu.Components 0.1 as UC
21−import Ubuntu.Telephony 0.1 as Telephony
23−import "../../../qml/Panel"
26− This tests the Panel component using a fake model to stage data in the indicators
27− A view will show with indicators at the top, as does in the shell. This can be controlled
41− height: parent.height - row.height
42− fullscreenMode: false
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"
121− panel.indicators.initialise();
122− panel.fullscreenMode = false;
124− panel.indicators.hide();
125− // Wait for animation to complete
126− tryCompare(panel.indicators.hideAnimation, "running", false);
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);
135− function get_indicator_item(index) {
136− var indicatorRow = findChild(panel.indicators, "indicatorRow");
137− verify(indicatorRow !== null);
139− return findChild(indicatorRow.row, "item" + index);
142− function get_indicator_item_position(index) {
143− var indicatorRow = findChild(panel.indicators, "indicatorRow");
144− verify(indicatorRow !== null);
146− var indicatorItem = get_indicator_item(index);
147− verify(indicatorItem !== null);
149− return panel.mapFromItem(indicatorItem, indicatorItem.width/2, indicatorItem.height/2);
152− // Pressing on the indicator panel should activate the indicator hints
153− // and expose a portion of the conent.
154− function test_hint() {
155− var indicatorItemCoord = get_indicator_item_position(0);
157− touchPress(panel, indicatorItemCoord.x, panel.indicators.panelHeight / 2);
159− // hint animation should be run, meaning that indicators will move downwards
160− // by hintValue pixels without any drag taking place
161− tryCompareFunction(function() { return panel.indicators.height },
162− panel.indicators.panelHeight + panel.indicators.hintValue);
163− tryCompare(panel.indicators, "partiallyOpened", true);
164− tryCompare(panel.indicators, "fullyOpened", false);
166− touchRelease(panel, indicatorItemCoord.x, panel.indicators.panelHeight/2);
169− // Pressing on the top edge of the screen should have no effect if the panel
170− // is hidden (fullscreen), which is the case when a fullscreen app is being shown
171− function test_noHintOnFullscreenMode() {
172− panel.fullscreenMode = true;
173− // Wait for the indicators to get into position.
174− // (switches between normal and fullscreen modes are animated)
175− var indicatorArea = findChild(panel, "indicatorArea");
176− tryCompare(indicatorArea, "y", -panel.panelHeight);
178− var indicatorItemCoord = get_indicator_item_position(0);
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);
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);
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 }
234− // Dragging from a indicator item in the panel will gradually expose the
235− // indicators, first by running the hint animation, then after dragging down will
236− // expose more of the panel, binding it to the selected indicator and opening it's menu.
237− function test_drag_show(data) {
238− panel.fullscreenMode = data.fullscreenFlag;
239− callManager.foregroundCall = data.call;
241− if (data.alreadyOpen) {
242− panel.indicators.show();
243− tryCompare(panel.indicators, "fullyOpened", true);
246− var indicatorRow = findChild(panel.indicators, "indicatorRow");
247− verify(indicatorRow !== null);
249− var menuContent = findChild(panel.indicators, "menuContent");
250− verify(menuContent !== null);
252− var indicatorArea = findChild(panel, "indicatorArea");
253− verify(indicatorArea !== null);
255− // Wait for the indicators to get into position.
256− // (switches between normal and fullscreen modes are animated)
257− tryCompareFunction(function() { return indicatorArea.y }, data.indicatorY);
259− // do this for each indicator item
260− for (var i = 0; i < indicatorRow.row.count; i++) {
262− var indicatorItem = get_indicator_item(i);
263− verify(indicatorItem !== null);
265− if (!indicatorItem.visible)
268− var indicatorItemCoord = get_indicator_item_position(i);
271− indicatorItemCoord.x, panel.indicators.panelHeight / 2);
273− // 1) Drag the mouse down
275− indicatorItemCoord.x, panel.indicators.panelHeight / 2,
276− indicatorItemCoord.x, panel.height,
277− false /* beginTouch */, false /* endTouch */);
279− // Indicators height should follow the drag, and therefore increase accordingly.
280− // They should be at least half-way through the screen
282− function() {return panel.indicators.height >= panel.height * 0.5},
285− touchRelease(panel, indicatorItemCoord.x, panel.height);
287− compare(indicatorRow.currentItem, indicatorItem,
288− "Incorrect item activated at position " + i);
289− compare(menuContent.currentMenuIndex, i, "Menu conetent should be enabled for item at position " + i);
291− // init for next indicatorItem
292− if (!data.alreadyOpen) {
293− panel.indicators.hide();
294− tryCompare(panel.indicators.hideAnimation, "running", false);
295− tryCompare(panel.indicators, "state", "initial");
300− // Test the vertical velocity check when flicking the indicators open at an angle.
301− // If the vertical velocity is above a specific point, we shouldnt change active indicators
302− // if the x position changes
303− function test_vertical_velocity_detector() {
304− panel.fullscreenMode = false;
306− var indicatorRow = findChild(panel.indicators, "indicatorRow");
307− verify(indicatorRow !== null);
309− // Get the first indicator
310− var indicatorItemFirst = get_indicator_item(0);
311− verify(indicatorItemFirst !== null);
313− var indicatorItemCoordFirst = get_indicator_item_position(0);
314− var indicatorItemCoordNext = get_indicator_item_position(indicatorRow.row.count - 1);
317− indicatorItemCoordFirst.x, panel.indicators.panelHeight / 2);
319− // 1) Drag the mouse down to hint a bit
321− indicatorItemCoordFirst.x, panel.indicators.panelHeight / 2,
322− indicatorItemCoordFirst.x, panel.indicators.panelHeight * 2,
323− false /* beginTouch */, false /* endTouch */);
325− tryCompare(indicatorRow, "currentItem", indicatorItemFirst)
327− // 1) Flick mouse down to bottom
329− indicatorItemCoordFirst.x, panel.indicators.panelHeight * 2,
330− indicatorItemCoordNext.x, panel.height,
331− false /* beginTouch */, true /* endTouch */,
332− units.gu(10) /* speed */, 30 /* iterations */); // more samples needed for accurate velocity
334− compare(indicatorRow.currentItem, indicatorItemFirst, "First indicator should still be the current item");