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/>.
16
* Authored by Nick Dedekind <nick.dedekind@canonical.com>
21
import Ubuntu.Test 0.1
22
import Ubuntu.Components 0.1
23
import Ubuntu.Settings.Menus 0.1
24
import "../utils.js" as UtilsJS
34
contentWidth: column.width
35
contentHeight: column.height
40
width: flickable.width
41
height: childrenRect.height
49
message: "I am a little teapot"
53
id: messageMenuRemovable
55
anchors.top: messageMenu.bottom
59
id: messageMenuSelected
61
anchors.top: messageMenuRemovable.bottom
64
textMessageReply = value;
70
property string textMessageReply: ""
73
id: signalSpyActivateApp
74
signalName: "appActivated"
75
target: messageMenuSelected
80
signalName: "dismissed"
81
target: messageMenuRemovable
87
target: messageMenuSelected
91
name: "TextMessageMenu"
95
signalSpyActivateApp.clear();
96
signalSpyDismiss.clear();
97
signalSpyReply.clear();
98
textMessageReply = "";
100
messageMenu.replyEnabled = true;
101
messageMenuSelected.selected = false;
104
function test_title_data() {
111
function test_title(data) {
112
messageMenu.title = data.title;
114
var title = UtilsJS.findChild(messageMenu, "title");
115
verify(title, "No title");
116
compare(title.text, data.title, "Title does not match set title.");
119
function test_time_data() {
126
function test_time(data) {
127
messageMenu.time = data.time;
129
var subtitle = UtilsJS.findChild(messageMenu, "subtitle");
130
verify(subtitle !== undefined, "No subtitle");
131
compare(subtitle.text, data.time, "Time does not match set time.");
134
function test_appIcon_data() {
136
{ appIcon: Qt.resolvedUrl("../../artwork/avatar.png") },
137
{ appIcon: Qt.resolvedUrl("../../artwork/rhythmbox.png") },
141
function test_appIcon(data) {
142
messageMenu.appIcon = data.appIcon;
144
var appIcon = UtilsJS.findChild(messageMenu, "appIcon");
145
verify(appIcon !== undefined, "No app icon");
146
compare(appIcon.source, data.appIcon, "App Icon does not match set icon.");
149
function test_message_data() {
151
{ message: "This is a test." },
152
{ message: "Test is also a test." },
156
function test_message(data) {
157
messageMenu.message = data.message;
159
var body = UtilsJS.findChild(messageMenu, "body");
160
verify(body !== undefined, "No body");
161
compare(body.text, data.message, "Message does not match set message.");
164
function test_replyButtonText_data() {
166
{ buttonText: "Send" },
167
{ buttonText: "reply" },
171
function test_replyButtonText(data) {
172
messageMenu.replyButtonText = data.buttonText;
174
var button = UtilsJS.findChild(messageMenu, "sendButton");
175
verify(button !== undefined, "No send button");
176
compare(button.text, data.buttonText, "Button text does not match set text.");
179
function test_activateApp() {
180
var appIcon = UtilsJS.findChild(messageMenuSelected, "appIcon");
182
mouseClick(appIcon, appIcon.width * 2, appIcon.height / 2, Qt.LeftButton, Qt.NoModifier, 0);
183
compare(signalSpyActivateApp.count, 0, "activate app should not have been triggered");
185
messageMenuSelected.selected = false;
186
mouseClick(appIcon, appIcon.width / 2, appIcon.height / 2, Qt.LeftButton, Qt.NoModifier, 0);
187
compare(signalSpyActivateApp.count, 0, "activate app should not have been triggered when not selected");
189
messageMenuSelected.selected = true;
190
mouseClick(appIcon, appIcon.width / 2, appIcon.height / 2, Qt.LeftButton, Qt.NoModifier, 0);
191
compare(signalSpyActivateApp.count > 0, true, "activate app should have been triggered when selected");
194
function test_dismiss() {
195
mouseFlick(messageMenuRemovable,
196
messageMenuRemovable.width / 2,
197
messageMenuRemovable.height / 2,
198
messageMenuRemovable.width,
199
messageMenuRemovable.height / 2,
200
true, true, units.gu(1), 10);
201
tryCompare(function() { return signalSpyDismiss.count > 0; }, true);
204
function test_replyEnabled_data() {
206
{ tag: 'disabledNoReply', enabled: false, reply: "", expected: false},
207
{ tag: 'enabledNoReply', enabled: true, reply: "", expected: false},
208
{ tag: 'disabledWithReply', enabled: false, reply: "test", expected: false},
209
{ tag: 'enabledWithReply', enabled: true, reply: "test", expected: true},
213
function test_replyEnabled(data) {
214
messageMenuSelected.selected = true;
215
messageMenuSelected.replyEnabled = data.enabled
217
var replyText = UtilsJS.findChild(messageMenuSelected, "replyText");
218
verify(replyText !== undefined, "Reply text not found");
220
var sendButton = UtilsJS.findChild(messageMenuSelected, "sendButton");
221
verify(sendButton !== undefined, "Send button not found");
223
replyText.text = data.reply;
225
compare(sendButton.enabled, data.expected, "Reply button is not in correct state");
228
function test_reply() {
229
messageMenuSelected.selected = true;
230
messageMenuSelected.replyEnabled = true;
232
var replyText = UtilsJS.findChild(messageMenuSelected, "replyText");
233
verify(replyText !== undefined, "Reply text not found");
234
replyText.text = "reply1";
236
var sendButton = UtilsJS.findChild(messageMenuSelected, "sendButton");
237
verify(sendButton !== undefined, "Send button not found");
239
mouseClick(sendButton, sendButton.width / 2, sendButton.height / 2, Qt.LeftButton, Qt.NoModifier, 0);
240
compare(signalSpyReply.count > 0, true);
241
compare(textMessageReply, "reply1", "Text message did not reply with correct text.");