on xenial help sign in
revert notification pausing -- it needs more thinking
commit517e29a57b4c31183ee8a0cd0f07e92c8fe81641 authorMichael Terry <michael.terry@canonical.com> dateWed 4 May 2016, 16:39 (10 years ago) parent9007ce1
8 files changed+81−120
debian/control+1−1 qml/Shell.qml−6 tests/mocks/Unity/Notifications/MockNotificationModel.cpp+5−23 tests/mocks/Unity/Notifications/MockNotificationModel.h−8 tests/mocks/Unity/Notifications/plugin.cpp+1−6 tests/qmltests/Notifications/tst_Notifications.qml+49−45 tests/qmltests/Tutorial/tst_Tutorial.qml+24−13 tests/qmltests/tst_Shell.qml+1−18
debian/control+1−1
@@ -131,7 +131,7 @@ Depends: qml-module-qtquick-layouts,
131131 qtdeclarative5-ubuntu-settings-components (>= 0.7),
132132 qtdeclarative5-ubuntu-thumbnailer0.1 | ubuntu-thumbnailer-impl,
133133 qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 1.3.1845) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 1.3.1845),
134− qtdeclarative5-unity-notifications-plugin (>= 0.1.4) | unity-notifications-impl,
134+ qtdeclarative5-unity-notifications-plugin (>= 0.1.2) | unity-notifications-impl,
135135 ubuntu-thumbnailer-impl-0,
136136 unity-application-impl-15,
137137 unity-notifications-impl-3,
qml/Shell.qml−6
@@ -667,12 +667,6 @@ Item {
667667 y: topmostIsFullscreen ? 0 : panel.panelHeight
668668 height: parent.height - (topmostIsFullscreen ? 0 : panel.panelHeight)
669669
670− Binding {
671− target: NotificationBackend.Model
672− property: "paused"
673− value: tutorial.running
674− }
675−
676670 states: [
677671 State {
678672 name: "narrow"
tests/mocks/Unity/Notifications/MockNotificationModel.cpp+5−23
@@ -31,14 +31,14 @@
3131
3232using namespace unity::shell::notifications;
3333
34−MockNotificationModel::MockNotificationModel(QObject *parent)
35− : QAbstractListModel(parent)
36− , m_paused(false)
37−{
34+MockNotificationModel::MockNotificationModel(QObject *parent) : QAbstractListModel(parent) {
3835}
3936
4037MockNotificationModel::~MockNotificationModel() {
41− clear();
38+ Q_FOREACH(MockNotification *n, m_queue) {
39+ n->deleteLater();
40+ }
41+ m_queue.clear();
4242}
4343
4444int MockNotificationModel::rowCount(const QModelIndex &) const {
@@ -89,17 +89,6 @@ QVariant MockNotificationModel::data(const QModelIndex &index, int role) const {
8989 }
9090}
9191
92−bool MockNotificationModel::getPaused() const {
93− return m_paused;
94−}
95−
96−void MockNotificationModel::setPaused(bool paused) {
97− if (m_paused != paused) {
98− m_paused = paused;
99− Q_EMIT pausedChanged(paused);
100− }
101−}
102−
10392void MockNotificationModel::append(MockNotification* n) {
10493 int location = m_queue.size();
10594 QModelIndex insertionPoint = QModelIndex();
@@ -118,13 +107,6 @@ MockNotification* MockNotificationModel::getNotification(int id) const {
118107 return nullptr;
119108}
120109
121−void MockNotificationModel::clear() {
122− Q_FOREACH(MockNotification *n, m_queue) {
123− n->deleteLater();
124− }
125− m_queue.clear();
126−}
127−
128110void MockNotificationModel::remove(const int id) {
129111 for(int i = 0; i < m_queue.size(); i++) {
130112 if(m_queue[i]->getID() == id) {
tests/mocks/Unity/Notifications/MockNotificationModel.h−8
@@ -30,7 +30,6 @@ class MockNotification;
3030class MockNotificationModel : public QAbstractListModel {
3131 Q_OBJECT
3232 Q_PROPERTY(int count READ getCount)
33− Q_PROPERTY(bool paused READ getPaused WRITE setPaused NOTIFY pausedChanged)
3433
3534public:
3635 MockNotificationModel(QObject *parent=nullptr);
@@ -40,9 +39,6 @@ public:
4039 QVariant data(const QModelIndex &index, int role) const override;
4140 QHash<int, QByteArray> roleNames() const override;
4241
43− bool getPaused() const;
44− void setPaused(bool paused);
45−
4642 Q_INVOKABLE void append(MockNotification* n);
4743 MockNotification* getNotification(int id) const;
4844
@@ -54,8 +50,6 @@ public:
5450 Q_INVOKABLE void remove(const int id);
5551 Q_INVOKABLE void removeSecond();
5652
57− Q_INVOKABLE void clear(); // only in mock
58−
5953 int getCount() const;
6054
6155Q_SIGNALS:
@@ -69,11 +63,9 @@ private Q_SLOTS:
6963
7064Q_SIGNALS:
7165 void queueSizeChanged(int newSize);
72− void pausedChanged(bool paused);
7366
7467private:
7568 QList<MockNotification*> m_queue;
76− bool m_paused;
7769 void removeInternal(int loc);
7870};
7971
tests/mocks/Unity/Notifications/plugin.cpp+1−6
@@ -24,15 +24,10 @@
2424
2525#include <QtQml/qqml.h>
2626
27−static QObject* modelProvider(QQmlEngine* /* engine */, QJSEngine* /* scriptEngine */)
28−{
29− return new MockNotificationModel;
30−}
31−
3227void TestNotificationPlugin::registerTypes(const char* uri)
3328{
3429 // @uri Unity.Notifications
3530 qmlRegisterType<MockNotification>(uri, 1, 0, "Notification");
36− qmlRegisterSingletonType<MockNotificationModel>(uri, 1, 0, "Model", modelProvider);
31+ qmlRegisterType<MockNotificationModel>(uri, 1, 0, "NotificationModel");
3732 qmlRegisterType<ActionModel>(uri, 1, 0, "ActionModel");
3833}
tests/qmltests/Notifications/tst_Notifications.qml+49−45
@@ -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
tests/qmltests/Tutorial/tst_Tutorial.qml+24−13
@@ -22,7 +22,7 @@ import Ubuntu.Components 1.3
2222import Ubuntu.Components.ListItems 1.3
2323import Ubuntu.Telephony 0.1 as Telephony
2424import Unity.Application 0.1
25−import Unity.Notifications 1.0 as NotificationBackend
25+import Unity.Notifications 1.0
2626import Unity.Test 0.1 as UT
2727import Utils 0.1
2828
@@ -57,21 +57,30 @@ Rectangle {
5757 }
5858
5959 Component {
60− id: notification
61− NotificationBackend.Notification {
62− nid: 1
63− type: NotificationBackend.Notification.Confirmation
64− summary: ""
65− body: ""
66− icon: ""
67− secondaryIcon: ""
68− value: 0
69− rawActions: []
60+ id: mockNotification
61+ QtObject {}
62+ }
63+
64+ ListModel {
65+ id: mockNotificationsModel
66+
67+ function getRaw(id) {
68+ return mockNotification.createObject(mockNotificationsModel)
7069 }
7170 }
7271
7372 function addNotification() {
74− NotificationBackend.Model.append(notification.createObject());
73+ var n = {
74+ type: Notification.Confirmation,
75+ hints: {},
76+ summary: "",
77+ body: "",
78+ icon: "",
79+ secondaryIcon: "",
80+ actions: []
81+ };
82+
83+ mockNotificationsModel.append(n);
7584 }
7685
7786 Component.onCompleted: {
@@ -277,11 +286,11 @@ Rectangle {
277286
278287 // kill all (fake) running apps
279288 killApps();
280− NotificationBackend.Model.clear();
281289
282290 // reload our test subject to get it in a fresh state once again
283291 shellLoader.active = true;
284292
293+ mockNotificationsModel.clear();
285294 tryCompare(shellLoader, "status", Loader.Ready);
286295 removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
287296 }
@@ -723,6 +732,8 @@ Rectangle {
723732 var tutorial = findChild(shell, "tutorial");
724733 verify(!tutorial.delayed);
725734
735+ var notifications = findChild(shell, "notificationList");
736+ notifications.model = mockNotificationsModel;
726737 addNotification();
727738
728739 tryCompare(tutorial, "delayed", true);
tests/qmltests/tst_Shell.qml+1−18
@@ -25,7 +25,7 @@ import Ubuntu.Telephony 0.1 as Telephony
2525import Unity.Application 0.1
2626import Unity.Connectivity 0.1
2727import Unity.Indicators 0.1
28−import Unity.Notifications 1.0 as NotificationBackend
28+import Unity.Notifications 1.0
2929import Unity.Launcher 0.1
3030import Unity.Test 0.1
3131import Powerd 0.1
@@ -349,8 +349,6 @@ Rectangle {
349349 ListModel {
350350 id: mockNotificationsModel
351351
352− property bool paused
353−
354352 signal actionInvoked(string actionId)
355353
356354 function getRaw(id) {
@@ -1289,21 +1287,6 @@ Rectangle {
12891287 tryCompare(tutorial, "paused", false);
12901288 }
12911289
1292− function test_notificationsPausedDuringTutorial() {
1293− loadShell("phone");
1294− swipeAwayGreeter();
1295− verify(!NotificationBackend.Model.paused);
1296−
1297− AccountsService.demoEdges = true;
1298− var tutorialLeft = findChild(shell, "tutorialLeft");
1299− var tutorialLeftTimer = findInvisibleChild(tutorialLeft, "tutorialLeftTimer");
1300− tutorialLeftTimer.interval = 0;
1301− tryCompare(NotificationBackend.Model, "paused", true);
1302−
1303− AccountsService.demoEdges = false;
1304− tryCompare(NotificationBackend.Model, "paused", false);
1305− }
1306−
13071290 function test_tapOnRightEdgeReachesApplicationSurface() {
13081291 loadShell("phone");
13091292 swipeAwayGreeter();