Merge lp:~unity-team/unity8/rtm-20150213 into lp:unity8/rtm-14.09
- rtm-20150213
- Merge into rtm-14.09
Proposed by
Michał Sawicz
Status: | Merged |
---|---|
Approved by: | Michael Zanetti |
Approved revision: | 1425 |
Merged at revision: | 1418 |
Proposed branch: | lp:~unity-team/unity8/rtm-20150213 |
Merge into: | lp:unity8/rtm-14.09 |
Diff against target: |
2193 lines (+1176/-382) 27 files modified
debian/changelog (+26/-0) plugins/Dash/CardAttributes.qml (+2/-0) plugins/Dash/CardCreator.js (+5/-1) qml/Components/Dialogs.qml (+4/-24) qml/Components/PhysicalKeysMapper.qml (+113/-0) qml/Components/VolumeKeyFilter.qml (+0/-63) qml/Notifications/Notification.qml (+36/-6) qml/Notifications/Notifications.qml (+2/-6) qml/Panel/IndicatorItem.qml (+2/-0) qml/Shell.qml (+12/-39) tests/mocks/Unity/Notifications/CMakeLists.txt (+2/-1) tests/mocks/Unity/Notifications/MockActionModel.cpp (+6/-4) tests/mocks/Unity/Notifications/MockActionModel.h (+4/-2) tests/mocks/Unity/Notifications/MockNotification.cpp (+156/-4) tests/mocks/Unity/Notifications/MockNotification.h (+63/-5) tests/mocks/Unity/Notifications/MockNotificationModel.cpp (+172/-0) tests/mocks/Unity/Notifications/MockNotificationModel.h (+72/-0) tests/mocks/Unity/Notifications/plugin.cpp (+5/-3) tests/mocks/Unity/Notifications/plugin.h (+1/-2) tests/qmltests/CMakeLists.txt (+1/-0) tests/qmltests/Components/tst_PhysicalKeysMapper.qml (+119/-0) tests/qmltests/Dash/tst_Card.qml (+9/-3) tests/qmltests/Notifications/Notification.qml (+31/-0) tests/qmltests/Notifications/tst_Notifications.qml (+271/-213) tests/qmltests/Notifications/tst_OptionToggle.qml (+11/-6) tests/qmltests/Notifications/tst_SwipeToAct.qml (+4/-0) tests/qmltests/tst_ShellWithPin.qml (+47/-0) |
To merge this branch: | bzr merge lp:~unity-team/unity8/rtm-20150213 |
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity Team | Pending | ||
Review via email: mp+249680@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
- 1423. By Michał Sawicz
-
Add changelog
- 1424. By Josh Arenson
-
Create a PhysicalKeyMapper to handle all physical/hardware keys
In addition, change the key combination for taking a screenshot from (Volume Up + Volume Down) to (Power + Volume Down).
- 1425. By Michał Sawicz
-
Update changelog
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/changelog' | |||
2 | --- debian/changelog 2015-01-22 20:47:05 +0000 | |||
3 | +++ debian/changelog 2015-02-16 22:20:44 +0000 | |||
4 | @@ -1,3 +1,29 @@ | |||
5 | 1 | unity8 (8.02+15.04.20150213~rtm-0ubuntu1) UNRELEASED; urgency=medium | ||
6 | 2 | |||
7 | 3 | [ Albert astals ] | ||
8 | 4 | * Preserve the aspect ratio for the card attribute images | ||
9 | 5 | |||
10 | 6 | [ Andrea Cimitan ] | ||
11 | 7 | * support background on horizontal cards with summary (LP: #1393008) | ||
12 | 8 | * Background needs to be specified to be visible in horizontal cards | ||
13 | 9 | (LP: #1411748) | ||
14 | 10 | |||
15 | 11 | [ Daniel d'Andrada ] | ||
16 | 12 | * Don't show() the lockscreen if it's already being shown | ||
17 | 13 | |||
18 | 14 | [ Joshua Arenson ] | ||
19 | 15 | * Create a PhysicalKeyMapper to handle all physical/hardware keys | ||
20 | 16 | |||
21 | 17 | [ Michał Sawicz ] | ||
22 | 18 | * Create a PhysicalKeyMapper to handle all physical/hardware keys | ||
23 | 19 | |||
24 | 20 | [ Mirco Müller ] | ||
25 | 21 | * Allow swipe-to-dismiss for contracted snap-decision notifications, | ||
26 | 22 | interactive notifications and ephemeral notifications. (LP: | ||
27 | 23 | #1355422, #1334855) | ||
28 | 24 | |||
29 | 25 | -- Michał Sawicz <michal.sawicz@canonical.com> Fri, 13 Feb 2015 17:23:13 +0100 | ||
30 | 26 | |||
31 | 1 | unity8 (8.02+15.04.20150122.2~rtm-0ubuntu1) 14.09; urgency=medium | 27 | unity8 (8.02+15.04.20150122.2~rtm-0ubuntu1) 14.09; urgency=medium |
32 | 2 | 28 | ||
33 | 3 | [ Michael Terry ] | 29 | [ Michael Terry ] |
34 | 4 | 30 | ||
35 | === modified file 'plugins/Dash/CardAttributes.qml' | |||
36 | --- plugins/Dash/CardAttributes.qml 2014-10-14 15:40:59 +0000 | |||
37 | +++ plugins/Dash/CardAttributes.qml 2015-02-16 22:20:44 +0000 | |||
38 | @@ -51,6 +51,8 @@ | |||
39 | 51 | id: icon | 51 | id: icon |
40 | 52 | height: units.gu(2) | 52 | height: units.gu(2) |
41 | 53 | sets: ["actions", "status", "apps"] | 53 | sets: ["actions", "status", "apps"] |
42 | 54 | // FIXME Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293 | ||
43 | 55 | width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth | ||
44 | 54 | source: "icon" in modelData && modelData["icon"] || "" | 56 | source: "icon" in modelData && modelData["icon"] || "" |
45 | 55 | color: grid.color | 57 | color: grid.color |
46 | 56 | } | 58 | } |
47 | 57 | 59 | ||
48 | === modified file 'plugins/Dash/CardCreator.js' | |||
49 | --- plugins/Dash/CardCreator.js 2015-01-08 12:51:33 +0000 | |||
50 | +++ plugins/Dash/CardCreator.js 2015-02-16 22:20:44 +0000 | |||
51 | @@ -224,6 +224,8 @@ | |||
52 | 224 | 224 | ||
53 | 225 | // %1 is used as extra anchors of emblemIcon | 225 | // %1 is used as extra anchors of emblemIcon |
54 | 226 | // %2 is used as color of emblemIcon | 226 | // %2 is used as color of emblemIcon |
55 | 227 | // FIXME The width code is a | ||
56 | 228 | // Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293 | ||
57 | 227 | var kEmblemIconCode = 'StatusIcon { \n\ | 229 | var kEmblemIconCode = 'StatusIcon { \n\ |
58 | 228 | id: emblemIcon; \n\ | 230 | id: emblemIcon; \n\ |
59 | 229 | objectName: "emblemIcon"; \n\ | 231 | objectName: "emblemIcon"; \n\ |
60 | @@ -235,6 +237,7 @@ | |||
61 | 235 | source: cardData && cardData["emblem"] || ""; \n\ | 237 | source: cardData && cardData["emblem"] || ""; \n\ |
62 | 236 | color: %2; \n\ | 238 | color: %2; \n\ |
63 | 237 | height: source != "" ? titleLabel.font.pixelSize : 0; \n\ | 239 | height: source != "" ? titleLabel.font.pixelSize : 0; \n\ |
64 | 240 | width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth; \n\ | ||
65 | 238 | }\n'; | 241 | }\n'; |
66 | 239 | 242 | ||
67 | 240 | // %1 is used as anchors of touchdown effect | 243 | // %1 is used as anchors of touchdown effect |
68 | @@ -320,7 +323,8 @@ | |||
69 | 320 | var hasSummary = components["summary"] || false; | 323 | var hasSummary = components["summary"] || false; |
70 | 321 | var artAndSummary = hasArt && hasSummary; | 324 | var artAndSummary = hasArt && hasSummary; |
71 | 322 | var isHorizontal = template["card-layout"] === "horizontal"; | 325 | var isHorizontal = template["card-layout"] === "horizontal"; |
73 | 323 | var hasBackground = !isHorizontal && (template["card-background"] || components["background"] || artAndSummary); | 326 | var hasBackground = (!isHorizontal && (template["card-background"] || components["background"] || artAndSummary)) || |
74 | 327 | (hasSummary && (template["card-background"] || components["background"])); | ||
75 | 324 | var hasTitle = components["title"] || false; | 328 | var hasTitle = components["title"] || false; |
76 | 325 | var hasMascot = components["mascot"] || false; | 329 | var hasMascot = components["mascot"] || false; |
77 | 326 | var hasEmblem = components["emblem"] && !(hasMascot && template["card-size"] === "small") || false; | 330 | var hasEmblem = components["emblem"] && !(hasMascot && template["card-size"] === "small") || false; |
78 | 327 | 331 | ||
79 | === modified file 'qml/Components/Dialogs.qml' | |||
80 | --- qml/Components/Dialogs.qml 2015-01-14 09:09:08 +0000 | |||
81 | +++ qml/Components/Dialogs.qml 2015-02-16 22:20:44 +0000 | |||
82 | @@ -28,21 +28,12 @@ | |||
83 | 28 | // in other applications like the welcome wizard. | 28 | // in other applications like the welcome wizard. |
84 | 29 | readonly property string domain: "unity8" | 29 | readonly property string domain: "unity8" |
85 | 30 | 30 | ||
86 | 31 | function onPowerKeyPressed() { | ||
87 | 32 | // FIXME: event.isAutoRepeat is always false on Nexus 4. | ||
88 | 33 | // So we use powerKeyTimer.running to avoid the PowerOff key repeat | ||
89 | 34 | // https://launchpad.net/bugs/1349416 | ||
90 | 35 | if (!powerKeyTimer.running) { | ||
91 | 36 | powerKeyTimer.restart(); | ||
92 | 37 | } | ||
93 | 38 | } | ||
94 | 39 | |||
95 | 40 | function onPowerKeyReleased() { | ||
96 | 41 | powerKeyTimer.stop(); | ||
97 | 42 | } | ||
98 | 43 | |||
99 | 44 | signal powerOffClicked(); | 31 | signal powerOffClicked(); |
100 | 45 | 32 | ||
101 | 33 | function showPowerDialog() { | ||
102 | 34 | d.showPowerDialog(); | ||
103 | 35 | } | ||
104 | 36 | |||
105 | 46 | QtObject { | 37 | QtObject { |
106 | 47 | id: d // private stuff | 38 | id: d // private stuff |
107 | 48 | 39 | ||
108 | @@ -56,17 +47,6 @@ | |||
109 | 56 | } | 47 | } |
110 | 57 | } | 48 | } |
111 | 58 | 49 | ||
112 | 59 | Timer { | ||
113 | 60 | id: powerKeyTimer | ||
114 | 61 | interval: 2000 | ||
115 | 62 | repeat: false | ||
116 | 63 | triggeredOnStart: false | ||
117 | 64 | |||
118 | 65 | onTriggered: { | ||
119 | 66 | d.showPowerDialog(); | ||
120 | 67 | } | ||
121 | 68 | } | ||
122 | 69 | |||
123 | 70 | Component { | 50 | Component { |
124 | 71 | id: logoutDialog | 51 | id: logoutDialog |
125 | 72 | Dialog { | 52 | Dialog { |
126 | 73 | 53 | ||
127 | === added file 'qml/Components/PhysicalKeysMapper.qml' | |||
128 | --- qml/Components/PhysicalKeysMapper.qml 1970-01-01 00:00:00 +0000 | |||
129 | +++ qml/Components/PhysicalKeysMapper.qml 2015-02-16 22:20:44 +0000 | |||
130 | @@ -0,0 +1,113 @@ | |||
131 | 1 | /* | ||
132 | 2 | * Copyright (C) 2014-2015 Canonical, Ltd. | ||
133 | 3 | * | ||
134 | 4 | * This program is free software; you can redistribute it and/or modify | ||
135 | 5 | * it under the terms of the GNU General Public License as published by | ||
136 | 6 | * the Free Software Foundation; version 3. | ||
137 | 7 | * | ||
138 | 8 | * This program is distributed in the hope that it will be useful, | ||
139 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
140 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
141 | 11 | * GNU General Public License for more details. | ||
142 | 12 | * | ||
143 | 13 | * You should have received a copy of the GNU General Public License | ||
144 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
145 | 15 | */ | ||
146 | 16 | |||
147 | 17 | import QtQuick 2.0 | ||
148 | 18 | import Powerd 0.1 | ||
149 | 19 | |||
150 | 20 | /*! | ||
151 | 21 | \brief A mapper for the physical keys on the device | ||
152 | 22 | |||
153 | 23 | A mapper to handle events triggered by pressing physical keys on a device. | ||
154 | 24 | Keys included are | ||
155 | 25 | * Volume Decrease | ||
156 | 26 | * Volume Increase | ||
157 | 27 | * Power | ||
158 | 28 | |||
159 | 29 | This allows for handling the following events | ||
160 | 30 | * Power dialog | ||
161 | 31 | * Volume Decreases/Increases | ||
162 | 32 | * Screenshots | ||
163 | 33 | |||
164 | 34 | */ | ||
165 | 35 | |||
166 | 36 | Item { | ||
167 | 37 | id: root | ||
168 | 38 | |||
169 | 39 | signal powerKeyLongPressed; | ||
170 | 40 | signal volumeDownTriggered; | ||
171 | 41 | signal volumeUpTriggered; | ||
172 | 42 | signal screenshotTriggered; | ||
173 | 43 | |||
174 | 44 | QtObject { | ||
175 | 45 | id: d | ||
176 | 46 | |||
177 | 47 | property bool volumeDownKeyPressed: false | ||
178 | 48 | property bool volumeUpKeyPressed: false | ||
179 | 49 | property bool ignoreVolumeEvents: false | ||
180 | 50 | } | ||
181 | 51 | |||
182 | 52 | Timer { | ||
183 | 53 | id: powerKeyLongPressTimer | ||
184 | 54 | |||
185 | 55 | interval: 2000 | ||
186 | 56 | onTriggered: root.powerKeyLongPressed(); | ||
187 | 57 | } | ||
188 | 58 | |||
189 | 59 | |||
190 | 60 | function onKeyPressed(event) { | ||
191 | 61 | if ((event.key == Qt.Key_PowerDown || event.key == Qt.Key_PowerOff) | ||
192 | 62 | && !event.isAutoRepeat) { | ||
193 | 63 | |||
194 | 64 | // FIXME: We only consider power key presses if the screen is | ||
195 | 65 | // on because of bugs 1410830/1409003. The theory is that when | ||
196 | 66 | // those bugs are encountered, there is a >2s delay between the | ||
197 | 67 | // power press event and the power release event, which causes | ||
198 | 68 | // the shutdown dialog to appear on resume. So to avoid that | ||
199 | 69 | // symptom while we investigate the root cause, we simply won't | ||
200 | 70 | // initiate any dialogs when the screen is off. | ||
201 | 71 | if (Powerd.status === Powerd.On) { | ||
202 | 72 | powerKeyLongPressTimer.restart(); | ||
203 | 73 | } | ||
204 | 74 | event.accepted = true; | ||
205 | 75 | } else if ((event.key == Qt.Key_MediaTogglePlayPause || event.key == Qt.Key_MediaPlay) | ||
206 | 76 | && !event.isAutoRepeat) { | ||
207 | 77 | event.accepted = callManager.handleMediaKey(false); | ||
208 | 78 | } else if (event.key == Qt.Key_VolumeDown) { | ||
209 | 79 | if (event.isAutoRepeat && !d.ignoreVolumeEvents) root.volumeDownTriggered(); | ||
210 | 80 | else if (!event.isAutoRepeat) { | ||
211 | 81 | if (d.volumeUpKeyPressed) { | ||
212 | 82 | if (Powerd.status === Powerd.On) root.screenshotTriggered(); | ||
213 | 83 | d.ignoreVolumeEvents = true; | ||
214 | 84 | } | ||
215 | 85 | d.volumeDownKeyPressed = true; | ||
216 | 86 | } | ||
217 | 87 | } else if (event.key == Qt.Key_VolumeUp) { | ||
218 | 88 | if (event.isAutoRepeat && !d.ignoreVolumeEvents) root.volumeUpTriggered(); | ||
219 | 89 | else if (!event.isAutoRepeat) { | ||
220 | 90 | if (d.volumeDownKeyPressed) { | ||
221 | 91 | if (Powerd.status === Powerd.On) root.screenshotTriggered(); | ||
222 | 92 | d.ignoreVolumeEvents = true; | ||
223 | 93 | } | ||
224 | 94 | d.volumeUpKeyPressed = true; | ||
225 | 95 | } | ||
226 | 96 | } | ||
227 | 97 | } | ||
228 | 98 | |||
229 | 99 | function onKeyReleased(event) { | ||
230 | 100 | if (event.key == Qt.Key_PowerDown || event.key == Qt.Key_PowerOff) { | ||
231 | 101 | powerKeyLongPressTimer.stop(); | ||
232 | 102 | event.accepted = true; | ||
233 | 103 | } else if (event.key == Qt.Key_VolumeDown) { | ||
234 | 104 | if (!d.ignoreVolumeEvents) root.volumeDownTriggered(); | ||
235 | 105 | d.volumeDownKeyPressed = false; | ||
236 | 106 | if (!d.volumeUpKeyPressed) d.ignoreVolumeEvents = false; | ||
237 | 107 | } else if (event.key == Qt.Key_VolumeUp) { | ||
238 | 108 | if (!d.ignoreVolumeEvents) root.volumeUpTriggered(); | ||
239 | 109 | d.volumeUpKeyPressed = false; | ||
240 | 110 | if (!d.volumeDownKeyPressed) d.ignoreVolumeEvents = false; | ||
241 | 111 | } | ||
242 | 112 | } | ||
243 | 113 | } | ||
244 | 0 | 114 | ||
245 | === removed file 'qml/Components/VolumeKeyFilter.qml' | |||
246 | --- qml/Components/VolumeKeyFilter.qml 2015-01-14 10:24:49 +0000 | |||
247 | +++ qml/Components/VolumeKeyFilter.qml 1970-01-01 00:00:00 +0000 | |||
248 | @@ -1,63 +0,0 @@ | |||
249 | 1 | /* | ||
250 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
251 | 3 | * | ||
252 | 4 | * This program is free software; you can redistribute it and/or modify | ||
253 | 5 | * it under the terms of the GNU General Public License as published by | ||
254 | 6 | * the Free Software Foundation; version 3. | ||
255 | 7 | * | ||
256 | 8 | * This program is distributed in the hope that it will be useful, | ||
257 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
258 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
259 | 11 | * GNU General Public License for more details. | ||
260 | 12 | * | ||
261 | 13 | * You should have received a copy of the GNU General Public License | ||
262 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
263 | 15 | */ | ||
264 | 16 | |||
265 | 17 | import QtQuick 2.0 | ||
266 | 18 | /*! | ||
267 | 19 | \brief A filter for volume keys | ||
268 | 20 | |||
269 | 21 | A filter which treats volume keys as single tri-state key with the states: | ||
270 | 22 | VolumeUp Pressed, VolumeDown Pressed or Volume Up+Down pressed | ||
271 | 23 | */ | ||
272 | 24 | QtObject { | ||
273 | 25 | id: root | ||
274 | 26 | |||
275 | 27 | signal volumeUpPressed() | ||
276 | 28 | signal volumeDownPressed() | ||
277 | 29 | signal bothVolumeKeysPressed() | ||
278 | 30 | |||
279 | 31 | property bool volumeUpKeyPressed: false | ||
280 | 32 | property bool volumeDownKeyPressed: false | ||
281 | 33 | property bool aVolumeKeyWasReleased: true | ||
282 | 34 | |||
283 | 35 | function onKeyPressed(key) { | ||
284 | 36 | if (key == Qt.Key_VolumeUp) | ||
285 | 37 | volumeUpKeyPressed = true; | ||
286 | 38 | else if (key == Qt.Key_VolumeDown) | ||
287 | 39 | volumeDownKeyPressed = true; | ||
288 | 40 | |||
289 | 41 | if (volumeDownKeyPressed && volumeUpKeyPressed) { | ||
290 | 42 | //avoids sending a signal repeatedly if both keys are held | ||
291 | 43 | //instead one of the keys must have been previously released | ||
292 | 44 | if (aVolumeKeyWasReleased) | ||
293 | 45 | bothVolumeKeysPressed(); | ||
294 | 46 | aVolumeKeyWasReleased = false; | ||
295 | 47 | } else if (volumeDownKeyPressed) { | ||
296 | 48 | volumeDownPressed(); | ||
297 | 49 | } else if (volumeUpKeyPressed) { | ||
298 | 50 | volumeUpPressed(); | ||
299 | 51 | } | ||
300 | 52 | } | ||
301 | 53 | |||
302 | 54 | function onKeyReleased(key) { | ||
303 | 55 | if (key == Qt.Key_VolumeUp) { | ||
304 | 56 | volumeUpKeyPressed = false; | ||
305 | 57 | aVolumeKeyWasReleased = true; | ||
306 | 58 | } else if (key == Qt.Key_VolumeDown) { | ||
307 | 59 | volumeDownKeyPressed = false; | ||
308 | 60 | aVolumeKeyWasReleased = true; | ||
309 | 61 | } | ||
310 | 62 | } | ||
311 | 63 | } | ||
312 | 64 | 0 | ||
313 | === modified file 'qml/Notifications/Notification.qml' | |||
314 | --- qml/Notifications/Notification.qml 2014-11-10 09:14:30 +0000 | |||
315 | +++ qml/Notifications/Notification.qml 2015-02-16 22:20:44 +0000 | |||
316 | @@ -40,6 +40,7 @@ | |||
317 | 40 | property bool fullscreen: false | 40 | property bool fullscreen: false |
318 | 41 | property int maxHeight | 41 | property int maxHeight |
319 | 42 | property int margins | 42 | property int margins |
320 | 43 | readonly property bool draggable: (type === Notification.SnapDecision && state === "contracted") || type === Notification.Interactive || type === Notification.Ephemeral | ||
321 | 43 | readonly property bool darkOnBright: panel.indicators.shown || type === Notification.SnapDecision | 44 | readonly property bool darkOnBright: panel.indicators.shown || type === Notification.SnapDecision |
322 | 44 | readonly property color red: "#fc4949" | 45 | readonly property color red: "#fc4949" |
323 | 45 | readonly property color green: "#3fb24f" | 46 | readonly property color green: "#3fb24f" |
324 | @@ -52,7 +53,7 @@ | |||
325 | 52 | implicitHeight: type !== Notification.PlaceHolder ? (fullscreen ? maxHeight : outterColumn.height - shapedBack.anchors.topMargin + contentSpacing * 2) : 0 | 53 | implicitHeight: type !== Notification.PlaceHolder ? (fullscreen ? maxHeight : outterColumn.height - shapedBack.anchors.topMargin + contentSpacing * 2) : 0 |
326 | 53 | 54 | ||
327 | 54 | color: (type === Notification.Confirmation && notificationList.useModal && !greeter.shown) || darkOnBright ? sdLightGrey : Qt.rgba(0.132, 0.117, 0.109, 0.97) | 55 | color: (type === Notification.Confirmation && notificationList.useModal && !greeter.shown) || darkOnBright ? sdLightGrey : Qt.rgba(0.132, 0.117, 0.109, 0.97) |
329 | 55 | opacity: 1 // FIXME: 1 because of LP: #1354406 workaround, has to be 0 really | 56 | opacity: 1 - (x / notification.width) // FIXME: non-zero initially because of LP: #1354406 workaround, we want this to start at 0 upon creation eventually |
330 | 56 | 57 | ||
331 | 57 | state: { | 58 | state: { |
332 | 58 | var result = ""; | 59 | var result = ""; |
333 | @@ -80,18 +81,28 @@ | |||
334 | 80 | id: sound | 81 | id: sound |
335 | 81 | objectName: "sound" | 82 | objectName: "sound" |
336 | 82 | audioRole: MediaPlayer.alert | 83 | audioRole: MediaPlayer.alert |
338 | 83 | source: hints["suppress-sound"] != "true" && hints["sound-file"] != undefined ? hints["sound-file"] : "" | 84 | source: hints["suppress-sound"] !== "true" && hints["sound-file"] !== undefined ? hints["sound-file"] : "" |
339 | 84 | } | 85 | } |
340 | 85 | 86 | ||
341 | 86 | // FIXME: using onCompleted because of LP: #1354406 workaround, has to be onOpacityChanged really | 87 | // FIXME: using onCompleted because of LP: #1354406 workaround, has to be onOpacityChanged really |
342 | 87 | Component.onCompleted: { | 88 | Component.onCompleted: { |
344 | 88 | if (opacity == 1.0 && hints["suppress-sound"] != "true" && sound.source != "") { | 89 | if (opacity == 1.0 && hints["suppress-sound"] !== "true" && sound.source !== "") { |
345 | 89 | sound.play(); | 90 | sound.play(); |
346 | 90 | } | 91 | } |
347 | 91 | } | 92 | } |
348 | 92 | 93 | ||
349 | 94 | Behavior on x { | ||
350 | 95 | id: normalXBehavior | ||
351 | 96 | |||
352 | 97 | enabled: draggable | ||
353 | 98 | UbuntuNumberAnimation { | ||
354 | 99 | duration: UbuntuAnimation.FastDuration | ||
355 | 100 | easing.type: Easing.OutBounce | ||
356 | 101 | } | ||
357 | 102 | } | ||
358 | 103 | |||
359 | 93 | onHintsChanged: { | 104 | onHintsChanged: { |
361 | 94 | if (type === Notification.Confirmation && opacity == 1.0 && hints["suppress-sound"] != "true" && sound.source != "") { | 105 | if (type === Notification.Confirmation && opacity == 1.0 && hints["suppress-sound"] !== "true" && sound.source !== "") { |
362 | 95 | sound.play(); | 106 | sound.play(); |
363 | 96 | } | 107 | } |
364 | 97 | } | 108 | } |
365 | @@ -146,6 +157,12 @@ | |||
366 | 146 | opacity: parent.opacity | 157 | opacity: parent.opacity |
367 | 147 | } | 158 | } |
368 | 148 | 159 | ||
369 | 160 | onXChanged: { | ||
370 | 161 | if (draggable && notification.x > 0.75 * notification.width) { | ||
371 | 162 | notification.notification.close() | ||
372 | 163 | } | ||
373 | 164 | } | ||
374 | 165 | |||
375 | 149 | Item { | 166 | Item { |
376 | 150 | id: contents | 167 | id: contents |
377 | 151 | anchors.fill: fullscreen ? nonShapedBack : shapedBack | 168 | anchors.fill: fullscreen ? nonShapedBack : shapedBack |
378 | @@ -169,7 +186,7 @@ | |||
379 | 169 | actions: paths.actions | 186 | actions: paths.actions |
380 | 170 | menuObjectPath: paths.menuObjectPath | 187 | menuObjectPath: paths.menuObjectPath |
381 | 171 | onNameOwnerChanged: { | 188 | onNameOwnerChanged: { |
383 | 172 | if (lastNameOwner != "" && nameOwner == "" && notification.notification != undefined) { | 189 | if (lastNameOwner !== "" && nameOwner === "" && notification.notification !== undefined) { |
384 | 173 | notification.notification.close() | 190 | notification.notification.close() |
385 | 174 | } | 191 | } |
386 | 175 | lastNameOwner = nameOwner | 192 | lastNameOwner = nameOwner |
387 | @@ -181,6 +198,12 @@ | |||
388 | 181 | 198 | ||
389 | 182 | anchors.fill: parent | 199 | anchors.fill: parent |
390 | 183 | objectName: "interactiveArea" | 200 | objectName: "interactiveArea" |
391 | 201 | |||
392 | 202 | drag.target: draggable ? notification : undefined | ||
393 | 203 | drag.axis: Drag.XAxis | ||
394 | 204 | drag.minimumX: 0 | ||
395 | 205 | drag.maximumX: notification.width | ||
396 | 206 | |||
397 | 184 | onClicked: { | 207 | onClicked: { |
398 | 185 | if (notification.type == Notification.Interactive) { | 208 | if (notification.type == Notification.Interactive) { |
399 | 186 | notification.notification.invokeAction(actionRepeater.itemAt(0).actionId) | 209 | notification.notification.invokeAction(actionRepeater.itemAt(0).actionId) |
400 | @@ -188,6 +211,13 @@ | |||
401 | 188 | notificationList.currentIndex = index; | 211 | notificationList.currentIndex = index; |
402 | 189 | } | 212 | } |
403 | 190 | } | 213 | } |
404 | 214 | onReleased: { | ||
405 | 215 | if (notification.x < notification.width / 2) { | ||
406 | 216 | notification.x = 0 | ||
407 | 217 | } else { | ||
408 | 218 | notification.x = notification.width | ||
409 | 219 | } | ||
410 | 220 | } | ||
411 | 191 | } | 221 | } |
412 | 192 | 222 | ||
413 | 193 | Column { | 223 | Column { |
414 | @@ -447,7 +477,7 @@ | |||
415 | 447 | right: parent.right | 477 | right: parent.right |
416 | 448 | margins: contentSpacing | 478 | margins: contentSpacing |
417 | 449 | } | 479 | } |
419 | 450 | visible: notification.type == Notification.SnapDecision && actionRepeater.count > 0 && !oneOverTwoCase.visible | 480 | visible: notification.type === Notification.SnapDecision && actionRepeater.count > 0 && !oneOverTwoCase.visible |
420 | 451 | spacing: units.gu(2) | 481 | spacing: units.gu(2) |
421 | 452 | layoutDirection: Qt.RightToLeft | 482 | layoutDirection: Qt.RightToLeft |
422 | 453 | 483 | ||
423 | 454 | 484 | ||
424 | === modified file 'qml/Notifications/Notifications.qml' | |||
425 | --- qml/Notifications/Notifications.qml 2014-10-30 21:42:32 +0000 | |||
426 | +++ qml/Notifications/Notifications.qml 2015-02-16 22:20:44 +0000 | |||
427 | @@ -41,15 +41,11 @@ | |||
428 | 41 | property bool topmostIsFullscreen: false | 41 | property bool topmostIsFullscreen: false |
429 | 42 | spacing: topmostIsFullscreen ? 0 : units.gu(.5) | 42 | spacing: topmostIsFullscreen ? 0 : units.gu(.5) |
430 | 43 | 43 | ||
433 | 44 | // FIXME: This doesn't make any sense and results in a binding loop | 44 | currentIndex: count > 1 ? 1 : -1 |
432 | 45 | currentIndex: (currentIndex < 1 && count > 1) ? 1 : -1 | ||
434 | 46 | 45 | ||
435 | 47 | delegate: Notification { | 46 | delegate: Notification { |
436 | 48 | objectName: "notification" + index | 47 | objectName: "notification" + index |
441 | 49 | anchors { | 48 | width: parent.width |
438 | 50 | left: parent.left | ||
439 | 51 | right: parent.right | ||
440 | 52 | } | ||
442 | 53 | type: model.type | 49 | type: model.type |
443 | 54 | hints: model.hints | 50 | hints: model.hints |
444 | 55 | iconSource: model.icon | 51 | iconSource: model.icon |
445 | 56 | 52 | ||
446 | === modified file 'qml/Panel/IndicatorItem.qml' | |||
447 | --- qml/Panel/IndicatorItem.qml 2015-01-14 10:17:12 +0000 | |||
448 | +++ qml/Panel/IndicatorItem.qml 2015-02-16 22:20:44 +0000 | |||
449 | @@ -95,6 +95,8 @@ | |||
450 | 95 | id: itemImage | 95 | id: itemImage |
451 | 96 | objectName: "icon"+index | 96 | objectName: "icon"+index |
452 | 97 | height: iconHeight | 97 | height: iconHeight |
453 | 98 | // FIXME Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293 | ||
454 | 99 | width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth; | ||
455 | 98 | source: modelData | 100 | source: modelData |
456 | 99 | sets: ["status", "actions"] | 101 | sets: ["status", "actions"] |
457 | 100 | color: root.color | 102 | color: root.color |
458 | 101 | 103 | ||
459 | === modified file 'qml/Shell.qml' | |||
460 | --- qml/Shell.qml 2015-01-22 02:41:55 +0000 | |||
461 | +++ qml/Shell.qml 2015-02-16 22:20:44 +0000 | |||
462 | @@ -136,6 +136,15 @@ | |||
463 | 136 | objectName: "dashCommunicator" | 136 | objectName: "dashCommunicator" |
464 | 137 | } | 137 | } |
465 | 138 | 138 | ||
466 | 139 | PhysicalKeysMapper { | ||
467 | 140 | id: physicalKeysMapper | ||
468 | 141 | |||
469 | 142 | onPowerKeyLongPressed: dialogs.showPowerDialog() | ||
470 | 143 | onVolumeDownTriggered: volumeControl.volumeDown(); | ||
471 | 144 | onVolumeUpTriggered: volumeControl.volumeUp(); | ||
472 | 145 | onScreenshotTriggered: screenGrabber.capture(); | ||
473 | 146 | } | ||
474 | 147 | |||
475 | 139 | ScreenGrabber { | 148 | ScreenGrabber { |
476 | 140 | id: screenGrabber | 149 | id: screenGrabber |
477 | 141 | z: edgeDemo.z + 10 | 150 | z: edgeDemo.z + 10 |
478 | @@ -148,45 +157,9 @@ | |||
479 | 148 | value: launcher.shown || launcher.dashSwipe | 157 | value: launcher.shown || launcher.dashSwipe |
480 | 149 | } | 158 | } |
481 | 150 | 159 | ||
482 | 151 | VolumeKeyFilter { | ||
483 | 152 | id: volumeKeyFilter | ||
484 | 153 | onVolumeDownPressed: volumeControl.volumeDown() | ||
485 | 154 | onVolumeUpPressed: volumeControl.volumeUp() | ||
486 | 155 | onBothVolumeKeysPressed: screenGrabber.capture() | ||
487 | 156 | } | ||
488 | 157 | |||
489 | 158 | WindowKeysFilter { | 160 | WindowKeysFilter { |
521 | 159 | Keys.onPressed: { | 161 | Keys.onPressed: physicalKeysMapper.onKeyPressed(event); |
522 | 160 | // Nokia earpieces give TogglePlayPause, while the iPhone's earpiece gives Play | 162 | Keys.onReleased: physicalKeysMapper.onKeyReleased(event); |
492 | 161 | if (event.key == Qt.Key_MediaTogglePlayPause || event.key == Qt.Key_MediaPlay) { | ||
493 | 162 | event.accepted = callManager.handleMediaKey(false); | ||
494 | 163 | } else if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) { | ||
495 | 164 | // FIXME: We only consider power key presses if the screen is | ||
496 | 165 | // on because of bugs 1410830/1409003. The theory is that when | ||
497 | 166 | // those bugs are encountered, there is a >2s delay between the | ||
498 | 167 | // power press event and the power release event, which causes | ||
499 | 168 | // the shutdown dialog to appear on resume. So to avoid that | ||
500 | 169 | // symptom while we investigate the root cause, we simply won't | ||
501 | 170 | // initiate any dialogs when the screen is off. | ||
502 | 171 | if (Powerd.status === Powerd.On) { | ||
503 | 172 | dialogs.onPowerKeyPressed(); | ||
504 | 173 | } | ||
505 | 174 | event.accepted = true; | ||
506 | 175 | } else { | ||
507 | 176 | volumeKeyFilter.onKeyPressed(event.key); | ||
508 | 177 | event.accepted = false; | ||
509 | 178 | } | ||
510 | 179 | } | ||
511 | 180 | |||
512 | 181 | Keys.onReleased: { | ||
513 | 182 | if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) { | ||
514 | 183 | dialogs.onPowerKeyReleased(); | ||
515 | 184 | event.accepted = true; | ||
516 | 185 | } else { | ||
517 | 186 | volumeKeyFilter.onKeyReleased(event.key); | ||
518 | 187 | event.accepted = false; | ||
519 | 188 | } | ||
520 | 189 | } | ||
523 | 190 | } | 163 | } |
524 | 191 | 164 | ||
525 | 192 | Item { | 165 | Item { |
526 | @@ -364,7 +337,7 @@ | |||
527 | 364 | onShownChanged: if (shown) greeter.lockedApp = "" | 337 | onShownChanged: if (shown) greeter.lockedApp = "" |
528 | 365 | 338 | ||
529 | 366 | function maybeShow() { | 339 | function maybeShow() { |
531 | 367 | if (!shell.forcedUnlock) { | 340 | if (!shell.forcedUnlock && !shown) { |
532 | 368 | showNow(); | 341 | showNow(); |
533 | 369 | } | 342 | } |
534 | 370 | } | 343 | } |
535 | 371 | 344 | ||
536 | === modified file 'tests/mocks/Unity/Notifications/CMakeLists.txt' | |||
537 | --- tests/mocks/Unity/Notifications/CMakeLists.txt 2014-11-05 00:17:50 +0000 | |||
538 | +++ tests/mocks/Unity/Notifications/CMakeLists.txt 2015-02-16 22:20:44 +0000 | |||
539 | @@ -4,7 +4,8 @@ | |||
540 | 4 | 4 | ||
541 | 5 | set(MockNotificationsPlugin_SOURCES | 5 | set(MockNotificationsPlugin_SOURCES |
542 | 6 | plugin.cpp | 6 | plugin.cpp |
544 | 7 | MockNotificationTypes.cpp | 7 | MockNotification.cpp |
545 | 8 | MockNotificationModel.cpp | ||
546 | 8 | MockActionModel.cpp | 9 | MockActionModel.cpp |
547 | 9 | ) | 10 | ) |
548 | 10 | 11 | ||
549 | 11 | 12 | ||
550 | === modified file 'tests/mocks/Unity/Notifications/MockActionModel.cpp' | |||
551 | --- tests/mocks/Unity/Notifications/MockActionModel.cpp 2014-11-05 00:17:50 +0000 | |||
552 | +++ tests/mocks/Unity/Notifications/MockActionModel.cpp 2015-02-16 22:20:44 +0000 | |||
553 | @@ -1,5 +1,5 @@ | |||
554 | 1 | /* | 1 | /* |
556 | 2 | * Copyright 2014 Canonical Ltd. | 2 | * Copyright 2015 Canonical Ltd. |
557 | 3 | * | 3 | * |
558 | 4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
559 | 5 | * it under the terms of the GNU Lesser General Public License as published by | 5 | * it under the terms of the GNU Lesser General Public License as published by |
560 | @@ -25,8 +25,6 @@ | |||
561 | 25 | }; | 25 | }; |
562 | 26 | 26 | ||
563 | 27 | ActionModel::ActionModel(QObject *parent) : QStringListModel(parent), p(new ActionModelPrivate) { | 27 | ActionModel::ActionModel(QObject *parent) : QStringListModel(parent), p(new ActionModelPrivate) { |
564 | 28 | insertAction("ok_id", "Ok"); | ||
565 | 29 | insertAction("cancel_id", "Cancel"); | ||
566 | 30 | } | 28 | } |
567 | 31 | 29 | ||
568 | 32 | ActionModel::~ActionModel() { | 30 | ActionModel::~ActionModel() { |
569 | @@ -66,7 +64,11 @@ | |||
570 | 66 | return data(index(row, 0), role); | 64 | return data(index(row, 0), role); |
571 | 67 | } | 65 | } |
572 | 68 | 66 | ||
574 | 69 | void ActionModel::insertAction(const QString &id, const QString &label) { | 67 | void ActionModel::append(const QString &id, const QString &label) { |
575 | 70 | p->ids.push_back(id); | 68 | p->ids.push_back(id); |
576 | 71 | p->labels.push_back(label); | 69 | p->labels.push_back(label); |
577 | 72 | } | 70 | } |
578 | 71 | |||
579 | 72 | int ActionModel::getCount() const { | ||
580 | 73 | return p->labels.size(); | ||
581 | 74 | } | ||
582 | 73 | 75 | ||
583 | === modified file 'tests/mocks/Unity/Notifications/MockActionModel.h' | |||
584 | --- tests/mocks/Unity/Notifications/MockActionModel.h 2014-11-05 00:17:50 +0000 | |||
585 | +++ tests/mocks/Unity/Notifications/MockActionModel.h 2015-02-16 22:20:44 +0000 | |||
586 | @@ -1,5 +1,5 @@ | |||
587 | 1 | /* | 1 | /* |
589 | 2 | * Copyright 2014 Canonical Ltd. | 2 | * Copyright 2015 Canonical Ltd. |
590 | 3 | * | 3 | * |
591 | 4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
592 | 5 | * it under the terms of the GNU Lesser General Public License as published by | 5 | * it under the terms of the GNU Lesser General Public License as published by |
593 | @@ -26,6 +26,7 @@ | |||
594 | 26 | 26 | ||
595 | 27 | class ActionModel : public QStringListModel { | 27 | class ActionModel : public QStringListModel { |
596 | 28 | Q_OBJECT | 28 | Q_OBJECT |
597 | 29 | Q_PROPERTY(int count READ getCount) | ||
598 | 29 | 30 | ||
599 | 30 | public: | 31 | public: |
600 | 31 | ActionModel(QObject *parent=nullptr); | 32 | ActionModel(QObject *parent=nullptr); |
601 | @@ -42,7 +43,8 @@ | |||
602 | 42 | }; | 43 | }; |
603 | 43 | Q_INVOKABLE QVariant data(int row, int role) const; | 44 | Q_INVOKABLE QVariant data(int row, int role) const; |
604 | 44 | 45 | ||
606 | 45 | void insertAction(const QString &id, const QString &label); | 46 | Q_INVOKABLE void append(const QString &id, const QString &label); |
607 | 47 | int getCount() const; | ||
608 | 46 | 48 | ||
609 | 47 | private: | 49 | private: |
610 | 48 | QScopedPointer<ActionModelPrivate> p; | 50 | QScopedPointer<ActionModelPrivate> p; |
611 | 49 | 51 | ||
612 | === renamed file 'tests/mocks/Unity/Notifications/MockNotificationTypes.cpp' => 'tests/mocks/Unity/Notifications/MockNotification.cpp' | |||
613 | --- tests/mocks/Unity/Notifications/MockNotificationTypes.cpp 2014-11-05 00:17:50 +0000 | |||
614 | +++ tests/mocks/Unity/Notifications/MockNotification.cpp 2015-02-16 22:20:44 +0000 | |||
615 | @@ -1,5 +1,5 @@ | |||
616 | 1 | /* | 1 | /* |
618 | 2 | * Copyright 2014 Canonical Ltd. | 2 | * Copyright 2015 Canonical Ltd. |
619 | 3 | * | 3 | * |
620 | 4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
621 | 5 | * it under the terms of the GNU Lesser General Public License as published by | 5 | * it under the terms of the GNU Lesser General Public License as published by |
622 | @@ -17,10 +17,162 @@ | |||
623 | 17 | * Mirco Mueller <mirco.mueller@canonical.com> | 17 | * Mirco Mueller <mirco.mueller@canonical.com> |
624 | 18 | */ | 18 | */ |
625 | 19 | 19 | ||
629 | 20 | #include "MockNotificationTypes.h" | 20 | #include "MockNotification.h" |
630 | 21 | 21 | ||
631 | 22 | MockNotification::MockNotification(QObject *parent) : QObject(parent) { | 22 | #include <QDebug> |
632 | 23 | |||
633 | 24 | struct MockNotificationPrivate { | ||
634 | 25 | int id; | ||
635 | 26 | QString summary; | ||
636 | 27 | QString body; | ||
637 | 28 | int value; | ||
638 | 29 | MockNotification::Type type; | ||
639 | 30 | QString icon; | ||
640 | 31 | QString secondaryIcon; | ||
641 | 32 | QStringList actions; | ||
642 | 33 | ActionModel* actionsModel; | ||
643 | 34 | QVariantMap hints; | ||
644 | 35 | }; | ||
645 | 36 | |||
646 | 37 | MockNotification::MockNotification(QObject *parent) : QObject(parent), p(new MockNotificationPrivate()) { | ||
647 | 38 | p->actionsModel = new ActionModel(); | ||
648 | 23 | } | 39 | } |
649 | 24 | 40 | ||
650 | 25 | MockNotification::~MockNotification() { | 41 | MockNotification::~MockNotification() { |
651 | 26 | } | 42 | } |
652 | 43 | |||
653 | 44 | QString MockNotification::getSummary() const { | ||
654 | 45 | return p->summary; | ||
655 | 46 | } | ||
656 | 47 | |||
657 | 48 | void MockNotification::setSummary(const QString &summary) { | ||
658 | 49 | if(p->summary != summary) { | ||
659 | 50 | p->summary = summary; | ||
660 | 51 | Q_EMIT summaryChanged(p->summary); | ||
661 | 52 | Q_EMIT dataChanged(p->id); | ||
662 | 53 | } | ||
663 | 54 | } | ||
664 | 55 | |||
665 | 56 | QString MockNotification::getBody() const { | ||
666 | 57 | return p->body; | ||
667 | 58 | } | ||
668 | 59 | |||
669 | 60 | void MockNotification::setBody(const QString &body) { | ||
670 | 61 | if(p->body != body) { | ||
671 | 62 | p->body = body; | ||
672 | 63 | Q_EMIT bodyChanged(p->body); | ||
673 | 64 | Q_EMIT dataChanged(p->id); | ||
674 | 65 | } | ||
675 | 66 | } | ||
676 | 67 | |||
677 | 68 | int MockNotification::getID() const { | ||
678 | 69 | return p->id; | ||
679 | 70 | } | ||
680 | 71 | |||
681 | 72 | void MockNotification::setID(const int id) { | ||
682 | 73 | p->id = id; | ||
683 | 74 | } | ||
684 | 75 | |||
685 | 76 | int MockNotification::getValue() const { | ||
686 | 77 | return p->value; | ||
687 | 78 | } | ||
688 | 79 | |||
689 | 80 | void MockNotification::setValue(int value) { | ||
690 | 81 | if(p->value != value) { | ||
691 | 82 | p->value = value; | ||
692 | 83 | Q_EMIT valueChanged(p->value); | ||
693 | 84 | Q_EMIT dataChanged(p->id); | ||
694 | 85 | } | ||
695 | 86 | } | ||
696 | 87 | |||
697 | 88 | QString MockNotification::getIcon() const { | ||
698 | 89 | return p->icon; | ||
699 | 90 | } | ||
700 | 91 | |||
701 | 92 | void MockNotification::setIcon(const QString &icon) { | ||
702 | 93 | if (icon.startsWith(" ") || icon.size() == 0) { | ||
703 | 94 | p->icon = nullptr; | ||
704 | 95 | } | ||
705 | 96 | else { | ||
706 | 97 | p->icon = icon; | ||
707 | 98 | |||
708 | 99 | if (icon.indexOf("/") == -1) { | ||
709 | 100 | p->icon.prepend("image://theme/"); | ||
710 | 101 | } | ||
711 | 102 | } | ||
712 | 103 | |||
713 | 104 | Q_EMIT iconChanged(p->icon); | ||
714 | 105 | Q_EMIT dataChanged(p->id); | ||
715 | 106 | } | ||
716 | 107 | |||
717 | 108 | QString MockNotification::getSecondaryIcon() const { | ||
718 | 109 | return p->secondaryIcon; | ||
719 | 110 | } | ||
720 | 111 | |||
721 | 112 | void MockNotification::setSecondaryIcon(const QString &secondaryIcon) { | ||
722 | 113 | if (secondaryIcon.startsWith(" ") || secondaryIcon.size() == 0) { | ||
723 | 114 | p->secondaryIcon = nullptr; | ||
724 | 115 | } | ||
725 | 116 | else { | ||
726 | 117 | p->secondaryIcon = secondaryIcon; | ||
727 | 118 | |||
728 | 119 | if (secondaryIcon.indexOf("/") == -1) { | ||
729 | 120 | p->secondaryIcon.prepend("image://theme/"); | ||
730 | 121 | } | ||
731 | 122 | } | ||
732 | 123 | |||
733 | 124 | Q_EMIT secondaryIconChanged(p->secondaryIcon); | ||
734 | 125 | Q_EMIT dataChanged(p->id); | ||
735 | 126 | } | ||
736 | 127 | |||
737 | 128 | MockNotification::Type MockNotification::getType() const { | ||
738 | 129 | return p->type; | ||
739 | 130 | } | ||
740 | 131 | |||
741 | 132 | void MockNotification::setType(Type type) { | ||
742 | 133 | if(p->type != type) { | ||
743 | 134 | p->type = type; | ||
744 | 135 | Q_EMIT typeChanged(p->type); | ||
745 | 136 | } | ||
746 | 137 | } | ||
747 | 138 | |||
748 | 139 | ActionModel* MockNotification::getActions() const { | ||
749 | 140 | return p->actionsModel; | ||
750 | 141 | } | ||
751 | 142 | |||
752 | 143 | void MockNotification::setActions(const QStringList &actions) { | ||
753 | 144 | if(p->actions != actions) { | ||
754 | 145 | p->actions = actions; | ||
755 | 146 | Q_EMIT actionsChanged(p->actions); | ||
756 | 147 | |||
757 | 148 | for (int i = 0; i < p->actions.size(); i += 2) { | ||
758 | 149 | p->actionsModel->append(p->actions[i], p->actions[i+1]); | ||
759 | 150 | } | ||
760 | 151 | } | ||
761 | 152 | } | ||
762 | 153 | |||
763 | 154 | QVariantMap MockNotification::getHints() const { | ||
764 | 155 | return p->hints; | ||
765 | 156 | } | ||
766 | 157 | |||
767 | 158 | void MockNotification::setHints(const QVariantMap& hints) { | ||
768 | 159 | if (p->hints != hints) { | ||
769 | 160 | p->hints = hints; | ||
770 | 161 | Q_EMIT hintsChanged(p->hints); | ||
771 | 162 | } | ||
772 | 163 | } | ||
773 | 164 | |||
774 | 165 | void MockNotification::invokeAction(const QString &action) { | ||
775 | 166 | for(int i=0; i<p->actions.size(); i++) { | ||
776 | 167 | if(p->actions[i] == action) { | ||
777 | 168 | Q_EMIT actionInvoked(action); | ||
778 | 169 | qDebug() << "Info: invoked action" << action; | ||
779 | 170 | return; | ||
780 | 171 | } | ||
781 | 172 | } | ||
782 | 173 | fprintf(stderr, "Error: tried to invoke action not in actionList.\n"); | ||
783 | 174 | } | ||
784 | 175 | |||
785 | 176 | void MockNotification::close() { | ||
786 | 177 | Q_EMIT completed(p->id); | ||
787 | 178 | } | ||
788 | 27 | 179 | ||
789 | === renamed file 'tests/mocks/Unity/Notifications/MockNotificationTypes.h' => 'tests/mocks/Unity/Notifications/MockNotification.h' | |||
790 | --- tests/mocks/Unity/Notifications/MockNotificationTypes.h 2014-11-05 00:17:50 +0000 | |||
791 | +++ tests/mocks/Unity/Notifications/MockNotification.h 2015-02-16 22:20:44 +0000 | |||
792 | @@ -1,5 +1,5 @@ | |||
793 | 1 | /* | 1 | /* |
795 | 2 | * Copyright 2014 Canonical Ltd. | 2 | * Copyright 2015 Canonical Ltd. |
796 | 3 | * | 3 | * |
797 | 4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
798 | 5 | * it under the terms of the GNU Lesser General Public License as published by | 5 | * it under the terms of the GNU Lesser General Public License as published by |
799 | @@ -17,20 +17,78 @@ | |||
800 | 17 | * Mirco Mueller <mirco.mueller@canonical.com> | 17 | * Mirco Mueller <mirco.mueller@canonical.com> |
801 | 18 | */ | 18 | */ |
802 | 19 | 19 | ||
805 | 20 | #ifndef MOCK_NOTIFICATION_TYPES_H | 20 | #ifndef MOCK_NOTIFICATION_H |
806 | 21 | #define MOCK_NOTIFICATION_TYPES_H | 21 | #define MOCK_NOTIFICATION_H |
807 | 22 | 22 | ||
808 | 23 | #include "MockActionModel.h" | ||
809 | 23 | #include <QObject> | 24 | #include <QObject> |
810 | 25 | #include <QString> | ||
811 | 26 | #include <QStringList> | ||
812 | 27 | #include <QScopedPointer> | ||
813 | 28 | |||
814 | 29 | struct MockNotificationPrivate; | ||
815 | 24 | 30 | ||
816 | 25 | class MockNotification : public QObject { | 31 | class MockNotification : public QObject { |
817 | 26 | Q_OBJECT | 32 | Q_OBJECT |
818 | 27 | Q_ENUMS(Type) | 33 | Q_ENUMS(Type) |
819 | 34 | Q_PROPERTY(QString summary READ getSummary WRITE setSummary NOTIFY summaryChanged) | ||
820 | 35 | Q_PROPERTY(QString body READ getBody WRITE setBody NOTIFY bodyChanged) | ||
821 | 36 | Q_PROPERTY(int nid READ getID WRITE setID NOTIFY idChanged) | ||
822 | 37 | Q_PROPERTY(int value READ getValue WRITE setValue NOTIFY valueChanged) | ||
823 | 38 | Q_PROPERTY(QString icon READ getIcon WRITE setIcon NOTIFY iconChanged) | ||
824 | 39 | Q_PROPERTY(QString secondaryIcon READ getSecondaryIcon WRITE setSecondaryIcon NOTIFY secondaryIconChanged) | ||
825 | 40 | Q_PROPERTY(Type type READ getType WRITE setType NOTIFY typeChanged) | ||
826 | 41 | Q_PROPERTY(QStringList rawActions WRITE setActions) | ||
827 | 42 | Q_PROPERTY(ActionModel* actions READ getActions NOTIFY actionsChanged) | ||
828 | 43 | Q_PROPERTY(QVariantMap hints READ getHints WRITE setHints NOTIFY hintsChanged) | ||
829 | 44 | |||
830 | 45 | private: | ||
831 | 46 | QScopedPointer<MockNotificationPrivate> p; | ||
832 | 47 | |||
833 | 48 | public: | ||
834 | 49 | enum Urgency { Low, Normal, Critical }; | ||
835 | 50 | enum Type { PlaceHolder, Confirmation, Ephemeral, Interactive, SnapDecision }; | ||
836 | 51 | |||
837 | 52 | Q_SIGNALS: | ||
838 | 53 | void summaryChanged(const QString &summary); | ||
839 | 54 | void bodyChanged(const QString &body); | ||
840 | 55 | void idChanged(const int id); | ||
841 | 56 | void valueChanged(int value); | ||
842 | 57 | void iconChanged(const QString &icon); | ||
843 | 58 | void secondaryIconChanged(const QString &secondaryIcon); | ||
844 | 59 | void typeChanged(Type type); | ||
845 | 60 | void actionsChanged(const QStringList &actions); | ||
846 | 61 | void hintsChanged(const QVariantMap& hints); | ||
847 | 62 | |||
848 | 63 | void dataChanged(int nid); | ||
849 | 64 | void completed(int nid); | ||
850 | 65 | void actionInvoked(const QString &action); | ||
851 | 28 | 66 | ||
852 | 29 | public: | 67 | public: |
853 | 30 | MockNotification(QObject *parent=nullptr); | 68 | MockNotification(QObject *parent=nullptr); |
854 | 31 | virtual ~MockNotification(); | 69 | virtual ~MockNotification(); |
855 | 32 | 70 | ||
857 | 33 | enum Type { PlaceHolder, Confirmation, Ephemeral, Interactive, SnapDecision }; | 71 | QString getSummary() const; |
858 | 72 | void setSummary(const QString &summary); | ||
859 | 73 | QString getBody() const; | ||
860 | 74 | void setBody(const QString &body); | ||
861 | 75 | int getID() const; | ||
862 | 76 | void setID(const int id); | ||
863 | 77 | int getValue() const; | ||
864 | 78 | void setValue(int value); | ||
865 | 79 | QString getIcon() const; | ||
866 | 80 | void setIcon(const QString &icon); | ||
867 | 81 | QString getSecondaryIcon() const; | ||
868 | 82 | void setSecondaryIcon(const QString &secondaryIcon); | ||
869 | 83 | Type getType() const; | ||
870 | 84 | void setType(Type type); | ||
871 | 85 | ActionModel* getActions() const; | ||
872 | 86 | void setActions(const QStringList &actions); | ||
873 | 87 | QVariantMap getHints() const; | ||
874 | 88 | void setHints(const QVariantMap& hints); | ||
875 | 89 | |||
876 | 90 | Q_INVOKABLE void invokeAction(const QString &action); | ||
877 | 91 | Q_INVOKABLE void close(); | ||
878 | 34 | }; | 92 | }; |
879 | 35 | 93 | ||
881 | 36 | #endif // MOCK_NOTIFICATION_TYPES_H | 94 | #endif // MOCK_NOTIFICATION_H |
882 | 37 | 95 | ||
883 | === added file 'tests/mocks/Unity/Notifications/MockNotificationModel.cpp' | |||
884 | --- tests/mocks/Unity/Notifications/MockNotificationModel.cpp 1970-01-01 00:00:00 +0000 | |||
885 | +++ tests/mocks/Unity/Notifications/MockNotificationModel.cpp 2015-02-16 22:20:44 +0000 | |||
886 | @@ -0,0 +1,172 @@ | |||
887 | 1 | /* | ||
888 | 2 | * Copyright 2015 Canonical Ltd. | ||
889 | 3 | * | ||
890 | 4 | * This program is free software; you can redistribute it and/or modify | ||
891 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
892 | 6 | * the Free Software Foundation; version 3. | ||
893 | 7 | * | ||
894 | 8 | * This program is distributed in the hope that it will be useful, | ||
895 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
896 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
897 | 11 | * GNU Lesser General Public License for more details. | ||
898 | 12 | * | ||
899 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
900 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
901 | 15 | * | ||
902 | 16 | * Authors: | ||
903 | 17 | * Mirco Mueller <mirco.mueller@canonical.com> | ||
904 | 18 | */ | ||
905 | 19 | |||
906 | 20 | #include "MockNotificationModel.h" | ||
907 | 21 | #include "MockNotification.h" | ||
908 | 22 | |||
909 | 23 | #include <unity/shell/notifications/ModelInterface.h> | ||
910 | 24 | |||
911 | 25 | #include <QTimer> | ||
912 | 26 | #include <QList> | ||
913 | 27 | #include <QVector> | ||
914 | 28 | #include <QMap> | ||
915 | 29 | #include <QStringListModel> | ||
916 | 30 | #include <QQmlEngine> | ||
917 | 31 | |||
918 | 32 | using namespace unity::shell::notifications; | ||
919 | 33 | |||
920 | 34 | MockNotificationModel::MockNotificationModel(QObject *parent) : QAbstractListModel(parent) { | ||
921 | 35 | } | ||
922 | 36 | |||
923 | 37 | MockNotificationModel::~MockNotificationModel() { | ||
924 | 38 | } | ||
925 | 39 | |||
926 | 40 | int MockNotificationModel::rowCount(const QModelIndex &parent) const { | ||
927 | 41 | return m_queue.size(); | ||
928 | 42 | } | ||
929 | 43 | |||
930 | 44 | int MockNotificationModel::getCount() const { | ||
931 | 45 | return m_queue.size(); | ||
932 | 46 | } | ||
933 | 47 | |||
934 | 48 | QVariant MockNotificationModel::data(const QModelIndex &index, int role) const { | ||
935 | 49 | if (!index.isValid()) | ||
936 | 50 | return QVariant(); | ||
937 | 51 | |||
938 | 52 | switch(role) { | ||
939 | 53 | case ModelInterface::RoleType: | ||
940 | 54 | return QVariant(m_queue[index.row()]->getType()); | ||
941 | 55 | |||
942 | 56 | case ModelInterface::RoleId: | ||
943 | 57 | return QVariant(m_queue[index.row()]->getID()); | ||
944 | 58 | |||
945 | 59 | case ModelInterface::RoleSummary: | ||
946 | 60 | return QVariant(m_queue[index.row()]->getSummary()); | ||
947 | 61 | |||
948 | 62 | case ModelInterface::RoleBody: | ||
949 | 63 | return QVariant(m_queue[index.row()]->getBody()); | ||
950 | 64 | |||
951 | 65 | case ModelInterface::RoleValue: | ||
952 | 66 | return QVariant(m_queue[index.row()]->getValue()); | ||
953 | 67 | |||
954 | 68 | case ModelInterface::RoleIcon: | ||
955 | 69 | return QVariant(m_queue[index.row()]->getIcon()); | ||
956 | 70 | |||
957 | 71 | case ModelInterface::RoleSecondaryIcon: | ||
958 | 72 | return QVariant(m_queue[index.row()]->getSecondaryIcon()); | ||
959 | 73 | |||
960 | 74 | case ModelInterface::RoleActions: | ||
961 | 75 | return QVariant::fromValue(m_queue[index.row()]->getActions()); | ||
962 | 76 | |||
963 | 77 | case ModelInterface::RoleHints: | ||
964 | 78 | return QVariant(m_queue[index.row()]->getHints()); | ||
965 | 79 | |||
966 | 80 | case ModelInterface::RoleNotification: | ||
967 | 81 | return QVariant::fromValue(m_queue[index.row()]); | ||
968 | 82 | |||
969 | 83 | default: | ||
970 | 84 | return QVariant(); | ||
971 | 85 | } | ||
972 | 86 | } | ||
973 | 87 | |||
974 | 88 | void MockNotificationModel::append(MockNotification* n) { | ||
975 | 89 | int location = m_queue.size(); | ||
976 | 90 | QModelIndex insertionPoint = QModelIndex(); | ||
977 | 91 | beginInsertRows(insertionPoint, location, location); | ||
978 | 92 | m_queue.insert(location, n); | ||
979 | 93 | endInsertRows(); | ||
980 | 94 | } | ||
981 | 95 | |||
982 | 96 | MockNotification* MockNotificationModel::getNotification(int id) const { | ||
983 | 97 | for(int i=0; i < m_queue.size(); i++) { | ||
984 | 98 | if(m_queue[i]->getID() == id) { | ||
985 | 99 | return m_queue[i]; | ||
986 | 100 | } | ||
987 | 101 | } | ||
988 | 102 | |||
989 | 103 | return nullptr; | ||
990 | 104 | } | ||
991 | 105 | |||
992 | 106 | void MockNotificationModel::remove(const int id) { | ||
993 | 107 | for(int i = 0; i < m_queue.size(); i++) { | ||
994 | 108 | if(m_queue[i]->getID() == id) { | ||
995 | 109 | removeInternal(i); | ||
996 | 110 | return; | ||
997 | 111 | } | ||
998 | 112 | } | ||
999 | 113 | } | ||
1000 | 114 | |||
1001 | 115 | void MockNotificationModel::removeSecond() { | ||
1002 | 116 | if(m_queue.size() < 2) | ||
1003 | 117 | return; | ||
1004 | 118 | removeInternal(1); | ||
1005 | 119 | } | ||
1006 | 120 | |||
1007 | 121 | void MockNotificationModel::removeInternal(int loc) { | ||
1008 | 122 | QModelIndex deletePoint = QModelIndex(); | ||
1009 | 123 | beginRemoveRows(deletePoint, loc, loc); | ||
1010 | 124 | m_queue.erase(m_queue.begin() + loc); | ||
1011 | 125 | endRemoveRows(); | ||
1012 | 126 | } | ||
1013 | 127 | |||
1014 | 128 | MockNotification* MockNotificationModel::getRaw(const int notificationId) const { | ||
1015 | 129 | for(int i = 0; i < m_queue.size(); i++) { | ||
1016 | 130 | if(m_queue[i]->getID() == notificationId) { | ||
1017 | 131 | MockNotification* n = m_queue[i]; | ||
1018 | 132 | return n; | ||
1019 | 133 | } | ||
1020 | 134 | } | ||
1021 | 135 | |||
1022 | 136 | return nullptr; | ||
1023 | 137 | } | ||
1024 | 138 | |||
1025 | 139 | int MockNotificationModel::queued() const { | ||
1026 | 140 | return m_queue.size(); | ||
1027 | 141 | } | ||
1028 | 142 | |||
1029 | 143 | QHash<int, QByteArray> MockNotificationModel::roleNames() const { | ||
1030 | 144 | QHash<int, QByteArray> roles; | ||
1031 | 145 | |||
1032 | 146 | roles.insert(ModelInterface::RoleType, "type"); | ||
1033 | 147 | roles.insert(ModelInterface::RoleUrgency, "urgency"); | ||
1034 | 148 | roles.insert(ModelInterface::RoleId, "id"); | ||
1035 | 149 | roles.insert(ModelInterface::RoleSummary, "summary"); | ||
1036 | 150 | roles.insert(ModelInterface::RoleBody, "body"); | ||
1037 | 151 | roles.insert(ModelInterface::RoleValue, "value"); | ||
1038 | 152 | roles.insert(ModelInterface::RoleIcon, "icon"); | ||
1039 | 153 | roles.insert(ModelInterface::RoleSecondaryIcon, "secondaryIcon"); | ||
1040 | 154 | roles.insert(ModelInterface::RoleActions, "actions"); | ||
1041 | 155 | roles.insert(ModelInterface::RoleHints, "hints"); | ||
1042 | 156 | roles.insert(ModelInterface::RoleNotification, "notification"); | ||
1043 | 157 | |||
1044 | 158 | return roles; | ||
1045 | 159 | } | ||
1046 | 160 | |||
1047 | 161 | void MockNotificationModel::onCompleted(int id) { | ||
1048 | 162 | remove(id); | ||
1049 | 163 | } | ||
1050 | 164 | |||
1051 | 165 | void MockNotificationModel::onDataChanged(int id) { | ||
1052 | 166 | for(int i = 0; i < m_queue.size(); i++) { | ||
1053 | 167 | if(m_queue[i]->getID() == id) { | ||
1054 | 168 | Q_EMIT dataChanged(index(i, 0), index(i, 0)); | ||
1055 | 169 | break; | ||
1056 | 170 | } | ||
1057 | 171 | } | ||
1058 | 172 | } | ||
1059 | 0 | 173 | ||
1060 | === added file 'tests/mocks/Unity/Notifications/MockNotificationModel.h' | |||
1061 | --- tests/mocks/Unity/Notifications/MockNotificationModel.h 1970-01-01 00:00:00 +0000 | |||
1062 | +++ tests/mocks/Unity/Notifications/MockNotificationModel.h 2015-02-16 22:20:44 +0000 | |||
1063 | @@ -0,0 +1,72 @@ | |||
1064 | 1 | /* | ||
1065 | 2 | * Copyright 2015 Canonical Ltd. | ||
1066 | 3 | * | ||
1067 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1068 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1069 | 6 | * the Free Software Foundation; version 3. | ||
1070 | 7 | * | ||
1071 | 8 | * This program is distributed in the hope that it will be useful, | ||
1072 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1073 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1074 | 11 | * GNU Lesser General Public License for more details. | ||
1075 | 12 | * | ||
1076 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1077 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1078 | 15 | * | ||
1079 | 16 | * Authors: | ||
1080 | 17 | * Mirco Mueller <mirco.mueller@canonical.com> | ||
1081 | 18 | */ | ||
1082 | 19 | |||
1083 | 20 | #ifndef MOCK_NOTIFICATION_MODEL_H | ||
1084 | 21 | #define MOCK_NOTIFICATION_MODEL_H | ||
1085 | 22 | |||
1086 | 23 | #include <QAbstractListModel> | ||
1087 | 24 | #include <QSharedPointer> | ||
1088 | 25 | #include <QScopedPointer> | ||
1089 | 26 | #include "MockNotification.h" | ||
1090 | 27 | |||
1091 | 28 | class MockNotification; | ||
1092 | 29 | |||
1093 | 30 | class MockNotificationModel : public QAbstractListModel { | ||
1094 | 31 | Q_OBJECT | ||
1095 | 32 | Q_PROPERTY(int count READ getCount) | ||
1096 | 33 | |||
1097 | 34 | public: | ||
1098 | 35 | MockNotificationModel(QObject *parent=nullptr); | ||
1099 | 36 | virtual ~MockNotificationModel(); | ||
1100 | 37 | |||
1101 | 38 | virtual int rowCount(const QModelIndex &parent) const; | ||
1102 | 39 | virtual QVariant data(const QModelIndex &index, int role) const; | ||
1103 | 40 | virtual QHash<int, QByteArray> roleNames() const; | ||
1104 | 41 | |||
1105 | 42 | Q_INVOKABLE void append(MockNotification* n); | ||
1106 | 43 | MockNotification* getNotification(int id) const; | ||
1107 | 44 | |||
1108 | 45 | // getRaw() is only meant to be used from QML, since QML cannot handle | ||
1109 | 46 | // QSharedPointers... on C++-side only use getNotification() | ||
1110 | 47 | Q_INVOKABLE MockNotification* getRaw(const int notificationId) const; | ||
1111 | 48 | |||
1112 | 49 | Q_INVOKABLE int queued() const; | ||
1113 | 50 | Q_INVOKABLE void remove(const int id); | ||
1114 | 51 | Q_INVOKABLE void removeSecond(); | ||
1115 | 52 | |||
1116 | 53 | int getCount() const; | ||
1117 | 54 | |||
1118 | 55 | Q_SIGNALS: | ||
1119 | 56 | void actionInvoked(const QString &action); | ||
1120 | 57 | |||
1121 | 58 | public Q_SLOTS: | ||
1122 | 59 | void onCompleted(int id); | ||
1123 | 60 | |||
1124 | 61 | private Q_SLOTS: | ||
1125 | 62 | void onDataChanged(int id); | ||
1126 | 63 | |||
1127 | 64 | Q_SIGNALS: | ||
1128 | 65 | void queueSizeChanged(int newSize); | ||
1129 | 66 | |||
1130 | 67 | private: | ||
1131 | 68 | QList<MockNotification*> m_queue; | ||
1132 | 69 | void removeInternal(int loc); | ||
1133 | 70 | }; | ||
1134 | 71 | |||
1135 | 72 | #endif | ||
1136 | 0 | 73 | ||
1137 | === modified file 'tests/mocks/Unity/Notifications/plugin.cpp' | |||
1138 | --- tests/mocks/Unity/Notifications/plugin.cpp 2014-11-05 00:17:50 +0000 | |||
1139 | +++ tests/mocks/Unity/Notifications/plugin.cpp 2015-02-16 22:20:44 +0000 | |||
1140 | @@ -1,5 +1,5 @@ | |||
1141 | 1 | /* | 1 | /* |
1143 | 2 | * Copyright 2014 Canonical Ltd. | 2 | * Copyright 2015 Canonical Ltd. |
1144 | 3 | * | 3 | * |
1145 | 4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
1146 | 5 | * it under the terms of the GNU Lesser General Public License as published by | 5 | * it under the terms of the GNU Lesser General Public License as published by |
1147 | @@ -19,13 +19,15 @@ | |||
1148 | 19 | 19 | ||
1149 | 20 | #include "plugin.h" | 20 | #include "plugin.h" |
1150 | 21 | #include "MockActionModel.h" | 21 | #include "MockActionModel.h" |
1152 | 22 | #include "MockNotificationTypes.h" | 22 | #include "MockNotification.h" |
1153 | 23 | #include "MockNotificationModel.h" | ||
1154 | 23 | 24 | ||
1155 | 24 | #include <QtQml/qqml.h> | 25 | #include <QtQml/qqml.h> |
1156 | 25 | 26 | ||
1157 | 26 | void TestNotificationPlugin::registerTypes(const char* uri) | 27 | void TestNotificationPlugin::registerTypes(const char* uri) |
1158 | 27 | { | 28 | { |
1159 | 28 | // @uri Unity.Notifications | 29 | // @uri Unity.Notifications |
1161 | 29 | qmlRegisterUncreatableType<MockNotification>(uri, 1, 0, "Notification", "Notification objects can only be created by the plugin"); | 30 | qmlRegisterType<MockNotification>(uri, 1, 0, "Notification"); |
1162 | 31 | qmlRegisterType<MockNotificationModel>(uri, 1, 0, "NotificationModel"); | ||
1163 | 30 | qmlRegisterType<ActionModel>(uri, 1, 0, "ActionModel"); | 32 | qmlRegisterType<ActionModel>(uri, 1, 0, "ActionModel"); |
1164 | 31 | } | 33 | } |
1165 | 32 | 34 | ||
1166 | === modified file 'tests/mocks/Unity/Notifications/plugin.h' | |||
1167 | --- tests/mocks/Unity/Notifications/plugin.h 2014-11-05 00:17:50 +0000 | |||
1168 | +++ tests/mocks/Unity/Notifications/plugin.h 2015-02-16 22:20:44 +0000 | |||
1169 | @@ -1,5 +1,5 @@ | |||
1170 | 1 | /* | 1 | /* |
1172 | 2 | * Copyright 2014 Canonical Ltd. | 2 | * Copyright 2015 Canonical Ltd. |
1173 | 3 | * | 3 | * |
1174 | 4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
1175 | 5 | * it under the terms of the GNU Lesser General Public License as published by | 5 | * it under the terms of the GNU Lesser General Public License as published by |
1176 | @@ -17,7 +17,6 @@ | |||
1177 | 17 | * Mirco Mueller <mirco.mueller@canonical.com> | 17 | * Mirco Mueller <mirco.mueller@canonical.com> |
1178 | 18 | */ | 18 | */ |
1179 | 19 | 19 | ||
1180 | 20 | |||
1181 | 21 | #ifndef TESTNOTIFICATION_PLUGIN_H | 20 | #ifndef TESTNOTIFICATION_PLUGIN_H |
1182 | 22 | #define TESTNOTIFICATION_PLUGIN_H | 21 | #define TESTNOTIFICATION_PLUGIN_H |
1183 | 23 | 22 | ||
1184 | 24 | 23 | ||
1185 | === modified file 'tests/qmltests/CMakeLists.txt' | |||
1186 | --- tests/qmltests/CMakeLists.txt 2015-01-14 10:17:12 +0000 | |||
1187 | +++ tests/qmltests/CMakeLists.txt 2015-02-16 22:20:44 +0000 | |||
1188 | @@ -13,6 +13,7 @@ | |||
1189 | 13 | set(qmltest_DEFAULT_NO_ADD_TEST FALSE) | 13 | set(qmltest_DEFAULT_NO_ADD_TEST FALSE) |
1190 | 14 | set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal") | 14 | set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal") |
1191 | 15 | add_qml_test(utils/Unity/Test UnityTest) | 15 | add_qml_test(utils/Unity/Test UnityTest) |
1192 | 16 | add_qml_test(Components PhysicalKeysMapper) | ||
1193 | 16 | 17 | ||
1194 | 17 | set(qmltest_DEFAULT_TARGETS qmluitests) | 18 | set(qmltest_DEFAULT_TARGETS qmluitests) |
1195 | 18 | set(qmltest_DEFAULT_NO_ADD_TEST TRUE) | 19 | set(qmltest_DEFAULT_NO_ADD_TEST TRUE) |
1196 | 19 | 20 | ||
1197 | === added file 'tests/qmltests/Components/tst_PhysicalKeysMapper.qml' | |||
1198 | --- tests/qmltests/Components/tst_PhysicalKeysMapper.qml 1970-01-01 00:00:00 +0000 | |||
1199 | +++ tests/qmltests/Components/tst_PhysicalKeysMapper.qml 2015-02-16 22:20:44 +0000 | |||
1200 | @@ -0,0 +1,119 @@ | |||
1201 | 1 | /* | ||
1202 | 2 | * Copyright (C) 2014-2015 Canonical, Ltd. | ||
1203 | 3 | * | ||
1204 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1205 | 5 | * it under the terms of the GNU General Public License as published by | ||
1206 | 6 | * the Free Software Foundation; version 3. | ||
1207 | 7 | * | ||
1208 | 8 | * This program is distributed in the hope that it will be useful, | ||
1209 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1210 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1211 | 11 | * GNU General Public License for more details. | ||
1212 | 12 | * | ||
1213 | 13 | * You should have received a copy of the GNU General Public License | ||
1214 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1215 | 15 | */ | ||
1216 | 16 | |||
1217 | 17 | import QtQuick 2.0 | ||
1218 | 18 | import QtTest 1.0 | ||
1219 | 19 | import "../../../qml/Components" | ||
1220 | 20 | |||
1221 | 21 | TestCase { | ||
1222 | 22 | name: "PhysicalKeysMapper" | ||
1223 | 23 | |||
1224 | 24 | Loader { | ||
1225 | 25 | // Using a Loader here to make sure mapper state is coherent | ||
1226 | 26 | // regardless of unmatched KeyPress and KeyRelease events | ||
1227 | 27 | id: loader | ||
1228 | 28 | active: false | ||
1229 | 29 | sourceComponent: PhysicalKeysMapper { } | ||
1230 | 30 | } | ||
1231 | 31 | |||
1232 | 32 | SignalSpy { | ||
1233 | 33 | id: powerSpy | ||
1234 | 34 | target: loader.item | ||
1235 | 35 | signalName: "powerKeyLongPressed" | ||
1236 | 36 | } | ||
1237 | 37 | |||
1238 | 38 | SignalSpy { | ||
1239 | 39 | id: volumeDownSpy | ||
1240 | 40 | target: loader.item | ||
1241 | 41 | signalName: "volumeDownTriggered" | ||
1242 | 42 | } | ||
1243 | 43 | |||
1244 | 44 | SignalSpy { | ||
1245 | 45 | id: volumeUpSpy | ||
1246 | 46 | target: loader.item | ||
1247 | 47 | signalName: "volumeUpTriggered" | ||
1248 | 48 | } | ||
1249 | 49 | |||
1250 | 50 | SignalSpy { | ||
1251 | 51 | id: screenshotSpy | ||
1252 | 52 | target: loader.item | ||
1253 | 53 | signalName: "screenshotTriggered" | ||
1254 | 54 | } | ||
1255 | 55 | |||
1256 | 56 | function init() { | ||
1257 | 57 | loader.active = true; | ||
1258 | 58 | tryCompare(loader.status == Loader.Ready); | ||
1259 | 59 | } | ||
1260 | 60 | |||
1261 | 61 | function cleanup() { | ||
1262 | 62 | loader.active = false; | ||
1263 | 63 | powerSpy.clear(); | ||
1264 | 64 | volumeDownSpy.clear(); | ||
1265 | 65 | volumeUpSpy.clear(); | ||
1266 | 66 | screenshotSpy.clear(); | ||
1267 | 67 | } | ||
1268 | 68 | |||
1269 | 69 | function test_LongPressPowerButton() { | ||
1270 | 70 | loader.item.onKeyPressed({ key: Qt.Key_PowerDown }); | ||
1271 | 71 | |||
1272 | 72 | expectFailContinue("", "Power signal should not be emitted within a second"); | ||
1273 | 73 | powerSpy.wait(1000); | ||
1274 | 74 | powerSpy.clear(); | ||
1275 | 75 | |||
1276 | 76 | loader.item.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: true }); | ||
1277 | 77 | powerSpy.wait(1500); | ||
1278 | 78 | } | ||
1279 | 79 | |||
1280 | 80 | function test_ScreenshotButtons_data() { | ||
1281 | 81 | return [ | ||
1282 | 82 | { tag: "UpFirst", first: Qt.Key_VolumeUp, second: Qt.Key_VolumeDown }, | ||
1283 | 83 | { tag: "DownFirst", first: Qt.Key_VolumeDown, second: Qt.Key_VolumeUp }, | ||
1284 | 84 | ]; | ||
1285 | 85 | } | ||
1286 | 86 | |||
1287 | 87 | function test_ScreenshotButtons(data) { | ||
1288 | 88 | loader.item.onKeyPressed({ key: data.first }); | ||
1289 | 89 | loader.item.onKeyPressed({ key: data.second }); | ||
1290 | 90 | screenshotSpy.wait(); | ||
1291 | 91 | loader.item.onKeyReleased({ key: data.first }); | ||
1292 | 92 | loader.item.onKeyReleased({ key: data.second }); | ||
1293 | 93 | expectFailContinue("", "VolumeUp signal should not fire"); | ||
1294 | 94 | volumeUpSpy.wait(100); | ||
1295 | 95 | expectFailContinue("", "VolumeDown signal should not fire"); | ||
1296 | 96 | volumeDownSpy.wait(100); | ||
1297 | 97 | } | ||
1298 | 98 | |||
1299 | 99 | function test_VolumeButton_data() { | ||
1300 | 100 | return [ | ||
1301 | 101 | { tag: "Down", key: Qt.Key_VolumeDown, spy: volumeDownSpy }, | ||
1302 | 102 | { tag: "Up", key: Qt.Key_VolumeUp, spy: volumeUpSpy }, | ||
1303 | 103 | ]; | ||
1304 | 104 | } | ||
1305 | 105 | |||
1306 | 106 | function test_VolumeButton(data) { | ||
1307 | 107 | loader.item.onKeyPressed({ key: data.key }); | ||
1308 | 108 | expectFailContinue("", "Signal should not fire on press"); | ||
1309 | 109 | data.spy.wait(100); | ||
1310 | 110 | data.spy.clear(); | ||
1311 | 111 | |||
1312 | 112 | loader.item.onKeyReleased({ key: data.key }); | ||
1313 | 113 | data.spy.wait(); | ||
1314 | 114 | |||
1315 | 115 | loader.item.onKeyPressed({ key: data.key }); | ||
1316 | 116 | loader.item.onKeyPressed({ key: data.key, isAutoRepeat: true }); | ||
1317 | 117 | data.spy.wait(); | ||
1318 | 118 | } | ||
1319 | 119 | } | ||
1320 | 0 | 120 | ||
1321 | === modified file 'tests/qmltests/Dash/tst_Card.qml' | |||
1322 | --- tests/qmltests/Dash/tst_Card.qml 2015-01-08 12:51:33 +0000 | |||
1323 | +++ tests/qmltests/Dash/tst_Card.qml 2015-02-16 22:20:44 +0000 | |||
1324 | @@ -60,8 +60,8 @@ | |||
1325 | 60 | "layout": { "components": Helpers.update(JSON.parse(Helpers.fullMapping), { "art": { "aspect-ratio": 0.7 } }) } | 60 | "layout": { "components": Helpers.update(JSON.parse(Helpers.fullMapping), { "art": { "aspect-ratio": 0.7 } }) } |
1326 | 61 | }, | 61 | }, |
1327 | 62 | { | 62 | { |
1330 | 63 | "name": "Art, header, summary - horizontal", | 63 | "name": "Art, header, summary, background - horizontal", |
1331 | 64 | "layout": { "template": { "card-layout": "horizontal" }, | 64 | "layout": { "template": { "card-layout": "horizontal", "card-background": { "type": "gradient", "elements": ["grey", "white"] } }, |
1332 | 65 | "components": JSON.parse(Helpers.fullMapping) } | 65 | "components": JSON.parse(Helpers.fullMapping) } |
1333 | 66 | }, | 66 | }, |
1334 | 67 | { | 67 | { |
1335 | @@ -101,6 +101,11 @@ | |||
1336 | 101 | "layout": { "template": { "overlay": true }, | 101 | "layout": { "template": { "overlay": true }, |
1337 | 102 | "components": { "art": "art", "title": "title" } } | 102 | "components": { "art": "art", "title": "title" } } |
1338 | 103 | }, | 103 | }, |
1339 | 104 | { | ||
1340 | 105 | "name": "Art, header, summary - horizontal", | ||
1341 | 106 | "layout": { "template": { "card-layout": "horizontal" }, | ||
1342 | 107 | "components": JSON.parse(Helpers.fullMapping) } | ||
1343 | 108 | }, | ||
1344 | 104 | ] | 109 | ] |
1345 | 105 | 110 | ||
1346 | 106 | CardTool { | 111 | CardTool { |
1347 | @@ -407,7 +412,7 @@ | |||
1348 | 407 | return [ | 412 | return [ |
1349 | 408 | { tag: "Art and summary", visible: true, color: "#ffffff", index: 0 }, | 413 | { tag: "Art and summary", visible: true, color: "#ffffff", index: 0 }, |
1350 | 409 | { tag: "No Summary", visible: false, index: 6 }, | 414 | { tag: "No Summary", visible: false, index: 6 }, |
1352 | 410 | { tag: "Horizontal", visible: false, index: 5 }, | 415 | { tag: "Horizontal", visible: true, color: "#808080", index: 5 }, |
1353 | 411 | { tag: "Grey background", visible: true, color: "#808080", index: 10 }, | 416 | { tag: "Grey background", visible: true, color: "#808080", index: 10 }, |
1354 | 412 | { tag: "Overriden Gradient background", visible: true, color: "#808080", gradientColor: "#ffffff", | 417 | { tag: "Overriden Gradient background", visible: true, color: "#808080", gradientColor: "#ffffff", |
1355 | 413 | background: {type: "color", elements: ["grey", "white"]}, index: 10 }, | 418 | background: {type: "color", elements: ["grey", "white"]}, index: 10 }, |
1356 | @@ -415,6 +420,7 @@ | |||
1357 | 415 | background: Qt.resolvedUrl("artwork/checkers.png"), index: 10 }, | 420 | background: Qt.resolvedUrl("artwork/checkers.png"), index: 10 }, |
1358 | 416 | { tag: "Gradient background", visible: true, color: "#808080", gradientColor: "#ffffff", index: 11 }, | 421 | { tag: "Gradient background", visible: true, color: "#808080", gradientColor: "#ffffff", index: 11 }, |
1359 | 417 | { tag: "Image background", visible: true, image: Qt.resolvedUrl("artwork/checkers.png"), index: 12 }, | 422 | { tag: "Image background", visible: true, image: Qt.resolvedUrl("artwork/checkers.png"), index: 12 }, |
1360 | 423 | { tag: "Horizontal no background", visible: false, index: 14 }, | ||
1361 | 418 | ]; | 424 | ]; |
1362 | 419 | } | 425 | } |
1363 | 420 | 426 | ||
1364 | 421 | 427 | ||
1365 | === added file 'tests/qmltests/Notifications/Notification.qml' | |||
1366 | --- tests/qmltests/Notifications/Notification.qml 1970-01-01 00:00:00 +0000 | |||
1367 | +++ tests/qmltests/Notifications/Notification.qml 2015-02-16 22:20:44 +0000 | |||
1368 | @@ -0,0 +1,31 @@ | |||
1369 | 1 | /* | ||
1370 | 2 | * Copyright 2015 Canonical Ltd. | ||
1371 | 3 | * | ||
1372 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1373 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1374 | 6 | * the Free Software Foundation; version 3. | ||
1375 | 7 | * | ||
1376 | 8 | * This program is distributed in the hope that it will be useful, | ||
1377 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1378 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1379 | 11 | * GNU Lesser General Public License for more details. | ||
1380 | 12 | * | ||
1381 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1382 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1383 | 15 | * | ||
1384 | 16 | * Authors: | ||
1385 | 17 | * Mirco Mueller <mirco.mueller@canonical.com> | ||
1386 | 18 | */ | ||
1387 | 19 | |||
1388 | 20 | import Unity.Notifications 1.0 | ||
1389 | 21 | |||
1390 | 22 | Notification { | ||
1391 | 23 | nid: 0 | ||
1392 | 24 | type: Notification.PlaceHolder | ||
1393 | 25 | summary: "" | ||
1394 | 26 | body: "" | ||
1395 | 27 | icon: "" | ||
1396 | 28 | secondaryIcon: "" | ||
1397 | 29 | value: 0 | ||
1398 | 30 | rawActions: [] | ||
1399 | 31 | } | ||
1400 | 0 | 32 | ||
1401 | === modified file 'tests/qmltests/Notifications/tst_Notifications.qml' | |||
1402 | --- tests/qmltests/Notifications/tst_Notifications.qml 2014-11-10 09:14:30 +0000 | |||
1403 | +++ tests/qmltests/Notifications/tst_Notifications.qml 2015-02-16 22:20:44 +0000 | |||
1404 | @@ -1,17 +1,20 @@ | |||
1405 | 1 | /* | 1 | /* |
1407 | 2 | * Copyright (C) 2013 Canonical, Ltd. | 2 | * Copyright 2015 Canonical Ltd. |
1408 | 3 | * | 3 | * |
1409 | 4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
1411 | 5 | * it under the terms of the GNU General Public License as published by | 5 | * it under the terms of the GNU Lesser General Public License as published by |
1412 | 6 | * the Free Software Foundation; version 3. | 6 | * the Free Software Foundation; version 3. |
1413 | 7 | * | 7 | * |
1414 | 8 | * This program is distributed in the hope that it will be useful, | 8 | * This program is distributed in the hope that it will be useful, |
1415 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1416 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1418 | 11 | * GNU General Public License for more details. | 11 | * GNU Lesser General Public License for more details. |
1419 | 12 | * | 12 | * |
1421 | 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU Lesser General Public License |
1422 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1423 | 15 | * | ||
1424 | 16 | * Authors: | ||
1425 | 17 | * Mirco Mueller <mirco.mueller@canonical.com> | ||
1426 | 15 | */ | 18 | */ |
1427 | 16 | 19 | ||
1428 | 17 | import QtQuick 2.0 | 20 | import QtQuick 2.0 |
1429 | @@ -24,146 +27,134 @@ | |||
1430 | 24 | import QtMultimedia 5.0 | 27 | import QtMultimedia 5.0 |
1431 | 25 | 28 | ||
1432 | 26 | Item { | 29 | Item { |
1433 | 30 | id: foobar | ||
1434 | 31 | |||
1435 | 27 | width: notificationsRect.width + interactiveControls.width | 32 | width: notificationsRect.width + interactiveControls.width |
1436 | 28 | height: notificationsRect.height | 33 | height: notificationsRect.height |
1437 | 34 | property int index: 0 | ||
1438 | 29 | 35 | ||
1439 | 30 | Row { | 36 | Row { |
1440 | 31 | id: rootRow | 37 | id: rootRow |
1441 | 32 | 38 | ||
1453 | 33 | Component { | 39 | NotificationModel { |
1443 | 34 | id: mockNotification | ||
1444 | 35 | |||
1445 | 36 | QtObject { | ||
1446 | 37 | function invokeAction(actionId) { | ||
1447 | 38 | mockModel.actionInvoked(actionId) | ||
1448 | 39 | } | ||
1449 | 40 | } | ||
1450 | 41 | } | ||
1451 | 42 | |||
1452 | 43 | ListModel { | ||
1454 | 44 | id: mockModel | 40 | id: mockModel |
1455 | 45 | dynamicRoles: true | ||
1456 | 46 | |||
1457 | 47 | signal actionInvoked(string actionId) | ||
1458 | 48 | |||
1459 | 49 | function getRaw(id) { | ||
1460 | 50 | return mockNotification.createObject(mockModel) | ||
1461 | 51 | } | ||
1462 | 52 | 41 | ||
1463 | 53 | // add the default/PlaceHolder notification to the model | 42 | // add the default/PlaceHolder notification to the model |
1464 | 54 | Component.onCompleted: { | 43 | Component.onCompleted: { |
1475 | 55 | var n = { | 44 | var component = Qt.createComponent("Notification.qml") |
1476 | 56 | type: Notification.PlaceHolder, | 45 | var n = component.createObject("notification", {"nid": index++, |
1477 | 57 | hints: {}, | 46 | "type": Notification.PlaceHolder, |
1478 | 58 | summary: "", | 47 | "hints": {}, |
1479 | 59 | body: "", | 48 | "summary": "", |
1480 | 60 | icon: "", | 49 | "body": "", |
1481 | 61 | secondaryIcon: "", | 50 | "icon": "", |
1482 | 62 | actions: [] | 51 | "secondaryIcon": "", |
1483 | 63 | } | 52 | "rawActions": []}) |
1484 | 64 | 53 | n.completed.connect(mockModel.onCompleted) | |
1485 | 65 | append(n) | 54 | append(n) |
1486 | 66 | } | 55 | } |
1487 | 67 | } | 56 | } |
1488 | 68 | 57 | ||
1489 | 69 | function add2over1SnapDecisionNotification() { | 58 | function add2over1SnapDecisionNotification() { |
1502 | 70 | var n = { | 59 | var component = Qt.createComponent("Notification.qml") |
1503 | 71 | type: Notification.SnapDecision, | 60 | var n = component.createObject("notification", {"nid": index++, |
1504 | 72 | hints: {"x-canonical-private-affirmative-tint": "true"}, | 61 | "type": Notification.SnapDecision, |
1505 | 73 | summary: "Theatre at Ferria Stadium", | 62 | "hints": {"x-canonical-private-affirmative-tint": "true"}, |
1506 | 74 | body: "at Ferria Stadium in Bilbao, Spain\n07578545317", | 63 | "summary": "Theatre at Ferria Stadium", |
1507 | 75 | icon: "", | 64 | "body": "at Ferria Stadium in Bilbao, Spain\n07578545317", |
1508 | 76 | secondaryIcon: "", | 65 | "icon": "", |
1509 | 77 | actions: [{ id: "ok_id", label: "Ok"}, | 66 | "secondaryIcon": "", |
1510 | 78 | { id: "snooze_id", label: "Snooze"}, | 67 | "rawActions": ["ok_id", "Ok", |
1511 | 79 | { id: "view_id", label: "View"}] | 68 | "snooze_id", "Snooze", |
1512 | 80 | } | 69 | "view_id", "View"]}) |
1513 | 81 | 70 | n.completed.connect(mockModel.onCompleted) | |
1514 | 82 | mockModel.append(n) | 71 | mockModel.append(n) |
1515 | 83 | } | 72 | } |
1516 | 84 | 73 | ||
1517 | 85 | function addEphemeralNotification() { | 74 | function addEphemeralNotification() { |
1527 | 86 | var n = { | 75 | var component = Qt.createComponent("Notification.qml") |
1528 | 87 | type: Notification.Ephemeral, | 76 | var n = component.createObject("notification", {"nid": index++, |
1529 | 88 | summary: "Cole Raby", | 77 | "type": Notification.Ephemeral, |
1530 | 89 | body: "I did not expect it to be that late.", | 78 | "hints": {}, |
1531 | 90 | icon: "../graphics/avatars/amanda.png", | 79 | "summary": "Cole Raby", |
1532 | 91 | secondaryIcon: "../graphics/applicationIcons/facebook.png", | 80 | "body": "I did not expect it to be that late.", |
1533 | 92 | actions: [] | 81 | "icon": "../graphics/avatars/amanda.png", |
1534 | 93 | } | 82 | "secondaryIcon": "../graphics/applicationIcons/facebook.png", |
1535 | 94 | 83 | "rawActions": ["reply_id", "Dummy"]}) | |
1536 | 84 | n.completed.connect(mockModel.onCompleted) | ||
1537 | 95 | mockModel.append(n) | 85 | mockModel.append(n) |
1538 | 96 | } | 86 | } |
1539 | 97 | 87 | ||
1540 | 98 | function addEphemeralNonShapedIconNotification() { | 88 | function addEphemeralNonShapedIconNotification() { |
1551 | 99 | var n = { | 89 | var component = Qt.createComponent("Notification.qml") |
1552 | 100 | type: Notification.Ephemeral, | 90 | var n = component.createObject("notification", {"nid": index++, |
1553 | 101 | hints: {"x-canonical-non-shaped-icon": "true"}, | 91 | "type": Notification.Ephemeral, |
1554 | 102 | summary: "Contacts", | 92 | "hints": {"x-canonical-non-shaped-icon": "true"}, |
1555 | 103 | body: "Synchronised contacts-database with cloud-storage.", | 93 | "summary": "Contacts", |
1556 | 104 | icon: "../graphics/applicationIcons/contacts-app.png", | 94 | "body": "Synchronised contacts-database with cloud-storage.", |
1557 | 105 | secondaryIcon: "", | 95 | "icon": "../graphics/applicationIcons/contacts-app.png", |
1558 | 106 | actions: [] | 96 | "secondaryIcon": "", |
1559 | 107 | } | 97 | "rawActions": ["reply_id", "Dummy"]}) |
1560 | 108 | 98 | n.completed.connect(mockModel.onCompleted) | |
1561 | 109 | mockModel.append(n) | 99 | mockModel.append(n) |
1562 | 110 | } | 100 | } |
1563 | 111 | 101 | ||
1564 | 112 | function addEphemeralIconSummaryNotification() { | 102 | function addEphemeralIconSummaryNotification() { |
1575 | 113 | var n = { | 103 | var component = Qt.createComponent("Notification.qml") |
1576 | 114 | type: Notification.Ephemeral, | 104 | var n = component.createObject("notification", {"nid": index++, |
1577 | 115 | hints: {"x-canonical-non-shaped-icon": "false"}, | 105 | "type": Notification.Ephemeral, |
1578 | 116 | summary: "Photo upload completed", | 106 | "hints": {"x-canonical-non-shaped-icon": "false"}, |
1579 | 117 | body: "", | 107 | "summary": "Photo upload completed", |
1580 | 118 | icon: "../graphics/applicationIcons/facebook.png", | 108 | "body": "", |
1581 | 119 | secondaryIcon: "", | 109 | "icon": "../graphics/applicationIcons/facebook.png", |
1582 | 120 | actions: [] | 110 | "secondaryIcon": "", |
1583 | 121 | } | 111 | "rawActions": ["reply_id", "Dummy"]}) |
1584 | 122 | 112 | n.completed.connect(mockModel.onCompleted) | |
1585 | 123 | mockModel.append(n) | 113 | mockModel.append(n) |
1586 | 124 | } | 114 | } |
1587 | 125 | 115 | ||
1588 | 126 | function addInteractiveNotification() { | 116 | function addInteractiveNotification() { |
1598 | 127 | var n = { | 117 | var component = Qt.createComponent("Notification.qml") |
1599 | 128 | type: Notification.Interactive, | 118 | var n = component.createObject("notification", {"nid": index++, |
1600 | 129 | summary: "Interactive notification", | 119 | "type": Notification.Interactive, |
1601 | 130 | body: "This is a notification that can be clicked", | 120 | "hints": {}, |
1602 | 131 | icon: "../graphics/avatars/anna_olsson.png", | 121 | "summary": "Interactive notification", |
1603 | 132 | secondaryIcon: "", | 122 | "body": "This is a notification that can be clicked", |
1604 | 133 | actions: [{ id: "reply_id", label: "Dummy"}], | 123 | "icon": "../graphics/avatars/anna_olsson.png", |
1605 | 134 | } | 124 | "secondaryIcon": "", |
1606 | 135 | 125 | "rawActions": ["reply_id", "Dummy"]}) | |
1607 | 126 | n.completed.connect(mockModel.onCompleted) | ||
1608 | 136 | mockModel.append(n) | 127 | mockModel.append(n) |
1609 | 137 | } | 128 | } |
1610 | 138 | 129 | ||
1611 | 139 | function addConfirmationNotification() { | 130 | function addConfirmationNotification() { |
1623 | 140 | var n = { | 131 | var component = Qt.createComponent("Notification.qml") |
1624 | 141 | type: Notification.Confirmation, | 132 | var n = component.createObject("notification", {"nid": index++, |
1625 | 142 | hints: {"x-canonical-non-shaped-icon": "true"}, | 133 | "type": Notification.Confirmation, |
1626 | 143 | summary: "Confirmation notification", | 134 | "hints": {"x-canonical-non-shaped-icon": "true"}, |
1627 | 144 | body: "", | 135 | "summary": "Confirmation notification", |
1628 | 145 | icon: "image://theme/audio-volume-medium", | 136 | "body": "", |
1629 | 146 | secondaryIcon: "", | 137 | "icon": "image://theme/audio-volume-medium", |
1630 | 147 | value: 50, | 138 | "secondaryIcon": "", |
1631 | 148 | actions: [], | 139 | "value": 50, |
1632 | 149 | } | 140 | "rawActions": ["reply_id", "Dummy"]}) |
1633 | 150 | 141 | n.completed.connect(mockModel.onCompleted) | |
1634 | 151 | mockModel.append(n) | 142 | mockModel.append(n) |
1635 | 152 | } | 143 | } |
1636 | 153 | 144 | ||
1637 | 154 | function add2ndConfirmationNotification() { | 145 | function add2ndConfirmationNotification() { |
1650 | 155 | var n = { | 146 | var component = Qt.createComponent("Notification.qml") |
1651 | 156 | type: Notification.Confirmation, | 147 | var n = component.createObject("notification", {"nid": index++, |
1652 | 157 | hints: {"x-canonical-non-shaped-icon": "true", | 148 | "type": Notification.Confirmation, |
1653 | 158 | "x-canonical-value-bar-tint": "true"}, | 149 | "hints": {"x-canonical-non-shaped-icon": "true", |
1654 | 159 | summary: "Confirmation notification", | 150 | "x-canonical-value-bar-tint": "true"}, |
1655 | 160 | body: "High Volume", | 151 | "summary": "Confirmation notification", |
1656 | 161 | icon: "image://theme/audio-volume-high", | 152 | "body": "High Volume", |
1657 | 162 | secondaryIcon: "", | 153 | "icon": "image://theme/audio-volume-high", |
1658 | 163 | value: 85, | 154 | "secondaryIcon": "", |
1659 | 164 | actions: [], | 155 | "value": 85, |
1660 | 165 | } | 156 | "rawActions": ["reply_id", "Dummy"]}) |
1661 | 166 | 157 | n.completed.connect(mockModel.onCompleted) | |
1662 | 167 | mockModel.append(n) | 158 | mockModel.append(n) |
1663 | 168 | } | 159 | } |
1664 | 169 | 160 | ||
1665 | @@ -174,8 +165,9 @@ | |||
1666 | 174 | } | 165 | } |
1667 | 175 | 166 | ||
1668 | 176 | function remove1stNotification() { | 167 | function remove1stNotification() { |
1671 | 177 | if (mockModel.count > 1) | 168 | if (mockModel.count > 1) { |
1672 | 178 | mockModel.remove(1) | 169 | mockModel.removeSecond() |
1673 | 170 | } | ||
1674 | 179 | } | 171 | } |
1675 | 180 | 172 | ||
1676 | 181 | Rectangle { | 173 | Rectangle { |
1677 | @@ -273,41 +265,122 @@ | |||
1678 | 273 | name: "NotificationRendererTest" | 265 | name: "NotificationRendererTest" |
1679 | 274 | when: windowShown | 266 | when: windowShown |
1680 | 275 | 267 | ||
1681 | 268 | property list<Notification> nlist: [ | ||
1682 | 269 | Notification { | ||
1683 | 270 | nid: 1 | ||
1684 | 271 | type: Notification.Ephemeral | ||
1685 | 272 | summary: "Photo upload completed" | ||
1686 | 273 | body: "" | ||
1687 | 274 | icon: "../graphics/applicationIcons/facebook.png" | ||
1688 | 275 | secondaryIcon: "" | ||
1689 | 276 | value: 0 | ||
1690 | 277 | rawActions: [] | ||
1691 | 278 | }, | ||
1692 | 279 | Notification { | ||
1693 | 280 | nid: 2 | ||
1694 | 281 | type: Notification.Ephemeral | ||
1695 | 282 | hints: {"x-canonical-private-affirmative-tint": "false", | ||
1696 | 283 | "sound-file": "dummy.ogg", | ||
1697 | 284 | "suppress-sound": "true"} | ||
1698 | 285 | summary: "New comment successfully published" | ||
1699 | 286 | body: "" | ||
1700 | 287 | icon: "" | ||
1701 | 288 | secondaryIcon: "../graphics/applicationIcons/facebook.png" | ||
1702 | 289 | value: 0 | ||
1703 | 290 | rawActions: [] | ||
1704 | 291 | }, | ||
1705 | 292 | Notification { | ||
1706 | 293 | nid: 3 | ||
1707 | 294 | type: Notification.Interactive | ||
1708 | 295 | hints: {"x-canonical-private-affirmative-tint": "false", | ||
1709 | 296 | "sound-file": "dummy.ogg"} | ||
1710 | 297 | summary: "Interactive notification" | ||
1711 | 298 | body: "This is a notification that can be clicked" | ||
1712 | 299 | icon: "../graphics/avatars/amanda.png" | ||
1713 | 300 | secondaryIcon: "" | ||
1714 | 301 | value: 0 | ||
1715 | 302 | rawActions: ["reply_id", "Dummy"] | ||
1716 | 303 | }, | ||
1717 | 304 | Notification { | ||
1718 | 305 | nid: 4 | ||
1719 | 306 | type: Notification.SnapDecision | ||
1720 | 307 | hints: {"x-canonical-private-affirmative-tint": "false", | ||
1721 | 308 | "sound-file": "dummy.ogg"} | ||
1722 | 309 | summary: "Bro Coly" | ||
1723 | 310 | body: "At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." | ||
1724 | 311 | icon: "../graphics/avatars/anna_olsson.png" | ||
1725 | 312 | secondaryIcon: "" | ||
1726 | 313 | value: 0 | ||
1727 | 314 | rawActions: ["accept_id", "Accept", | ||
1728 | 315 | "reject_id", "Reject"] | ||
1729 | 316 | }, | ||
1730 | 317 | Notification { | ||
1731 | 318 | nid: 5 | ||
1732 | 319 | type: Notification.Ephemeral | ||
1733 | 320 | hints: {"x-canonical-private-affirmative-tint": "false", | ||
1734 | 321 | "sound-file": "dummy.ogg"} | ||
1735 | 322 | summary: "Cole Raby" | ||
1736 | 323 | body: "I did not expect it to be that late." | ||
1737 | 324 | icon: "../graphics/avatars/funky.png" | ||
1738 | 325 | secondaryIcon: "../graphics/applicationIcons/facebook.png" | ||
1739 | 326 | value: 0 | ||
1740 | 327 | rawActions: [] | ||
1741 | 328 | }, | ||
1742 | 329 | Notification { | ||
1743 | 330 | nid: 6 | ||
1744 | 331 | type: Notification.Ephemeral | ||
1745 | 332 | hints: {"x-canonical-private-affirmative-tint": "false", | ||
1746 | 333 | "x-canonical-non-shaped-icon": "true"} | ||
1747 | 334 | summary: "Contacts" | ||
1748 | 335 | body: "Synchronised contacts-database with cloud-storage." | ||
1749 | 336 | icon: "image://theme/contacts-app" | ||
1750 | 337 | secondaryIcon: "" | ||
1751 | 338 | value: 0 | ||
1752 | 339 | rawActions: [] | ||
1753 | 340 | }, | ||
1754 | 341 | Notification { | ||
1755 | 342 | nid: 7 | ||
1756 | 343 | type: Notification.Confirmation | ||
1757 | 344 | hints: {"x-canonical-non-shaped-icon": "true"} | ||
1758 | 345 | summary: "" | ||
1759 | 346 | body: "" | ||
1760 | 347 | icon: "image://theme/audio-volume-medium" | ||
1761 | 348 | secondaryIcon: "" | ||
1762 | 349 | value: 50 | ||
1763 | 350 | rawActions: [] | ||
1764 | 351 | }, | ||
1765 | 352 | Notification { | ||
1766 | 353 | nid: 8 | ||
1767 | 354 | type: Notification.Confirmation | ||
1768 | 355 | hints: {"x-canonical-non-shaped-icon": "true", | ||
1769 | 356 | "x-canonical-value-bar-tint" : "true"} | ||
1770 | 357 | summary: "" | ||
1771 | 358 | body: "High Volume" | ||
1772 | 359 | icon: "image://theme/audio-volume-high" | ||
1773 | 360 | secondaryIcon: "" | ||
1774 | 361 | value: 85 | ||
1775 | 362 | rawActions: [] | ||
1776 | 363 | }, | ||
1777 | 364 | Notification { | ||
1778 | 365 | nid: 9 | ||
1779 | 366 | type: Notification.SnapDecision | ||
1780 | 367 | hints: {"x-canonical-private-affirmative-tint": "true"} | ||
1781 | 368 | summary: "Theatre at Ferria Stadium" | ||
1782 | 369 | body: "at Ferria Stadium in Bilbao, Spain\n07578545317" | ||
1783 | 370 | icon: "" | ||
1784 | 371 | secondaryIcon: "" | ||
1785 | 372 | value: 0 | ||
1786 | 373 | rawActions: ["ok_id", "Ok", | ||
1787 | 374 | "snooze_id", "Snooze", | ||
1788 | 375 | "view_id", "View"] | ||
1789 | 376 | } | ||
1790 | 377 | ] | ||
1791 | 378 | |||
1792 | 276 | function test_NotificationRenderer_data() { | 379 | function test_NotificationRenderer_data() { |
1793 | 277 | return [ | 380 | return [ |
1794 | 278 | { | 381 | { |
1795 | 279 | tag: "2-over-1 Snap Decision with button-tint", | ||
1796 | 280 | type: Notification.SnapDecision, | ||
1797 | 281 | hints: {"x-canonical-private-affirmative-tint": "true"}, | ||
1798 | 282 | summary: "Theatre at Ferria Stadium", | ||
1799 | 283 | body: "at Ferria Stadium in Bilbao, Spain\n07578545317", | ||
1800 | 284 | icon: "", | ||
1801 | 285 | secondaryIcon: "", | ||
1802 | 286 | actions: [{ id: "ok_id", label: "Ok"}, | ||
1803 | 287 | { id: "snooze_id", label: "Snooze"}, | ||
1804 | 288 | { id: "view_id", label: "View"}], | ||
1805 | 289 | summaryVisible: true, | ||
1806 | 290 | bodyVisible: true, | ||
1807 | 291 | iconVisible: false, | ||
1808 | 292 | centeredIconVisible: false, | ||
1809 | 293 | shaped: false, | ||
1810 | 294 | secondaryIconVisible: false, | ||
1811 | 295 | buttonRowVisible: false, | ||
1812 | 296 | buttonTinted: true, | ||
1813 | 297 | hasSound: false, | ||
1814 | 298 | valueVisible: false, | ||
1815 | 299 | valueLabelVisible: false, | ||
1816 | 300 | valueTinted: false | ||
1817 | 301 | }, | ||
1818 | 302 | { | ||
1819 | 303 | tag: "Ephemeral notification - icon-summary layout", | 382 | tag: "Ephemeral notification - icon-summary layout", |
1827 | 304 | type: Notification.Ephemeral, | 383 | n: nlist[0], |
1821 | 305 | hints: {}, | ||
1822 | 306 | summary: "Photo upload completed", | ||
1823 | 307 | body: "", | ||
1824 | 308 | icon: "../graphics/applicationIcons/facebook.png", | ||
1825 | 309 | secondaryIcon: "", | ||
1826 | 310 | actions: [], | ||
1828 | 311 | summaryVisible: true, | 384 | summaryVisible: true, |
1829 | 312 | bodyVisible: false, | 385 | bodyVisible: false, |
1830 | 313 | iconVisible: true, | 386 | iconVisible: true, |
1831 | @@ -323,15 +396,7 @@ | |||
1832 | 323 | }, | 396 | }, |
1833 | 324 | { | 397 | { |
1834 | 325 | tag: "Ephemeral notification - check suppression of secondary icon for icon-summary layout", | 398 | tag: "Ephemeral notification - check suppression of secondary icon for icon-summary layout", |
1844 | 326 | type: Notification.Ephemeral, | 399 | n: nlist[1], |
1836 | 327 | hints: {"x-canonical-private-affirmative-tint": "false", | ||
1837 | 328 | "sound-file": "dummy.ogg", | ||
1838 | 329 | "suppress-sound": "true"}, | ||
1839 | 330 | summary: "New comment successfully published", | ||
1840 | 331 | body: "", | ||
1841 | 332 | icon: "", | ||
1842 | 333 | secondaryIcon: "../graphics/applicationIcons/facebook.png", | ||
1843 | 334 | actions: [], | ||
1845 | 335 | summaryVisible: true, | 400 | summaryVisible: true, |
1846 | 336 | bodyVisible: false, | 401 | bodyVisible: false, |
1847 | 337 | interactiveAreaEnabled: false, | 402 | interactiveAreaEnabled: false, |
1848 | @@ -348,14 +413,7 @@ | |||
1849 | 348 | }, | 413 | }, |
1850 | 349 | { | 414 | { |
1851 | 350 | tag: "Interactive notification", | 415 | tag: "Interactive notification", |
1860 | 351 | type: Notification.Interactive, | 416 | n: nlist[2], |
1853 | 352 | hints: {"x-canonical-private-affirmative-tint": "false", | ||
1854 | 353 | "sound-file": "dummy.ogg"}, | ||
1855 | 354 | summary: "Interactive notification", | ||
1856 | 355 | body: "This is a notification that can be clicked", | ||
1857 | 356 | icon: "../graphics/avatars/amanda.png", | ||
1858 | 357 | secondaryIcon: "", | ||
1859 | 358 | actions: [{ id: "reply_id", label: "Dummy"}], | ||
1861 | 359 | summaryVisible: true, | 417 | summaryVisible: true, |
1862 | 360 | bodyVisible: true, | 418 | bodyVisible: true, |
1863 | 361 | iconVisible: true, | 419 | iconVisible: true, |
1864 | @@ -371,15 +429,7 @@ | |||
1865 | 371 | }, | 429 | }, |
1866 | 372 | { | 430 | { |
1867 | 373 | tag: "Snap Decision without secondary icon and no button-tint", | 431 | tag: "Snap Decision without secondary icon and no button-tint", |
1877 | 374 | type: Notification.SnapDecision, | 432 | n: nlist[3], |
1869 | 375 | hints: {"x-canonical-private-affirmative-tint": "false", | ||
1870 | 376 | "sound-file": "dummy.ogg"}, | ||
1871 | 377 | summary: "Bro Coly", | ||
1872 | 378 | body: "At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.", | ||
1873 | 379 | icon: "../graphics/avatars/anna_olsson.png", | ||
1874 | 380 | secondaryIcon: "", | ||
1875 | 381 | actions: [{ id: "accept_id", label: "Accept"}, | ||
1876 | 382 | { id: "reject_id", label: "Reject"}], | ||
1878 | 383 | summaryVisible: true, | 433 | summaryVisible: true, |
1879 | 384 | bodyVisible: true, | 434 | bodyVisible: true, |
1880 | 385 | iconVisible: true, | 435 | iconVisible: true, |
1881 | @@ -395,14 +445,7 @@ | |||
1882 | 395 | }, | 445 | }, |
1883 | 396 | { | 446 | { |
1884 | 397 | tag: "Ephemeral notification", | 447 | tag: "Ephemeral notification", |
1893 | 398 | type: Notification.Ephemeral, | 448 | n: nlist[4], |
1886 | 399 | hints: {"x-canonical-private-affirmative-tint": "false", | ||
1887 | 400 | "sound-file": "dummy.ogg"}, | ||
1888 | 401 | summary: "Cole Raby", | ||
1889 | 402 | body: "I did not expect it to be that late.", | ||
1890 | 403 | icon: "../graphics/avatars/funky.png", | ||
1891 | 404 | secondaryIcon: "../graphics/applicationIcons/facebook.png", | ||
1892 | 405 | actions: [], | ||
1894 | 406 | summaryVisible: true, | 449 | summaryVisible: true, |
1895 | 407 | bodyVisible: true, | 450 | bodyVisible: true, |
1896 | 408 | iconVisible: true, | 451 | iconVisible: true, |
1897 | @@ -418,14 +461,7 @@ | |||
1898 | 418 | }, | 461 | }, |
1899 | 419 | { | 462 | { |
1900 | 420 | tag: "Ephemeral notification with non-shaped icon", | 463 | tag: "Ephemeral notification with non-shaped icon", |
1909 | 421 | type: Notification.Ephemeral, | 464 | n: nlist[5], |
1902 | 422 | hints: {"x-canonical-private-affirmative-tint": "false", | ||
1903 | 423 | "x-canonical-non-shaped-icon": "true"}, | ||
1904 | 424 | summary: "Contacts", | ||
1905 | 425 | body: "Synchronised contacts-database with cloud-storage.", | ||
1906 | 426 | icon: "image://theme/contacts-app", | ||
1907 | 427 | secondaryIcon: "", | ||
1908 | 428 | actions: [], | ||
1910 | 429 | summaryVisible: true, | 465 | summaryVisible: true, |
1911 | 430 | bodyVisible: true, | 466 | bodyVisible: true, |
1912 | 431 | iconVisible: true, | 467 | iconVisible: true, |
1913 | @@ -441,14 +477,7 @@ | |||
1914 | 441 | }, | 477 | }, |
1915 | 442 | { | 478 | { |
1916 | 443 | tag: "Confirmation notification with value", | 479 | tag: "Confirmation notification with value", |
1925 | 444 | type: Notification.Confirmation, | 480 | n: nlist[6], |
1918 | 445 | hints: {"x-canonical-non-shaped-icon": "true"}, | ||
1919 | 446 | summary: "", | ||
1920 | 447 | body: "", | ||
1921 | 448 | icon: "image://theme/audio-volume-medium", | ||
1922 | 449 | secondaryIcon: "", | ||
1923 | 450 | value: 50, | ||
1924 | 451 | actions: [], | ||
1926 | 452 | summaryVisible: false, | 481 | summaryVisible: false, |
1927 | 453 | bodyVisible: false, | 482 | bodyVisible: false, |
1928 | 454 | iconVisible: false, | 483 | iconVisible: false, |
1929 | @@ -464,15 +493,7 @@ | |||
1930 | 464 | }, | 493 | }, |
1931 | 465 | { | 494 | { |
1932 | 466 | tag: "Confirmation notification with value, label and tint", | 495 | tag: "Confirmation notification with value, label and tint", |
1942 | 467 | type: Notification.Confirmation, | 496 | n: nlist[7], |
1934 | 468 | hints: {"x-canonical-non-shaped-icon": "true", | ||
1935 | 469 | "x-canonical-value-bar-tint" : "true"}, | ||
1936 | 470 | summary: "", | ||
1937 | 471 | body: "High Volume", | ||
1938 | 472 | icon: "image://theme/audio-volume-high", | ||
1939 | 473 | secondaryIcon: "", | ||
1940 | 474 | value: 85, | ||
1941 | 475 | actions: [], | ||
1943 | 476 | summaryVisible: false, | 497 | summaryVisible: false, |
1944 | 477 | bodyVisible: false, | 498 | bodyVisible: false, |
1945 | 478 | iconVisible: false, | 499 | iconVisible: false, |
1946 | @@ -485,6 +506,22 @@ | |||
1947 | 485 | valueVisible: true, | 506 | valueVisible: true, |
1948 | 486 | valueLabelVisible: true, | 507 | valueLabelVisible: true, |
1949 | 487 | valueTinted: true | 508 | valueTinted: true |
1950 | 509 | }, | ||
1951 | 510 | { | ||
1952 | 511 | tag: "2-over-1 Snap Decision with button-tint", | ||
1953 | 512 | n: nlist[8], | ||
1954 | 513 | summaryVisible: true, | ||
1955 | 514 | bodyVisible: true, | ||
1956 | 515 | iconVisible: false, | ||
1957 | 516 | centeredIconVisible: false, | ||
1958 | 517 | shaped: false, | ||
1959 | 518 | secondaryIconVisible: false, | ||
1960 | 519 | buttonRowVisible: false, | ||
1961 | 520 | buttonTinted: true, | ||
1962 | 521 | hasSound: false, | ||
1963 | 522 | valueVisible: false, | ||
1964 | 523 | valueLabelVisible: false, | ||
1965 | 524 | valueTinted: false | ||
1966 | 488 | } | 525 | } |
1967 | 489 | ] | 526 | ] |
1968 | 490 | } | 527 | } |
1969 | @@ -509,8 +546,14 @@ | |||
1970 | 509 | } | 546 | } |
1971 | 510 | 547 | ||
1972 | 511 | function test_NotificationRenderer(data) { | 548 | function test_NotificationRenderer(data) { |
1973 | 549 | // make sure the clicks on mocked notifications can be checked against by "actionSpy" (mimicking the NotificationServer component) | ||
1974 | 550 | data.n.actionInvoked.connect(mockModel.actionInvoked) | ||
1975 | 551 | |||
1976 | 552 | // hook up notification's completed-signal with model's onCompleted-slot, so that remove() (model) happens on close() (notification) | ||
1977 | 553 | data.n.completed.connect(mockModel.onCompleted) | ||
1978 | 554 | |||
1979 | 512 | // populate model with some mock notifications | 555 | // populate model with some mock notifications |
1981 | 513 | mockModel.append(data) | 556 | mockModel.append(data.n) |
1982 | 514 | 557 | ||
1983 | 515 | // make sure the view is properly updated before going on | 558 | // make sure the view is properly updated before going on |
1984 | 516 | notifications.forceLayout(); | 559 | notifications.forceLayout(); |
1985 | @@ -548,9 +591,9 @@ | |||
1986 | 548 | 591 | ||
1987 | 549 | // test input does not fall through | 592 | // test input does not fall through |
1988 | 550 | mouseClick(notification, notification.width / 2, notification.height / 2) | 593 | mouseClick(notification, notification.width / 2, notification.height / 2) |
1990 | 551 | if(data.type == Notification.Interactive) { | 594 | if(data.n.type === Notification.Interactive) { |
1991 | 552 | actionSpy.wait() | 595 | actionSpy.wait() |
1993 | 553 | compare(actionSpy.signalArguments[0][0], data.actions[0]["id"], "got wrong id for interactive action") | 596 | compare(actionSpy.signalArguments[0][0], data.n.actions.data(0, ActionModel.RoleActionId), "got wrong id for interactive action") |
1994 | 554 | } | 597 | } |
1995 | 555 | compare(clickThroughSpy.count, 0, "click on notification fell through") | 598 | compare(clickThroughSpy.count, 0, "click on notification fell through") |
1996 | 556 | 599 | ||
1997 | @@ -559,17 +602,19 @@ | |||
1998 | 559 | compare(bodyLabel.visible, data.bodyVisible, "body-text visibility is incorrect") | 602 | compare(bodyLabel.visible, data.bodyVisible, "body-text visibility is incorrect") |
1999 | 560 | compare(buttonRow.visible, data.buttonRowVisible, "button visibility is incorrect") | 603 | compare(buttonRow.visible, data.buttonRowVisible, "button visibility is incorrect") |
2000 | 561 | 604 | ||
2003 | 562 | var audioItem = findInvisibleChild(notification, "sound") | 605 | if (data.hasSound) { |
2004 | 563 | compare(audioItem.playbackState, data.hasSound ? Audio.PlayingState : Audio.StoppedState, "Audio has wrong state") | 606 | var audioItem = findInvisibleChild(notification, "sound") |
2005 | 607 | compare(audioItem.playbackState, data.hasSound ? Audio.PlayingState : Audio.StoppedState, "Audio has wrong state") | ||
2006 | 608 | } | ||
2007 | 564 | 609 | ||
2008 | 565 | if(data.buttonRowVisible) { | 610 | if(data.buttonRowVisible) { |
2009 | 566 | var buttonCancel = findChild(buttonRow, "notify_button1") | 611 | var buttonCancel = findChild(buttonRow, "notify_button1") |
2010 | 567 | var buttonAccept = findChild(buttonRow, "notify_button0") | 612 | var buttonAccept = findChild(buttonRow, "notify_button0") |
2011 | 568 | 613 | ||
2012 | 569 | // only test the left/cancel-button if two actions have been passed in | 614 | // only test the left/cancel-button if two actions have been passed in |
2014 | 570 | if (data.actions.length == 2) { | 615 | if (data.n.actions.count === 2) { |
2015 | 571 | tryCompareFunction(function() { mouseClick(buttonCancel, buttonCancel.width / 2, buttonCancel.height / 2); return actionSpy.signalArguments.length > 0; }, true); | 616 | tryCompareFunction(function() { mouseClick(buttonCancel, buttonCancel.width / 2, buttonCancel.height / 2); return actionSpy.signalArguments.length > 0; }, true); |
2017 | 572 | compare(actionSpy.signalArguments[0][0], data.actions[1]["id"], "got wrong id for negative action") | 617 | compare(actionSpy.signalArguments[0][0], data.n.actions.data(1, ActionModel.RoleActionId), "got wrong id for negative action") |
2018 | 573 | actionSpy.clear() | 618 | actionSpy.clear() |
2019 | 574 | } | 619 | } |
2020 | 575 | 620 | ||
2021 | @@ -578,36 +623,49 @@ | |||
2022 | 578 | 623 | ||
2023 | 579 | // click the positive/right button | 624 | // click the positive/right button |
2024 | 580 | tryCompareFunction(function() { mouseClick(buttonAccept, buttonAccept.width / 2, buttonAccept.height / 2); return actionSpy.signalArguments.length > 0; }, true); | 625 | tryCompareFunction(function() { mouseClick(buttonAccept, buttonAccept.width / 2, buttonAccept.height / 2); return actionSpy.signalArguments.length > 0; }, true); |
2026 | 581 | compare(actionSpy.signalArguments[0][0], data.actions[0]["id"], "got wrong id positive action") | 626 | compare(actionSpy.signalArguments[0][0], data.n.actions.data(0, ActionModel.RoleActionId), "got wrong id positive action") |
2027 | 582 | actionSpy.clear() | 627 | actionSpy.clear() |
2028 | 583 | waitForRendering (notification) | ||
2029 | 584 | 628 | ||
2030 | 585 | // check if there's a ComboButton created due to more actions being passed | 629 | // check if there's a ComboButton created due to more actions being passed |
2032 | 586 | if (data.actions.length > 2) { | 630 | if (data.n.actions.count > 3) { |
2033 | 587 | var comboButton = findChild(notification, "notify_button2") | 631 | var comboButton = findChild(notification, "notify_button2") |
2035 | 588 | tryCompareFunction(function() { return comboButton.expanded == false; }, true); | 632 | tryCompareFunction(function() { return comboButton.expanded === false; }, true); |
2036 | 589 | 633 | ||
2037 | 590 | // click to expand | 634 | // click to expand |
2039 | 591 | tryCompareFunction(function() { mouseClick(comboButton, comboButton.width - comboButton.__styleInstance.dropDownWidth / 2, comboButton.height / 2); return comboButton.expanded == true; }, true); | 635 | tryCompareFunction(function() { mouseClick(comboButton, comboButton.width / 2, comboButton.height / 2); return comboButton.expanded === true; }, true); |
2040 | 592 | 636 | ||
2041 | 593 | // try clicking on choices in expanded comboList | 637 | // try clicking on choices in expanded comboList |
2042 | 594 | var choiceButton1 = findChild(notification, "notify_button3") | 638 | var choiceButton1 = findChild(notification, "notify_button3") |
2043 | 595 | tryCompareFunction(function() { mouseClick(choiceButton1, choiceButton1.width / 2, choiceButton1.height / 2); return actionSpy.signalArguments.length > 0; }, true); | 639 | tryCompareFunction(function() { mouseClick(choiceButton1, choiceButton1.width / 2, choiceButton1.height / 2); return actionSpy.signalArguments.length > 0; }, true); |
2045 | 596 | compare(actionSpy.signalArguments[0][0], data.actions[3]["id"], "got wrong id choice action 1") | 640 | compare(actionSpy.signalArguments[0][0], data.n.actions.data(3, ActionModel.RoleActionId), "got wrong id choice action 1") |
2046 | 597 | actionSpy.clear() | 641 | actionSpy.clear() |
2047 | 598 | 642 | ||
2048 | 599 | var choiceButton2 = findChild(notification, "notify_button4") | 643 | var choiceButton2 = findChild(notification, "notify_button4") |
2049 | 600 | tryCompareFunction(function() { mouseClick(choiceButton2, choiceButton2.width / 2, choiceButton2.height / 2); return actionSpy.signalArguments.length > 0; }, true); | 644 | tryCompareFunction(function() { mouseClick(choiceButton2, choiceButton2.width / 2, choiceButton2.height / 2); return actionSpy.signalArguments.length > 0; }, true); |
2051 | 601 | compare(actionSpy.signalArguments[0][0], data.actions[4]["id"], "got wrong id choice action 2") | 645 | compare(actionSpy.signalArguments[0][0], data.n.actions.data(4, ActionModel.RoleActionId), "got wrong id choice action 2") |
2052 | 602 | actionSpy.clear() | 646 | actionSpy.clear() |
2053 | 603 | 647 | ||
2054 | 604 | // click to collapse | 648 | // click to collapse |
2056 | 605 | //tryCompareFunction(function() { mouseClick(comboButton, comboButton.width - comboButton.__styleInstance.dropDownWidth / 2, comboButton.height / 2); return comboButton.expanded == false; }, true); | 649 | tryCompareFunction(function() { mouseClick(comboButton, comboButton.width / 2, comboButton.height / 2); return comboButton.expanded == false; }, true); |
2057 | 606 | } else { | 650 | } else { |
2058 | 607 | mouseClick(buttonCancel, buttonCancel.width / 2, buttonCancel.height / 2) | 651 | mouseClick(buttonCancel, buttonCancel.width / 2, buttonCancel.height / 2) |
2060 | 608 | compare(actionSpy.signalArguments[0][0], data.actions[1]["id"], "got wrong id for negative action") | 652 | compare(actionSpy.signalArguments[0][0], data.n.actions.data(1, ActionModel.RoleActionId), "got wrong id for negative action") |
2061 | 609 | } | 653 | } |
2062 | 610 | } | 654 | } |
2063 | 655 | |||
2064 | 656 | // swipe-to-dismiss check | ||
2065 | 657 | waitForRendering(notification) | ||
2066 | 658 | var before = mockModel.count | ||
2067 | 659 | var dragStart = notification.width * 0.25; | ||
2068 | 660 | var dragEnd = notification.width; | ||
2069 | 661 | var dragY = notification.height / 2; | ||
2070 | 662 | touchFlick(notification, dragStart, dragY, dragEnd, dragY) | ||
2071 | 663 | waitForRendering(notification) | ||
2072 | 664 | if ((data.n.type === Notification.SnapDecision && notification.state === "expanded") || data.n.type === Notification.Confirmation) { | ||
2073 | 665 | tryCompare(mockModel, "count", before) | ||
2074 | 666 | } else { | ||
2075 | 667 | tryCompare(mockModel, "count", before - 1) | ||
2076 | 668 | } | ||
2077 | 611 | } | 669 | } |
2078 | 612 | } | 670 | } |
2079 | 613 | } | 671 | } |
2080 | 614 | 672 | ||
2081 | === modified file 'tests/qmltests/Notifications/tst_OptionToggle.qml' | |||
2082 | --- tests/qmltests/Notifications/tst_OptionToggle.qml 2014-11-10 09:14:30 +0000 | |||
2083 | +++ tests/qmltests/Notifications/tst_OptionToggle.qml 2015-02-16 22:20:44 +0000 | |||
2084 | @@ -1,17 +1,20 @@ | |||
2085 | 1 | /* | 1 | /* |
2087 | 2 | * Copyright (C) 2014 Canonical, Ltd. | 2 | * Copyright 2015 Canonical Ltd. |
2088 | 3 | * | 3 | * |
2089 | 4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
2091 | 5 | * it under the terms of the GNU General Public License as published by | 5 | * it under the terms of the GNU Lesser General Public License as published by |
2092 | 6 | * the Free Software Foundation; version 3. | 6 | * the Free Software Foundation; version 3. |
2093 | 7 | * | 7 | * |
2094 | 8 | * This program is distributed in the hope that it will be useful, | 8 | * This program is distributed in the hope that it will be useful, |
2095 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2096 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2098 | 11 | * GNU General Public License for more details. | 11 | * GNU Lesser General Public License for more details. |
2099 | 12 | * | 12 | * |
2101 | 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU Lesser General Public License |
2102 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2103 | 15 | * | ||
2104 | 16 | * Authors: | ||
2105 | 17 | * Mirco Mueller <mirco.mueller@canonical.com> | ||
2106 | 15 | */ | 18 | */ |
2107 | 16 | 19 | ||
2108 | 17 | import QtQuick 2.0 | 20 | import QtQuick 2.0 |
2109 | @@ -235,8 +238,10 @@ | |||
2110 | 235 | compare(bodyLabel.visible, data.bodyVisible, "body-text visibility is incorrect") | 238 | compare(bodyLabel.visible, data.bodyVisible, "body-text visibility is incorrect") |
2111 | 236 | compare(buttonRow.visible, data.buttonRowVisible, "button visibility is incorrect") | 239 | compare(buttonRow.visible, data.buttonRowVisible, "button visibility is incorrect") |
2112 | 237 | 240 | ||
2115 | 238 | var audioItem = findInvisibleChild(notification, "sound") | 241 | if (data.hasSound) { |
2116 | 239 | compare(audioItem.playbackState, data.hasSound ? Audio.PlayingState : Audio.StoppedState, "Audio has wrong state") | 242 | var audioItem = findInvisibleChild(notification, "sound") |
2117 | 243 | compare(audioItem.playbackState, data.hasSound ? Audio.PlayingState : Audio.StoppedState, "Audio has wrong state") | ||
2118 | 244 | } | ||
2119 | 240 | 245 | ||
2120 | 241 | if(data.buttonRowVisible) { | 246 | if(data.buttonRowVisible) { |
2121 | 242 | var buttonCancel = findChild(buttonRow, "notify_button1") | 247 | var buttonCancel = findChild(buttonRow, "notify_button1") |
2122 | 243 | 248 | ||
2123 | === modified file 'tests/qmltests/Notifications/tst_SwipeToAct.qml' | |||
2124 | --- tests/qmltests/Notifications/tst_SwipeToAct.qml 2014-11-05 14:37:11 +0000 | |||
2125 | +++ tests/qmltests/Notifications/tst_SwipeToAct.qml 2015-02-16 22:20:44 +0000 | |||
2126 | @@ -218,6 +218,10 @@ | |||
2127 | 218 | // populate model with some mock notifications | 218 | // populate model with some mock notifications |
2128 | 219 | mockModel.append(data) | 219 | mockModel.append(data) |
2129 | 220 | 220 | ||
2130 | 221 | // add actions to action-model to test against | ||
2131 | 222 | myActionModel.append("ok_id", "Ok") | ||
2132 | 223 | myActionModel.append("cancel_id", "Cancel") | ||
2133 | 224 | |||
2134 | 221 | // make sure the view is properly updated before going on | 225 | // make sure the view is properly updated before going on |
2135 | 222 | notifications.forceLayout(); | 226 | notifications.forceLayout(); |
2136 | 223 | waitForRendering(notifications); | 227 | waitForRendering(notifications); |
2137 | 224 | 228 | ||
2138 | === modified file 'tests/qmltests/tst_ShellWithPin.qml' | |||
2139 | --- tests/qmltests/tst_ShellWithPin.qml 2014-12-05 16:27:27 +0000 | |||
2140 | +++ tests/qmltests/tst_ShellWithPin.qml 2015-02-16 22:20:44 +0000 | |||
2141 | @@ -472,5 +472,52 @@ | |||
2142 | 472 | 472 | ||
2143 | 473 | } | 473 | } |
2144 | 474 | 474 | ||
2145 | 475 | /* | ||
2146 | 476 | Regression test for https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1393447 | ||
2147 | 477 | |||
2148 | 478 | Do a left edge drag that is long enough to start displacing the greeter | ||
2149 | 479 | but short engough so that the greeter comes back into place once the | ||
2150 | 480 | finger is lifted. | ||
2151 | 481 | |||
2152 | 482 | In this situation the launcher should remaing fully shown and hide itself | ||
2153 | 483 | only after its idle timeout is triggered. | ||
2154 | 484 | */ | ||
2155 | 485 | function test_shortLeftEdgeSwipeMakesLauncherStayVisible() { | ||
2156 | 486 | var greeter = testCase.findChild(shell, "greeter") | ||
2157 | 487 | greeter.show(); | ||
2158 | 488 | tryCompare(greeter, "showProgress", 1); | ||
2159 | 489 | |||
2160 | 490 | var launcher = testCase.findChild(shell, "launcher") | ||
2161 | 491 | { | ||
2162 | 492 | var dismissTimer = testCase.findInvisibleChild(launcher, "dismissTimer"); | ||
2163 | 493 | // effectively disable the dismiss timer | ||
2164 | 494 | dismissTimer.interval = 24 * 60 * 60 * 1000 // 24 hours | ||
2165 | 495 | } | ||
2166 | 496 | var launcherPanel = testCase.findChild(launcher, "launcherPanel"); | ||
2167 | 497 | |||
2168 | 498 | var toX = shell.width * 0.45; | ||
2169 | 499 | touchFlick(shell, | ||
2170 | 500 | 1 /* fromX */, shell.height * 0.5 /* fromY */, | ||
2171 | 501 | toX /* toX */, shell.height * 0.5 /* toY */, | ||
2172 | 502 | true /* beginTouch */, false /* endTouch */, | ||
2173 | 503 | 50, 100); | ||
2174 | 504 | |||
2175 | 505 | // Launcher must be fully shown by now | ||
2176 | 506 | tryCompare(launcherPanel, "x", 0); | ||
2177 | 507 | |||
2178 | 508 | // Greeter should be displaced | ||
2179 | 509 | tryCompareFunction(function() { return greeter.mapToItem(shell, 0, 0).x > shell.width*0.2; }, true); | ||
2180 | 510 | |||
2181 | 511 | touchRelease(shell, toX, shell.height * 0.5); | ||
2182 | 512 | |||
2183 | 513 | // Upon release the greeter should have slid back into full view | ||
2184 | 514 | tryCompareFunction(function() { return greeter.mapToItem(shell, 0, 0).x === 0; }, true); | ||
2185 | 515 | |||
2186 | 516 | // And the launcher should stay fully shown | ||
2187 | 517 | for (var i = 0; i < 10; ++i) { | ||
2188 | 518 | wait(50); | ||
2189 | 519 | compare(launcherPanel.x, 0); | ||
2190 | 520 | } | ||
2191 | 521 | } | ||
2192 | 475 | } | 522 | } |
2193 | 476 | } | 523 | } |