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 "../../../Dash/People"
21
import Ubuntu.Components 0.1
22
import Unity.Test 0.1 as UT
29
property bool helper: false
34
anchors.rightMargin: units.gu(20)
49
anchors { left: parent.left; right: parent.right }
50
onClicked: mockModel.clear();
53
model: testCase.test_click_items_data()
55
text: testCase.test_click_items_data()[index].tag
56
anchors { left: parent.left; right: parent.right }
57
onClicked: testCase.fillModel(testCase.test_click_items_data()[index]);
76
function fillModel(data) {
78
mockModel.append(data);
79
preview.model = mockModel.get(0);
83
function test_click_items_data() {
87
displayName: "Round Robin",
88
avatar: "../../graphics/clock.png",
90
statusTime: "1/6/2013 16:19:01",
91
statusServiceIcon: "../../../graphics/clock.png",
92
phoneNumbers: [{number:"123456", type: "voice", location: "Mars"}, {number: "654321"}],
93
emailAddresses: [{address:"robin@ntp.org"}, {address: "sirspamalot@foo.com"}],
94
imAccounts: [{address:"rr@jabber.org", protocol: "xmpp"}, {address: "sirspamalot@foo.com", protocol: "secret service messenger"}],
96
{street: "Middle of nowhere", poBox: 1, extension: "none", locality: "Mars", region: "all of it", postalCode: "٣٤٥٦", country: "There is only one on mars", addressFormat: "unreadable for you"},
97
{street: "Blue fin building"}
103
statusTime: "1/6/2013 16:19:01",
104
statusServiceIcon: "../../../graphics/clock.png",
108
phoneNumbers: [{number:"123456", type: "voice", location: "Mars"}],
111
tag: "Three Numbers",
112
phoneNumbers: [{number:"123456", type: "voice", location: "Mars"}, {number: "654321"}, {number: "666", type: "voice", location: "h3ll"}],
116
emailAddresses: [{address:"robin@ntp.org"}, {address: "sirspamalot@foo.com"}],
120
imAccounts: [{address:"rr@jabber.org", protocol: "xmpp"}, {address: "sirspamalot@foo.com", protocol: "secret service messenger"}],
125
{street: "Middle of nowhere", poBox: 1, extension: "none", locality: "Mars", region: "all of it", postalCode: "٣٤٥٦", country: "There is only one on mars", addressFormat: "unreadable for you"},
130
displayName: "Round Robin",
131
avatar: "../../graphics/clock.png",
132
phoneNumbers: [{number:"123456", type: "voice", location: "Mars"}],
133
emailAddresses: [{address:"robin@ntp.org"}],
135
{street: "Middle of nowhere", poBox: 1, extension: "none", locality: "Mars", region: "all of it", postalCode: "٣٤٥٦", country: "There is only one on mars", addressFormat: "unreadable for you"},
136
{street: "Blue fin building"}
141
displayName: "Round Robin",
142
avatar: "../../graphics/clock.png",
144
statusTime: "1/6/2013 16:19:01",
145
statusServiceIcon: "../../../graphics/clock.png",
146
phoneNumbers: [{number:"123456", type: "voice", location: "Mars"}],
147
emailAddresses: [{address:"robin@ntp.org"}],
149
{street: "Middle of nowhere", poBox: 1, extension: "none", locality: "Mars", region: "all of it", postalCode: "٣٤٥٦", country: "There is only one on mars", addressFormat: "unreadable for you"},
150
{street: "Blue fin building"}
156
function test_click_items(data) {
159
// Check if status field is visible
160
var field = findChild(preview, "statusField");
161
if (data.status != undefined) {
162
compare(field.visible, true, "status field is not visible");
165
compare(field.visible, false, "status field is visible while it should not");
168
// Check if there are phoneNumber.count phone fields
170
if (data.phoneNumbers != undefined) {
171
for (; i < data.phoneNumbers.length; ++i) {
172
var field = findChild(preview, "phoneField" + i);
173
verify(field != undefined);
174
verifyPhoneNumberClick(field);
178
// Check if there are no more phone fields
179
var field = findChild(preview, "phoneField" + i);
180
compare(field, undefined, "There is a phone number field too much!");
183
// Check if email adresses are here
185
if (data.emailAddresses != undefined) {
186
for (; i < data.emailAddresses.length; ++i) {
187
var field = findChild(preview, "emailField" + i);
188
verify(field != undefined);
193
// Check if there are no more email fields
194
var field = findChild(preview, "emailField" + i);
195
compare(field, undefined, "There is a email field too much!");
198
// Check if IM accounts are here
200
if (data.imAccounts != undefined) {
201
for (; i < data.imAccounts.length; ++i) {
202
var field = findChild(preview, "imField" + i);
203
verify(field != undefined);
208
// Check if there are no more IM fields
209
var field = findChild(preview, "imField" + i);
210
compare(field, undefined, "There is a IM field too much!");
212
// Check if email adresses are here
214
if (data.addresses != undefined) {
215
for (; i < data.addresses.length; ++i) {
216
var field = findChild(preview, "addressField" + i);
217
verify(field != undefined);
222
// Check if there are no more fields fields
223
var field = findChild(preview, "addressField" + i);
224
compare(field, undefined, "There is an address field too much!");
227
function verifyClick(field) {
228
waitForRendering(field)
229
clickSpy.signalName = "" // Get rid of a warning if new target doesn't support previous signal name
230
clickSpy.target = field;
232
clickSpy.signalName = "clicked";
233
compare(clickSpy.count, 0, "Could not reset signal spy");
234
mouseClick(field, field.width / 2, field.height / 2);
235
compare(clickSpy.count, 1, "Could not click on field " + field);
238
function verifyPhoneNumberClick(field) {
239
waitForRendering(field)
240
clickSpy.target = field;
242
clickSpy.signalName = "phoneClicked";
243
compare(clickSpy.count, 0, "Could not reset signal spy");
244
mouseClick(field, 1 , field.height / 2);
245
compare(clickSpy.count, 1, "Could not click on phone field");
248
clickSpy.signalName = "textClicked";
249
compare(clickSpy.count, 0, "Could not reset signal spy");
250
mouseClick(field, field.width - 1 , field.height / 2);
251
compare(clickSpy.count, 1, "Could not click on Message field");