Merge lp:~tiagosh/messaging-app/fix-sections-dualsim into lp:messaging-app
- fix-sections-dualsim
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Gustavo Pichorim Boiko | ||||
Approved revision: | 555 | ||||
Merged at revision: | 554 | ||||
Proposed branch: | lp:~tiagosh/messaging-app/fix-sections-dualsim | ||||
Merge into: | lp:messaging-app | ||||
Diff against target: |
413 lines (+270/-13) 7 files modified
src/qml/EmptyState.qml (+18/-0) src/qml/InputInfo.qml (+18/-0) src/qml/Messages.qml (+25/-9) src/qml/MessagingBottomEdge.qml (+18/-0) src/qml/MessagingPageLayout.qml (+18/-0) tests/qml/CMakeLists.txt (+9/-4) tests/qml/tst_DualSim.qml (+164/-0) |
||||
To merge this branch: | bzr merge lp:~tiagosh/messaging-app/fix-sections-dualsim | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gustavo Pichorim Boiko (community) | Approve | ||
PS Jenkins bot | continuous-integration | Needs Fixing | |
Review via email: mp+293331@code.launchpad.net |
Commit message
Do not use bindings on sections model to avoid the index getting reset.
Description of the change
Do not use bindings on sections model to avoid the index getting reset.
PS Jenkins bot (ps-jenkins) wrote : | # |
- 552. By Tiago Salem Herrmann
-
add qml test
- 553. By Tiago Salem Herrmann
-
add missing copyright headers
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:552
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:553
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 554. By Tiago Salem Herrmann
-
dismiss swipe demo if displayed
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:554
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 555. By Tiago Salem Herrmann
-
fix tests
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:555
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Gustavo Pichorim Boiko (boiko) wrote : | # |
Looks good!
Preview Diff
1 | === modified file 'src/qml/EmptyState.qml' |
2 | --- src/qml/EmptyState.qml 2016-01-15 19:56:29 +0000 |
3 | +++ src/qml/EmptyState.qml 2016-05-02 22:45:26 +0000 |
4 | @@ -1,3 +1,21 @@ |
5 | +/* |
6 | + * Copyright 2016 Canonical Ltd. |
7 | + * |
8 | + * This file is part of messaging-app. |
9 | + * |
10 | + * messaging-app is free software; you can redistribute it and/or modify |
11 | + * it under the terms of the GNU General Public License as published by |
12 | + * the Free Software Foundation; version 3. |
13 | + * |
14 | + * messaging-app is distributed in the hope that it will be useful, |
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | + * GNU General Public License for more details. |
18 | + * |
19 | + * You should have received a copy of the GNU General Public License |
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
21 | + */ |
22 | + |
23 | import QtQuick 2.0 |
24 | import Ubuntu.Components 1.3 |
25 | |
26 | |
27 | === modified file 'src/qml/InputInfo.qml' |
28 | --- src/qml/InputInfo.qml 2016-01-21 20:25:20 +0000 |
29 | +++ src/qml/InputInfo.qml 2016-05-02 22:45:26 +0000 |
30 | @@ -1,3 +1,21 @@ |
31 | +/* |
32 | + * Copyright 2016 Canonical Ltd. |
33 | + * |
34 | + * This file is part of messaging-app. |
35 | + * |
36 | + * messaging-app is free software; you can redistribute it and/or modify |
37 | + * it under the terms of the GNU General Public License as published by |
38 | + * the Free Software Foundation; version 3. |
39 | + * |
40 | + * messaging-app is distributed in the hope that it will be useful, |
41 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
42 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
43 | + * GNU General Public License for more details. |
44 | + * |
45 | + * You should have received a copy of the GNU General Public License |
46 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
47 | + */ |
48 | + |
49 | import QtQuick 2.0 |
50 | //import Unity.InputInfo 0.1 |
51 | |
52 | |
53 | === modified file 'src/qml/Messages.qml' |
54 | --- src/qml/Messages.qml 2016-03-17 21:10:15 +0000 |
55 | +++ src/qml/Messages.qml 2016-05-02 22:45:26 +0000 |
56 | @@ -67,6 +67,7 @@ |
57 | property string firstRecipientAlias: ((contactWatcher.isUnknown && |
58 | contactWatcher.isInteractive) || |
59 | contactWatcher.alias === "") ? contactWatcher.identifier : contactWatcher.alias |
60 | + property bool newMessage: false |
61 | |
62 | // When using this view from the bottom edge, we are not in the stack, so we need to push on top of the parent page |
63 | property var basePage: messages |
64 | @@ -76,10 +77,16 @@ |
65 | signal ready |
66 | signal cancel |
67 | |
68 | + function restoreBindings() { |
69 | + messages.account = Qt.binding(getCurrentAccount) |
70 | + messages.phoneAccount = Qt.binding(isPhoneAccount) |
71 | + headerSections.selectedIndex = Qt.binding(getSelectedIndex) |
72 | + } |
73 | + |
74 | function getAccountsModel() { |
75 | var accounts = [] |
76 | // on new chat dialogs display all possible accounts |
77 | - if (accountId == "" && participants.length === 0) { |
78 | + if (newMessage) { |
79 | for (var i in telepathyHelper.activeAccounts) { |
80 | accounts.push(telepathyHelper.activeAccounts[i]) |
81 | } |
82 | @@ -123,7 +130,7 @@ |
83 | } |
84 | |
85 | function getSelectedIndex() { |
86 | - if (accountId == "" && participants.length === 0) { |
87 | + if (newMessage) { |
88 | // if this is a new message, just pre select the the |
89 | // default phone account for messages if available |
90 | if (multiplePhoneAccounts && telepathyHelper.defaultMessagingAccount) { |
91 | @@ -339,7 +346,7 @@ |
92 | } |
93 | eventModel.writeEvents([event]); |
94 | } else { |
95 | - var isMmsGroupChat = participants.length > 1 && telepathyHelper.mmsGroupChat && messages.account.type == AccountEntry.PhoneAccount |
96 | + var isMmsGroupChat = participantIds.length > 1 && telepathyHelper.mmsGroupChat && messages.account.type == AccountEntry.PhoneAccount |
97 | // mms group chat only works if we know our own phone number |
98 | var isSelfContactKnown = account.selfContactId != "" |
99 | if (isMmsGroupChat && !isSelfContactKnown) { |
100 | @@ -354,6 +361,14 @@ |
101 | } |
102 | } |
103 | |
104 | + if (newMessage) { |
105 | + newMessage = false |
106 | + var currentIndex = headerSections.selectedIndex |
107 | + headerSections.model = getSectionsModel() |
108 | + restoreBindings() |
109 | + headerSections.selectedIndex = currentIndex |
110 | + } |
111 | + |
112 | // FIXME: soon it won't be just about SIM cards, so the dialogs need updating |
113 | if (multiplePhoneAccounts && !telepathyHelper.defaultMessagingAccount && !settings.messagesDontAsk && account.type == AccountEntry.PhoneAccount) { |
114 | Qt.inputMethod.hide() |
115 | @@ -491,6 +506,8 @@ |
116 | messages.account = messages.accountsModel[selectedIndex] |
117 | } |
118 | } |
119 | + // force break the binding, so the index doesn't get reset |
120 | + Component.onCompleted: model = getSectionsModel() |
121 | } |
122 | |
123 | extension: headerSections.model.length > 1 ? headerSections : null |
124 | @@ -635,7 +652,7 @@ |
125 | // NOTE: in case the state name is changed here, the bottom edge component needs |
126 | // to be updated too |
127 | name: "newMessage" |
128 | - when: participants.length === 0 |
129 | + when: messages.newMessage |
130 | |
131 | property list<QtObject> trailingActions: [ |
132 | Action { |
133 | @@ -722,6 +739,8 @@ |
134 | } |
135 | } |
136 | } |
137 | + newMessage = (messages.accountId == "" && messages.participants.length === 0) |
138 | + restoreBindings() |
139 | // if we add multiple attachments at the same time, it break the Repeater + Loaders |
140 | fillAttachmentsTimer.start() |
141 | } |
142 | @@ -759,10 +778,8 @@ |
143 | target: telepathyHelper |
144 | onSetupReady: { |
145 | // force reevaluation |
146 | - messages.account = Qt.binding(getCurrentAccount) |
147 | - messages.phoneAccount = Qt.binding(isPhoneAccount) |
148 | - headerSections.model = Qt.binding(getSectionsModel) |
149 | - headerSections.selectedIndex = Qt.binding(getSelectedIndex) |
150 | + headerSections.model = getSectionsModel() |
151 | + restoreBindings() |
152 | } |
153 | } |
154 | |
155 | @@ -1157,7 +1174,6 @@ |
156 | |
157 | if (messages.account && messages.accountId == "") { |
158 | messages.accountId = messages.account.accountId |
159 | - headerSections.selectedIndex = Qt.binding(getSelectedIndex) |
160 | } |
161 | |
162 | var newAttachments = [] |
163 | |
164 | === modified file 'src/qml/MessagingBottomEdge.qml' |
165 | --- src/qml/MessagingBottomEdge.qml 2016-02-25 23:43:42 +0000 |
166 | +++ src/qml/MessagingBottomEdge.qml 2016-05-02 22:45:26 +0000 |
167 | @@ -1,3 +1,21 @@ |
168 | +/* |
169 | + * Copyright 2016 Canonical Ltd. |
170 | + * |
171 | + * This file is part of messaging-app. |
172 | + * |
173 | + * messaging-app is free software; you can redistribute it and/or modify |
174 | + * it under the terms of the GNU General Public License as published by |
175 | + * the Free Software Foundation; version 3. |
176 | + * |
177 | + * messaging-app is distributed in the hope that it will be useful, |
178 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
179 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
180 | + * GNU General Public License for more details. |
181 | + * |
182 | + * You should have received a copy of the GNU General Public License |
183 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
184 | + */ |
185 | + |
186 | import QtQuick 2.0 |
187 | import Ubuntu.Components 1.3 |
188 | |
189 | |
190 | === modified file 'src/qml/MessagingPageLayout.qml' |
191 | --- src/qml/MessagingPageLayout.qml 2016-03-17 21:06:41 +0000 |
192 | +++ src/qml/MessagingPageLayout.qml 2016-05-02 22:45:26 +0000 |
193 | @@ -1,3 +1,21 @@ |
194 | +/* |
195 | + * Copyright 2016 Canonical Ltd. |
196 | + * |
197 | + * This file is part of messaging-app. |
198 | + * |
199 | + * messaging-app is free software; you can redistribute it and/or modify |
200 | + * it under the terms of the GNU General Public License as published by |
201 | + * the Free Software Foundation; version 3. |
202 | + * |
203 | + * messaging-app is distributed in the hope that it will be useful, |
204 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
205 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
206 | + * GNU General Public License for more details. |
207 | + * |
208 | + * You should have received a copy of the GNU General Public License |
209 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
210 | + */ |
211 | + |
212 | import QtQuick 2.0 |
213 | import Ubuntu.Components 1.3 |
214 | |
215 | |
216 | === modified file 'tests/qml/CMakeLists.txt' |
217 | --- tests/qml/CMakeLists.txt 2016-01-19 17:44:27 +0000 |
218 | +++ tests/qml/CMakeLists.txt 2016-05-02 22:45:26 +0000 |
219 | @@ -28,16 +28,21 @@ |
220 | add_executable(${TEST} ${SOURCES}) |
221 | qt5_use_modules(${TEST} Core Multimedia Qml Quick QuickTest Sql) |
222 | |
223 | +set(TEST_COMMAND ${XVFB_COMMAND} ${CMAKE_CURRENT_BINARY_DIR}/${TEST} |
224 | + -import ${CMAKE_BINARY_DIR}/src |
225 | + -import ${UNITY8_QML_PATH}) |
226 | + |
227 | include_directories( |
228 | ${messaging-app_SOURCE_DIR}/src |
229 | ${CMAKE_CURRENT_BINARY_DIR} |
230 | ${CMAKE_CURRENT_SOURCE_DIR} |
231 | ) |
232 | |
233 | -add_test(${TEST} ${XVFB_COMMAND} ${CMAKE_CURRENT_BINARY_DIR}/${TEST} |
234 | - -input ${CMAKE_CURRENT_SOURCE_DIR} |
235 | - -import ${CMAKE_BINARY_DIR}/src |
236 | - -import ${UNITY8_QML_PATH}) |
237 | +add_test(DualSim ${TEST_COMMAND} -input ${CMAKE_CURRENT_SOURCE_DIR}/tst_DualSim.qml) |
238 | +add_test(MessageBubble ${TEST_COMMAND} -input ${CMAKE_CURRENT_SOURCE_DIR}/tst_MessageBubble.qml) |
239 | +add_test(MessagesView ${TEST_COMMAND} -input ${CMAKE_CURRENT_SOURCE_DIR}/tst_MessagesView.qml) |
240 | +add_test(MMSDelegate ${TEST_COMMAND} -input ${CMAKE_CURRENT_SOURCE_DIR}/tst_MMSDelegate.qml) |
241 | +add_test(StickersHistoryModel ${TEST_COMMAND} -input ${CMAKE_CURRENT_SOURCE_DIR}/tst_StickersHistoryModel.qml) |
242 | |
243 | # make qml files visible in QtCreator |
244 | file(GLOB_RECURSE NON_COMPILED_FILES *.qml) |
245 | |
246 | === added file 'tests/qml/tst_DualSim.qml' |
247 | --- tests/qml/tst_DualSim.qml 1970-01-01 00:00:00 +0000 |
248 | +++ tests/qml/tst_DualSim.qml 2016-05-02 22:45:26 +0000 |
249 | @@ -0,0 +1,164 @@ |
250 | +/* |
251 | + * Copyright 2016 Canonical Ltd. |
252 | + * |
253 | + * This file is part of messaging-app. |
254 | + * |
255 | + * messaging-app is free software; you can redistribute it and/or modify |
256 | + * it under the terms of the GNU General Public License as published by |
257 | + * the Free Software Foundation; version 3. |
258 | + * |
259 | + * messaging-app is distributed in the hope that it will be useful, |
260 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
261 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
262 | + * GNU General Public License for more details. |
263 | + * |
264 | + * You should have received a copy of the GNU General Public License |
265 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
266 | + */ |
267 | + |
268 | +import QtQuick 2.2 |
269 | +import QtTest 1.0 |
270 | +import Ubuntu.Test 0.1 |
271 | +import Ubuntu.Telephony 0.1 |
272 | +import Ubuntu.History 0.1 |
273 | + |
274 | +Item { |
275 | + id: root |
276 | + |
277 | + width: units.gu(40) |
278 | + height: units.gu(70) |
279 | + |
280 | + |
281 | + Item { |
282 | + id: application |
283 | + function findMessagingChild(name) |
284 | + { |
285 | + return null |
286 | + } |
287 | + } |
288 | + |
289 | + QtObject { |
290 | + id: testAccount |
291 | + property string accountId: "ofono/ofono/account0" |
292 | + property var emergencyNumbers: [ "444", "555"] |
293 | + property int type: AccountEntry.PhoneAccount |
294 | + property string displayName: "SIM 1" |
295 | + property bool connected: true |
296 | + property bool emergencyCallsAvailable: true |
297 | + property bool active: true |
298 | + property string networkName: "Network name" |
299 | + property bool simLocked: false |
300 | + property var addressableVCardFields: ["tel"] |
301 | + } |
302 | + |
303 | + QtObject { |
304 | + id: testAccount2 |
305 | + property string accountId: "ofono/ofono/account1" |
306 | + property var emergencyNumbers: [ "444", "555"] |
307 | + property int type: AccountEntry.PhoneAccount |
308 | + property string displayName: "SIM 2" |
309 | + property bool connected: true |
310 | + property bool emergencyCallsAvailable: true |
311 | + property bool active: true |
312 | + property string networkName: "Network name 2" |
313 | + property bool simLocked: false |
314 | + property var addressableVCardFields: ["tel"] |
315 | + } |
316 | + |
317 | + Item { |
318 | + id: telepathyHelper |
319 | + property var activeAccounts: [testAccount, testAccount2] |
320 | + property alias accounts: telepathyHelper.activeAccounts |
321 | + property QtObject defaultMessagingAccount: testAccount2 |
322 | + function registerChannelObserver() {} |
323 | + function unregisterChannelObserver() {} |
324 | + function accountForId(accountId) { |
325 | + for (var i in accounts) { |
326 | + if (accounts[i].accountId == accountId) { |
327 | + return accounts[i] |
328 | + } |
329 | + } |
330 | + return null |
331 | + } |
332 | + } |
333 | + |
334 | + Item { |
335 | + id: chatManager |
336 | + signal messageSent(string accountId, var participantIds, string text, var attachments, var properties) |
337 | + function acknowledgeMessage(recipients, messageId, accountId) { |
338 | + chatManager.messageAcknowledged(recipients, messageId, accountId) |
339 | + } |
340 | + function sendMessage(accountId, participantIds, text, attachments, properties) { |
341 | + chatManager.messageSent(accountId, participantIds, text, attachments, properties) |
342 | + return accountId |
343 | + } |
344 | + function chatEntryForParticipants(accountId, participantIds) { |
345 | + return null |
346 | + } |
347 | + } |
348 | + |
349 | + Loader { |
350 | + id: mainViewLoader |
351 | + property string i18nDirectory: "" |
352 | + source: '../../src/qml/messaging-app.qml' |
353 | + } |
354 | + |
355 | + SignalSpy { |
356 | + id: messageSentSpy |
357 | + target: chatManager |
358 | + signalName: "messageSent" |
359 | + } |
360 | + |
361 | + UbuntuTestCase { |
362 | + id: dualSim |
363 | + name: 'dualSim' |
364 | + |
365 | + when: windowShown |
366 | + |
367 | + // we reimplement the function here and add a special |
368 | + // case to deal with a null child without failing |
369 | + function findChild(obj,objectName) { |
370 | + var childs = new Array(0); |
371 | + childs.push(obj) |
372 | + while (childs.length > 0) { |
373 | + // this is the special case |
374 | + if (!childs[0]) { |
375 | + childs.splice(0, 1); |
376 | + continue |
377 | + } |
378 | + if (childs[0].objectName == objectName) { |
379 | + return childs[0] |
380 | + } |
381 | + for (var i in childs[0].children) { |
382 | + childs.push(childs[0].children[i]) |
383 | + } |
384 | + childs.splice(0, 1); |
385 | + } |
386 | + return null; |
387 | + } |
388 | + |
389 | + function init() { |
390 | + } |
391 | + |
392 | + function cleanup() { |
393 | + } |
394 | + |
395 | + function test_dualSim() { |
396 | + tryCompare(mainViewLoader.item, 'applicationActive', true) |
397 | + |
398 | + mainViewLoader.item.startNewMessage() |
399 | + wait(1000) |
400 | + |
401 | + var messagesView = findChild(mainViewLoader, "messagesPage") |
402 | + var textArea = findChild(messagesView, "messageTextArea") |
403 | + var contactSearchInput = findChild(messagesView, "contactSearchInput") |
404 | + var sendButton = findChild(messagesView, "sendButton") |
405 | + contactSearchInput.text = "123" |
406 | + textArea.text = "test text" |
407 | + // on vivid mouseClick() does not work here |
408 | + sendButton.clicked() |
409 | + tryCompare(messageSentSpy, 'count', 1) |
410 | + tryCompare(telepathyHelper.defaultMessagingAccount, 'accountId', messageSentSpy.signalArguments[0][0]) |
411 | + } |
412 | + } |
413 | +} |
FAILED: Continuous integration, rev:551 jenkins. qa.ubuntu. com/job/ messaging- app-ci/ 995/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- vivid-touch/ 6892/console jenkins. qa.ubuntu. com/job/ messaging- app-vivid- i386-ci/ 504/console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 6903/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/messaging- app-ci/ 995/rebuild
http://