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 Lesser 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 Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
import Ubuntu.Test 0.1
20
import Ubuntu.Components 0.1
21
import Ubuntu.Components.Pickers 0.1
34
delegate: PickerDelegate {
35
Label {text: modelData}
43
delegate: PickerDelegate {
44
Label {text: modelData}
49
objectName: "objectModelled"
55
objectName: "simpleModelled"
114
function test_0_circular() {
115
compare(picker.circular, true, "default circular");
117
function test_0_model() {
118
compare(picker.model, undefined, "default model");
120
function test_0_delegate() {
121
compare(picker.delegate, null, "default delegate");
123
function test_0_selectedIndex() {
124
compare(picker.selectedIndex, 0, "default selectedIndex");
127
function test_1_runtimeModel() {
128
picker.model = emptyModel;
129
compare(picker.selectedIndex, 0, "selectedIndex gets 0");
132
function test_1_selectedIndexForEmptyModel() {
133
compare(simpleModelled.selectedIndex, 2, "empty modelled picker selectedIndex is 0");
136
function test_1_selectedIndexForObjectModel() {
137
compare(objectModelled.selectedIndex, 2, "model containing data, picker.selectedIndex");
140
function test_2_updateModel() {
141
picker.selectedIndex = 1;
143
spy.signalName = "onSelectedIndexChanged";
146
tryCompare(spy, "count", 1);
149
function test_2_updateModel2() {
150
objectModelled.selectedIndex = 1;
152
spy.signalName = "onSelectedIndexChanged";
153
spy.target = objectModelled;
154
objectModelled.model = [];
155
tryCompare(spy, "count", 1);
158
function test_4_clickMovesSelection_Long() {
160
spy.signalName = "onSelectedIndexChanged";
161
spy.target = linearLong;
162
mouseClick(linearLong, units.gu(1), units.gu(1));
163
tryCompare(spy, "count", 0);
164
mouseClick(linearLong, units.gu(1), units.gu(18));
165
tryCompare(spy, "count", 1);
168
function test_3_clickMovesSelection_Short() {
170
spy.signalName = "onSelectedIndexChanged";
171
spy.target = linearShort;
172
mouseClick(linearShort, units.gu(1), units.gu(1));
173
tryCompare(spy, "count", 0);
174
mouseClick(linearShort, units.gu(1), units.gu(18));
175
tryCompare(spy, "count", 1);
178
function test_5_clickMovesSelection_Long() {
180
spy.signalName = "onSelectedIndexChanged";
181
linearLong.circular = true;
183
spy.target = linearLong;
184
mouseClick(linearLong, units.gu(1), units.gu(1));
185
tryCompare(spy, "count", 1);
186
mouseClick(linearLong, units.gu(1), units.gu(18));
187
tryCompare(spy, "count", 2);