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
21
import "../../../Panel"
22
import Ubuntu.ChewieUI 0.1 as ChewieUI
25
This tests the Panel component using a fake model to stage data in the indicators
26
A view will show with indicators at the top, as does in the shell. This can be controlled
34
property bool search_clicked: false
38
onSearchClicked: search_clicked = true
50
function get_window_data() {
52
{tag: "pinned", fullscreenFlag: false },
53
{tag: "fullscreen", fullscreenFlag: true }
58
search_clicked = false;
59
panel.indicators.hide();
60
tryCompare(panel.indicators.hideAnimation, "running", false);
61
tryCompare(panel.indicators, "state", "initial");
64
function get_indicator_item(index) {
65
var row_repeater = findChild(panel.indicators, "rowRepeater");
66
verify(row_repeater != undefined)
67
return row_repeater.itemAt(index);
70
function get_indicator_item_position(index) {
72
var indicator_row = findChild(panel.indicators, "indicatorRow");
73
verify(indicator_row != undefined)
75
var indicator_item = get_indicator_item(index);
76
verify(indicator_item != undefined);
78
return panel.mapFromItem(indicator_item, indicator_item.width/2, indicator_item.height/2);
81
function test_hint_data() { return get_window_data() }
83
// Pressing on the indicator panel should activate the indicator hints
84
// and expose a portion of the conent.
85
function test_hint(data) {
86
panel.fullscreenMode = data.fullscreenFlag;
88
var indicator_item_coord = get_indicator_item_position(0);
89
var indicator_revealer = findChild(panel, "indicatorRevealer");
90
verify(indicator_revealer != undefined)
93
indicator_item_coord.x, panel.panelHeight/2,
94
Qt.LeftButton, Qt.NoModifier , 0);
96
if (!panel.fullscreenMode)
98
compare(indicator_revealer.hintingAnimation.running, true, "Indicator revealer hint animation should be running after mouse press on indicator panel in pinned mode");
99
tryCompare(indicator_revealer.hintingAnimation, "running", false);
100
tryCompare(panel.indicators, "partiallyOpened", true);
104
// nothing should happen
105
compare(indicator_revealer.hintingAnimation.running, false, "Indicator revealer hint animation should not be running after mouse press on indicator panel in fullscreen mode");
106
compare(panel.indicators.partiallyOpened, false, "Indicator should not be partially opened when panel is pressed in fullscreenmode");
107
compare(panel.indicators.fullyOpened, false, "Indicator should not be partially opened when panel is pressed in fullscreenmode");
111
indicator_item_coord.x, panel.panelHeight/2,
112
Qt.LeftButton, Qt.NoModifier , 0);
115
function test_show_click_data() { return get_window_data() }
117
// Clicking the indicator panel should fully open the inidicators
118
function test_show_click(data) {
119
panel.fullscreenMode = data.fullscreenFlag;
121
var indicator_item_coord = get_indicator_item_position(0);
124
indicator_item_coord.x, panel.panelHeight/2,
125
Qt.LeftButton, Qt.NoModifier , 0);
127
if (!panel.fullscreenMode)
129
compare(panel.indicators.showAnimation.running, true, "Show animation should run after panel is clicked in pinned mode.");
130
tryCompare(panel.indicators, "fullyOpened", true);
132
// click will activate device overview.
133
compare(findChild(panel.indicators, "indicatorRow").overviewActive, true, "Overview indicator should be avtive when indicators clicked.")
137
compare(panel.indicators.showAnimation.running, false, "Indicators should not open when panel is clicked in pinned mode.");
141
function test_show_press_release_data() { return get_window_data() }
143
// Pressing and releasing on the indicator panel will fully open the indicators
144
function test_show_press_release(data) {
145
panel.fullscreenMode = data.fullscreenFlag;
147
var indicator_item_coord = get_indicator_item_position(0);
150
indicator_item_coord.x, panel.panelHeight/2,
151
Qt.LeftButton, Qt.NoModifier , 0);
154
indicator_item_coord.x, panel.panelHeight/2,
155
Qt.LeftButton, Qt.NoModifier , 0);
157
if (!panel.fullscreenMode)
159
compare(panel.indicators.showAnimation.running, true, "Show animation should run after panel is clicked in pinned mode.");
160
tryCompare(panel.indicators, "fullyOpened", true);
164
// nothing should happen.
165
compare(panel.indicators.showAnimation.running, false, "Indicators should not open when panel is clicked in pinned mode.");
169
function test_drag_show_data() { return get_window_data() }
171
// Dragging from a indicator item in the panel will gradually expose the
172
// indicators, first by running the hint animation, then after dragging down will
173
// expose more of the panel, binding it to the selected indicator and opening it's menu.
174
function test_drag_show(data) {
175
panel.fullscreenMode = data.fullscreenFlag;
177
var indicator_revealer = findChild(panel, "indicatorRevealer");
178
verify(indicator_revealer != undefined)
180
var indicator_row = findChild(panel.indicators, "indicatorRow");
181
verify(indicator_row != undefined)
183
var row_repeater = findChild(panel.indicators, "rowRepeater");
184
verify(indicator_row != undefined)
186
var menu_content = findChild(panel.indicators, "menuContent");
187
verify(indicator_row != undefined)
189
// do this for each indicator item
190
for (var i = 0; i < row_repeater.count; i++) {
192
var indicator_item = get_indicator_item(i);
193
verify(indicator_item != undefined)
195
var indicator_item_coord = get_indicator_item_position(i);
197
// 1) Press on the panel
199
indicator_item_coord.x, panel.panelHeight/2,
200
Qt.LeftButton, Qt.NoModifier , 0);
202
if (!panel.fullscreenMode)
204
// hint animation should be run, and panel will end in partiallyOpened state.
205
compare(indicator_revealer.hintingAnimation.running, true, "Indicator revealer hint animation should be running after mouse press on indicator panel");
206
tryCompare(indicator_revealer.hintingAnimation, "running", false);
207
tryCompare(panel.indicators, "partiallyOpened", true);
210
// 2) Drag the mouse down
211
var old_progress = panel.indicators.progress
213
indicator_item_coord.x, old_progress + (panel.height - old_progress)/2,
216
// progress should increase.
217
var progress_increases = panel.indicators.progress > old_progress;
218
compare(progress_increases, true, "Progress has not increased on dragging indicator.");
221
indicator_item_coord.x, shell.y + shell.height,
224
tryCompare(panel.indicators, "fullyOpened", true);
227
indicator_item_coord.x, indicator_item_coord.y + panel.height/2,
228
Qt.LeftButton, Qt.NoModifier , 0);
230
compare(indicator_row.currentItem, indicator_item, "Incorrect item activated at position " + i);
231
compare(menu_content.__shown, true, "Menu conetent should be enabled for item at position " + i);
233
// init for next indicator_item
238
function test_search_click_when_visible() {
239
panel.fullscreenMode = false;
240
panel.searchVisible = true;
242
var search_indicator = findChild(panel, "search");
243
verify(search_indicator != undefined);
245
mouseClick(search_indicator,
247
Qt.LeftButton, Qt.NoModifier , 0);
249
compare(search_clicked, true, "Clicking search indicator while it was enabled did not emit searchClicked signal")
252
function test_search_click_when_not_visible() {
253
panel.fullscreenMode = false;
254
panel.searchVisible = false
256
var search_indicator = findChild(panel, "search");
257
verify(search_indicator != undefined);
259
mouseClick(search_indicator,
261
Qt.LeftButton, Qt.NoModifier , 0);
263
compare(search_clicked, false, "Clicking search indicator while it was not visible emitted searchClicked signal")