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/>.
20
import "../../../Panel/Menus"
21
import "../../../Components"
22
import Unity.Test 0.1 as UT
33
indicatorsModel: mockModel
41
volume = Math.min(100, volume + 10);
43
function volumeDown() {
44
volume = Math.max(0, volume - 10);
50
ListElement {title: "foo"; label: "foo"; iconSource: "graphics/sound_on_icon.png"}
51
ListElement {title: "bar"; label: ""; iconSource: "graphics/sound_on_icon.png"}
52
ListElement {title: "baz"; label: "baz"; iconSource: "graphics/sound_on_icon.png"}
62
signalName: "menuSelected"
69
function initTestCase() {
70
// Spin the event loop once because the UI builds up delayed
74
function test_menuSelected() {
75
overview.indicatorsModel = mockModel;
77
for (var i = 0; i < mockModel.count; ++i) {
78
var button = findChild(overview, "overviewGridButton" + i);
80
mouseClick(button, button.width / 2, button.height / 2);
81
compare(clickSpy.count, 1, "Clicking on grid didn't work");
82
compare(clickSpy.signalArguments[0][0], i, "Clicking the grid returned a wrong index");
86
function test_dynamic_addition() {
87
var overviewGrid = findChild(overview, "overviewGrid");
89
for(var i = 0; i < mockModel.count; ++i) {
90
mockModel2.append(mockModel.get(i));
92
overview.indicatorsModel = mockModel2;
93
overviewGrid.forceLayout();
94
waitForRendering(overviewGrid);
96
var button = findChild(overview, "overviewGridButton2");
97
verify(button !== undefined, "button2 wasn't found");
98
button = findChild(overview, "overviewGridButton3");
99
compare(button, undefined, "There should only be 3 buttons... found at least 4...");
101
mockModel2.append({title: "humppa", label: "", iconSource: "graphics/sound_on_icon.png"})
102
overviewGrid.forceLayout();
103
waitForRendering(overviewGrid);
105
button = findChild(overview, "overviewGridButton3");
106
verify(button !== undefined, "button3 wasn't found");
109
function test_text_or_icon_data() {
111
{tag: "text", index: 0, imageVisible: false},
112
{tag: "image", index: 1, imageVisible: true}
116
function test_text_or_icon(data) {
117
var button = findChild(overview, "overviewGridButton" + data.index);
118
var image = findChild(button, "overviewGridButtonImage");
119
compare(image.visible, data.imageVisible)
122
function test_volume_slider_data() {
124
{tag: "0%", sliderPos:0},
125
{tag: "100%", sliderPos: 100},
126
{tag: "50%", sliderPos: 50}
130
function test_volume_slider(data) {
131
var volumeSlider = findChild(overview, "volumeSlider");
132
var startX = volumeSlider.width * volumeSlider.value / 100;
133
var startY = volumeSlider.y + volumeSlider.height / 2;
134
var stopX = (volumeSlider.width - units.gu(5)) * data.sliderPos / 100;
135
var stopY = volumeSlider.y + volumeSlider.height / 2;
136
mouseFlick(volumeSlider, startX, startY, stopX, stopY, true, true, 0.1);
139
function test_volume_buttons(data) {
140
var volumeDownButton = findChild(overview, "minVolumeIcon");
141
var volumeUpButton = findChild(overview, "maxVolumeIcon");
143
for (var i = 0; i < 10; ++i) {
144
mouseClick(volumeDownButton, volumeDownButton.width / 2, volumeDownButton.height / 2);
147
tryCompare(volumeControl, "volume", 0);
148
for (var i = 0; i < 10; ++i) {
149
mouseClick(volumeUpButton, 1, 1);