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.
commitea6d2df249de7016bb8c9b082953b55815476adb authorMirco Müller <mirco.mueller@ubuntu.com> dateMon 26 Jan 2015, 13:32 (12 years ago) parent9ecb29f
1 file changed+45−19
tests/qmltests/tst_Shell.qml+45−19
tests/qmltests/tst_Shell.qml+45−19
@@ -30,7 +30,6 @@ import Unity.Test 0.1 as UT
3030import Powerd 0.1
3131
3232import "../../qml"
33−import "../../qml/Notifications"
3433
3534Item {
3635 id: root
@@ -97,12 +96,27 @@ Item {
9796 }
9897 }
9998
100− NotificationModel {
99+ Component {
100+ id: mockNotification
101+
102+ QtObject {
103+ function invokeAction(actionId) {
104+ mockNotificationsModel.actionInvoked(actionId)
105+ }
106+ }
107+ }
108+ ListModel {
101109 id: mockNotificationsModel
102110
111+ signal actionInvoked(string actionId)
112+
113+ function getRaw(id) {
114+ return mockNotification.createObject(mockNotificationsModel)
115+ }
116+
103117 onActionInvoked: {
104− if(action == "ok_id") {
105− mockNotificationsModel.remove(1)
118+ if(actionId == "ok_id") {
119+ mockNotificationsModel.clear()
106120 }
107121 }
108122 }
@@ -128,6 +142,12 @@ Item {
128142 signalName: "unlockingAllModems"
129143 }
130144
145+ SignalSpy {
146+ id: notificationActionSpy
147+ target: mockNotificationsModel
148+ signalName: "actionInvoked"
149+ }
150+
131151 Telephony.CallEntry {
132152 id: phoneCall
133153 phoneNumber: "+447812221111"
@@ -202,6 +222,13 @@ Item {
202222
203223 notifications.model = mockNotificationsModel;
204224
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+
205232 // Pop-up a notification
206233 addSnapDecisionNotification();
207234 waitForRendering(shell);
@@ -226,21 +253,20 @@ Item {
226253 }
227254
228255 function addSnapDecisionNotification() {
229− var component = Qt.createComponent("./Notifications/Notification.qml")
230− var n = component.createObject("notification", {"nid": 1,
231− "type": Notification.SnapDecision,
232− "hints": {"x-canonical-private-affirmative-tint": "true"},
233− "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.",
235− "icon": "../graphics/avatars/funky.png",
236− "secondaryIcon": "../graphics/applicationIcons/facebook.png",
237− "rawActions": ["ok_id", "Ok",
238− "cancel_id", "Cancel",
239− "notreally_id", "Not really",
240− "noway_id", "messages:No way",
241− "nada_id", "messages:Nada"]})
242− n.completed.connect(mockNotificationsModel.onCompleted)
243− n.actionInvoked.connect(mockNotificationsModel.actionInvoked)
256+ var n = {
257+ type: Notification.SnapDecision,
258+ hints: {"x-canonical-private-affirmative-tint": "true"},
259+ summary: "Tom Ato",
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.",
261+ icon: "../graphics/avatars/funky.png",
262+ secondaryIcon: "../graphics/applicationIcons/facebook.png",
263+ actions: [{ id: "ok_id", label: "Ok"},
264+ { id: "cancel_id", label: "Cancel"},
265+ { id: "notreally_id", label: "Not really"},
266+ { id: "noway_id", label: "messages:No way"},
267+ { id: "nada_id", label: "messages:Nada"}]
268+ }
269+
244270 mockNotificationsModel.append(n)
245271 }
246272