on xenial help sign in
Don't fix the snapDecisionProxyModel-hack in this branch. It'll be kept in a seperate one to not futher block this one from being MP'ed.
ea6d2dfMirco Müller
tests/qmltests/tst_Shell.qml+45−19
@@ -30,7 +30,6 @@ import Unity.Test 0.1 as UT
30import Powerd 0.1
30import Powerd 0.1
31
31
32import "../../qml"
32import "../../qml"
33−import "../../qml/Notifications"
34
33
35Item {
34Item {
36 id: root
35 id: root
@@ -97,12 +96,27 @@ Item {
97 }
96 }
98 }
97 }
99
98
100− NotificationModel {
99+ Component {
100+ id: mockNotification
101+
102+ QtObject {
103+ function invokeAction(actionId) {
104+ mockNotificationsModel.actionInvoked(actionId)
105+ }
106+ }
107+ }
108+ ListModel {
101 id: mockNotificationsModel
109 id: mockNotificationsModel
102
110
111+ signal actionInvoked(string actionId)
112+
113+ function getRaw(id) {
114+ return mockNotification.createObject(mockNotificationsModel)
115+ }
116+
103 onActionInvoked: {
117 onActionInvoked: {
104− if(action == "ok_id") {
118+ if(actionId == "ok_id") {
105− mockNotificationsModel.remove(1)
119+ mockNotificationsModel.clear()
106 }
120 }
107 }
121 }
108 }
122 }
@@ -128,6 +142,12 @@ Item {
128 signalName: "unlockingAllModems"
142 signalName: "unlockingAllModems"
129 }
143 }
130
144
145+ SignalSpy {
146+ id: notificationActionSpy
147+ target: mockNotificationsModel
148+ signalName: "actionInvoked"
149+ }
150+
131 Telephony.CallEntry {
151 Telephony.CallEntry {
132 id: phoneCall
152 id: phoneCall
133 phoneNumber: "+447812221111"
153 phoneNumber: "+447812221111"
@@ -202,6 +222,13 @@ Item {
202
222
203 notifications.model = mockNotificationsModel;
223 notifications.model = mockNotificationsModel;
204
224
225+ // FIXME: Hack: UnitySortFilterProxyModelQML doesn't work with QML ListModels which we use
226+ // for mocking here (RoleType can't be found in the QML model). As we only need to show
227+ // one SnapDecision lets just disable the filtering and make appear any notification as a
228+ // SnapDecision.
229+ var snapDecisionProxyModel = findInvisibleChild(shell, "snapDecisionProxyModel");
230+ snapDecisionProxyModel.filterRegExp = RegExp("");
231+
205 // Pop-up a notification
232 // Pop-up a notification
206 addSnapDecisionNotification();
233 addSnapDecisionNotification();
207 waitForRendering(shell);
234 waitForRendering(shell);
@@ -226,21 +253,20 @@ Item {
226 }
253 }
227
254
228 function addSnapDecisionNotification() {
255 function addSnapDecisionNotification() {
229− var component = Qt.createComponent("./Notifications/Notification.qml")
256+ var n = {
230− var n = component.createObject("notification", {"nid": 1,
231− "type": Notification.SnapDecision,
257+ type: Notification.SnapDecision,
232− "hints": {"x-canonical-private-affirmative-tint": "true"},
258+ hints: {"x-canonical-private-affirmative-tint": "true"},
233− "summary": "Tom Ato",
259+ summary: "Tom Ato",
234− "body": "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.",
260+ body: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.",
235− "icon": "../graphics/avatars/funky.png",
261+ icon: "../graphics/avatars/funky.png",
236− "secondaryIcon": "../graphics/applicationIcons/facebook.png",
262+ secondaryIcon: "../graphics/applicationIcons/facebook.png",
237− "rawActions": ["ok_id", "Ok",
263+ actions: [{ id: "ok_id", label: "Ok"},
238− "cancel_id", "Cancel",
264+ { id: "cancel_id", label: "Cancel"},
239− "notreally_id", "Not really",
265+ { id: "notreally_id", label: "Not really"},
240− "noway_id", "messages:No way",
266+ { id: "noway_id", label: "messages:No way"},
241− "nada_id", "messages:Nada"]})
267+ { id: "nada_id", label: "messages:Nada"}]
242− n.completed.connect(mockNotificationsModel.onCompleted)
268+ }
243− n.actionInvoked.connect(mockNotificationsModel.actionInvoked)
269+
244 mockNotificationsModel.append(n)
270 mockNotificationsModel.append(n)
245 }
271 }
246
272