@@ -34,19 +34,23 @@ Item {
3434 Row {
3535 id: rootRow
3636
37− // add the default/PlaceHolder notification to the model
38− Component.onCompleted: {
39− var component = Qt.createComponent("Notification.qml")
40− var n = component.createObject("notification", {"nid": index++,
41− "type": Notification.PlaceHolder,
42− "hints": {},
43− "summary": "",
44− "body": "",
45− "icon": "",
46− "secondaryIcon": "",
47− "rawActions": []})
48− n.completed.connect(Model.onCompleted)
49− Model.append(n)
37+ NotificationModel {
38+ id: mockModel
39+
40+ // add the default/PlaceHolder notification to the model
41+ Component.onCompleted: {
42+ var component = Qt.createComponent("Notification.qml")
43+ var n = component.createObject("notification", {"nid": index++,
44+ "type": Notification.PlaceHolder,
45+ "hints": {},
46+ "summary": "",
47+ "body": "",
48+ "icon": "",
49+ "secondaryIcon": "",
50+ "rawActions": []})
51+ n.completed.connect(mockModel.onCompleted)
52+ append(n)
53+ }
5054 }
5155
5256 function add2over1SnapDecisionNotification() {
@@ -61,8 +65,8 @@ Item {
6165 "rawActions": ["ok_id", "Ok",
6266 "snooze_id", "Snooze",
6367 "view_id", "View"]})
64− n.completed.connect(Model.onCompleted)
65− Model.append(n)
68+ n.completed.connect(mockModel.onCompleted)
69+ mockModel.append(n)
6670 }
6771
6872 function addEphemeralNotification() {
@@ -75,8 +79,8 @@ Item {
7579 "icon": "../../tests/graphics/avatars/amanda.png",
7680 "secondaryIcon": "../../tests/graphics/applicationIcons/facebook.png",
7781 "rawActions": ["reply_id", "Dummy"]})
78− n.completed.connect(Model.onCompleted)
79− Model.append(n)
82+ n.completed.connect(mockModel.onCompleted)
83+ mockModel.append(n)
8084 }
8185
8286 function addEphemeralNonShapedIconNotification() {
@@ -89,8 +93,8 @@ Item {
8993 "icon": "../../tests/graphics/applicationIcons/contacts-app.png",
9094 "secondaryIcon": "",
9195 "rawActions": ["reply_id", "Dummy"]})
92− n.completed.connect(Model.onCompleted)
93− Model.append(n)
96+ n.completed.connect(mockModel.onCompleted)
97+ mockModel.append(n)
9498 }
9599
96100 function addEphemeralIconSummaryNotification() {
@@ -103,8 +107,8 @@ Item {
103107 "icon": "../../tests/graphics/applicationIcons/facebook.png",
104108 "secondaryIcon": "",
105109 "rawActions": ["reply_id", "Dummy"]})
106− n.completed.connect(Model.onCompleted)
107− Model.append(n)
110+ n.completed.connect(mockModel.onCompleted)
111+ mockModel.append(n)
108112 }
109113
110114 function addInteractiveNotification() {
@@ -117,8 +121,8 @@ Item {
117121 "icon": "../../tests/graphics/avatars/anna_olsson.png",
118122 "secondaryIcon": "",
119123 "rawActions": ["reply_id", "Dummy"]})
120− n.completed.connect(Model.onCompleted)
121− Model.append(n)
124+ n.completed.connect(mockModel.onCompleted)
125+ mockModel.append(n)
122126 }
123127
124128 function addConfirmationNotification() {
@@ -132,8 +136,8 @@ Item {
132136 "secondaryIcon": "",
133137 "value": 50,
134138 "rawActions": ["reply_id", "Dummy"]})
135− n.completed.connect(Model.onCompleted)
136− Model.append(n)
139+ n.completed.connect(mockModel.onCompleted)
140+ mockModel.append(n)
137141 }
138142
139143 function add2ndConfirmationNotification() {
@@ -148,19 +152,19 @@ Item {
148152 "secondaryIcon": "",
149153 "value": 85,
150154 "rawActions": ["reply_id", "Dummy"]})
151− n.completed.connect(Model.onCompleted)
152− Model.append(n)
155+ n.completed.connect(mockModel.onCompleted)
156+ mockModel.append(n)
153157 }
154158
155159 function clearNotifications() {
156− while(Model.count > 1) {
160+ while(mockModel.count > 1) {
157161 remove1stNotification()
158162 }
159163 }
160164
161165 function remove1stNotification() {
162− if (Model.count > 1) {
163− Model.removeSecond()
166+ if (mockModel.count > 1) {
167+ mockModel.removeSecond()
164168 }
165169 }
166170
@@ -182,7 +186,7 @@ Item {
182186 margin: units.gu(1)
183187
184188 anchors.fill: parent
185− model: Model
189+ model: mockModel
186190 hasMouse: fakeMouseCB.checked
187191 inverseMode: inverseModeCB.checked
188192 }
@@ -554,7 +558,7 @@ Item {
554558 SignalSpy {
555559 id: actionSpy
556560
557− target: Model
561+ target: mockModel
558562 signalName: "actionInvoked"
559563 }
560564
@@ -565,19 +569,19 @@ Item {
565569
566570 function test_NotificationRenderer(data) {
567571 // make sure the clicks on mocked notifications can be checked against by "actionSpy" (mimicking the NotificationServer component)
568− data.n.actionInvoked.connect(Model.actionInvoked)
572+ data.n.actionInvoked.connect(mockModel.actionInvoked)
569573
570574 // hook up notification's completed-signal with model's onCompleted-slot, so that remove() (model) happens on close() (notification)
571− data.n.completed.connect(Model.onCompleted)
575+ data.n.completed.connect(mockModel.onCompleted)
572576
573577 // populate model with some mock notifications
574− Model.append(data.n)
578+ mockModel.append(data.n)
575579
576580 // make sure the view is properly updated before going on
577581 notifications.forceLayout();
578582 waitForRendering(notifications);
579583
580− var notification = findChild(notifications, "notification" + (Model.count - 1))
584+ var notification = findChild(notifications, "notification" + (mockModel.count - 1))
581585 verify(notification !== undefined, "notification wasn't found");
582586
583587 waitForRendering(notification);
@@ -623,7 +627,7 @@ Item {
623627
624628 // After clicking the state of notifications can change so let's wait
625629 // for their height animations to finish before continuing
626− for (var i = 0; i < Model.count; ++i) {
630+ for (var i = 0; i < mockModel.count; ++i) {
627631 var n = findChild(notifications, "notification" + i)
628632 tryCompare(n, "height", n.state === "contracted" ? units.gu(10) : n.implicitHeight);
629633 }
@@ -681,16 +685,16 @@ Item {
681685
682686 // swipe-to-dismiss check
683687 waitForRendering(notification)
684− var before = Model.count
688+ var before = mockModel.count
685689 var dragStart = notification.width * 0.25;
686690 var dragEnd = notification.width;
687691 var dragY = notification.height / 2;
688692 touchFlick(notification, dragStart, dragY, dragEnd, dragY)
689693 waitForRendering(notification)
690694 if ((data.n.type === Notification.SnapDecision && notification.state === "expanded") || data.n.type === Notification.Confirmation) {
691− tryCompare(Model, "count", before)
695+ tryCompare(mockModel, "count", before)
692696 } else {
693− tryCompare(Model, "count", before - 1)
697+ tryCompare(mockModel, "count", before - 1)
694698 }
695699 }
696700
@@ -701,27 +705,27 @@ Item {
701705
702706 function test_clickToClose(data) {
703707 // populate model with some mock notifications
704− Model.append(data.n)
708+ mockModel.append(data.n)
705709
706710 // make sure the view is properly updated before going on
707711 notifications.forceLayout();
708712 waitForRendering(notifications);
709713
710− var notification = findChild(notifications, "notification" + (Model.count - 1))
714+ var notification = findChild(notifications, "notification" + (mockModel.count - 1))
711715 verify(!!notification, "notification wasn't found");
712716
713717 // click-to-dismiss check
714718 waitForRendering(notification);
715− var before = Model.count;
719+ var before = mockModel.count;
716720 var canBeClosed = notification.canBeClosed;
717721 mouseClick(notification);
718722
719723 if (canBeClosed) {
720724 // closing the notification, the model count should be one less
721− tryCompare(Model, "count", before - 1)
725+ tryCompare(mockModel, "count", before - 1)
722726 } else {
723727 // not closing, model stays the same
724− tryCompare(Model, "count", before)
728+ tryCompare(mockModel, "count", before)
725729 }
726730 }
727731