Merge lp:~lukas-kde/unity-notifications/visibleQueueFixes into lp:unity-notifications

Proposed by Lukáš Tinkl
Status: Merged
Approved by: Michael Zanetti
Approved revision: 245
Merged at revision: 238
Proposed branch: lp:~lukas-kde/unity-notifications/visibleQueueFixes
Merge into: lp:unity-notifications
Diff against target: 685 lines (+96/-168)
11 files modified
include/ActionModel.h (+3/-3)
include/Notification.h (+0/-5)
include/NotificationModel.h (+0/-1)
include/NotificationServer.h (+3/-4)
include/notify-backend.h.in (+0/-25)
src/ActionModel.cpp (+11/-11)
src/CMakeLists.txt (+0/-1)
src/Notification.cpp (+9/-15)
src/NotificationModel.cpp (+19/-61)
src/NotificationServer.cpp (+8/-13)
test/notificationtest.cpp (+43/-29)
To merge this branch: bzr merge lp:~lukas-kde/unity-notifications/visibleQueueFixes
Reviewer Review Type Date Requested Status
Michael Zanetti (community) Approve
Unity8 CI Bot continuous-integration Approve
Unity API Team Pending
Review via email: mp+301304@code.launchpad.net

Commit message

Visible queue improvements

Description of the change

Don't block the visible queue by snap decisions, allow for showing everything, sorted by type and urgency

Also do some cleanup and get rid of the Placeholder notification

Based on design request

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:243
https://unity8-jenkins.ubuntu.com/job/lp-unity-notifications-ci/2/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/2391
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/2419
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2306
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2306
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2306
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2299
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2299/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2299
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2299/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2299
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2299/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2299
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2299/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2299
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2299/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2299
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2299/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2299
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2299/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2299
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2299/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2299
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2299/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity-notifications-ci/2/rebuild

review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

Hmm, the code reads ok to me. Nice cleanup!

However, visually it looks a bit weird. Not sure if that's because of the removal of the placeholder notification but I'm afraid this requires some visual tweaks in unity8 too:

* http://i.imgur.com/MzHWx0N.png
  Spacing between notifications missing

* http://i.imgur.com/FdP0SYJ.png
  Having a SnapDecision and a Confirmation, it seems the incoming telegram message is put into the wrong place in the queue. I would think the SnapDecision should stay expanded and the telegram notification be the last one

* http://i.imgur.com/ZB7S9Ju.png
  Also without SnapDecision, the spacing seems broken now (probably really because of the removal of the placeholder)

review: Needs Information
244. By Lukáš Tinkl

respect the order

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:244
https://unity8-jenkins.ubuntu.com/job/lp-unity-notifications-ci/3/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/2423
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/2451
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2338
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2338
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2338
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2331
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2331/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2331
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2331/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2331
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2331/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2331
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2331/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2331
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2331/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2331
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2331/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2331
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2331/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2331
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2331/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2331
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2331/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity-notifications-ci/3/rebuild

review: Approve (continuous-integration)
245. By Lukáš Tinkl

append the notification, not prepend

side effect of the placeholder :S

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:245
https://unity8-jenkins.ubuntu.com/job/lp-unity-notifications-ci/4/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/2425
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/2453
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2340
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2340
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2340
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2333
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2333/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2333
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2333/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2333
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2333/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2333
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2333/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2333
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2333/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2333
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2333/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2333
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2333/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2333
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2333/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2333
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2333/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity-notifications-ci/4/rebuild

review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

Mostly good now. Regular notifications are now displayed all at once too atm. Need to check with design if that's ok or not.

review: Needs Information
Revision history for this message
Michael Zanetti (mzanetti) wrote :

Ok. Got confirmation from design that this is ok.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/ActionModel.h'
--- include/ActionModel.h 2015-10-13 14:11:24 +0000
+++ include/ActionModel.h 2016-08-01 14:19:24 +0000
@@ -29,9 +29,9 @@
29 ActionModel(QObject *parent=nullptr);29 ActionModel(QObject *parent=nullptr);
30 virtual ~ActionModel();30 virtual ~ActionModel();
3131
32 virtual int rowCount(const QModelIndex &index) const override;32 int rowCount(const QModelIndex &index) const override;
33 virtual QVariant data(const QModelIndex &index, int role) const override;33 QVariant data(const QModelIndex &index, int role) const override;
34 virtual QHash<int, QByteArray> roleNames() const override;34 QHash<int, QByteArray> roleNames() const override;
3535
36 enum ActionsRoles {36 enum ActionsRoles {
37 RoleActionLabel = Qt::UserRole + 1,37 RoleActionLabel = Qt::UserRole + 1,
3838
=== modified file 'include/Notification.h'
--- include/Notification.h 2015-10-12 15:21:27 +0000
+++ include/Notification.h 2016-08-01 14:19:24 +0000
@@ -26,7 +26,6 @@
26#include <QString>26#include <QString>
27#include <QObject>27#include <QObject>
28#include <QScopedPointer>28#include <QScopedPointer>
29#include <QImage>
30#include <QStringList>29#include <QStringList>
3130
32struct NotificationPrivate;31struct NotificationPrivate;
@@ -70,10 +69,6 @@
70 void dismissed();69 void dismissed();
71 void completed(unsigned int id);70 void completed(unsigned int id);
7271
73public Q_SLOTS:
74 void onHovered();
75 void onDisplayed();
76
77public:72public:
78 Notification(QObject *parent=nullptr);73 Notification(QObject *parent=nullptr);
79 Notification(NotificationID id,74 Notification(NotificationID id,
8075
=== modified file 'include/NotificationModel.h'
--- include/NotificationModel.h 2015-10-12 15:21:27 +0000
+++ include/NotificationModel.h 2016-08-01 14:19:24 +0000
@@ -79,7 +79,6 @@
79 int nextTimeout() const;79 int nextTimeout() const;
80 void incrementDisplayTimes(const int displayedTime) const;80 void incrementDisplayTimes(const int displayedTime) const;
81 void pruneExpired();81 void pruneExpired();
82 void removeNonSnap();
8382
84 int insertionPoint(const QSharedPointer<Notification> &n) const;83 int insertionPoint(const QSharedPointer<Notification> &n) const;
85 void insertEphemeral(const QSharedPointer<Notification> &n);84 void insertEphemeral(const QSharedPointer<Notification> &n);
8685
=== modified file 'include/NotificationServer.h'
--- include/NotificationServer.h 2015-07-06 18:13:16 +0000
+++ include/NotificationServer.h 2016-08-01 14:19:24 +0000
@@ -55,7 +55,7 @@
5555
56 Q_OBJECT56 Q_OBJECT
5757
58 friend NotificationsAdaptor;58 friend class NotificationsAdaptor;
5959
60public:60public:
61 NotificationServer(const QDBusConnection& connection, NotificationModel &m, QObject *parent=nullptr);61 NotificationServer(const QDBusConnection& connection, NotificationModel &m, QObject *parent=nullptr);
@@ -82,15 +82,14 @@
8282
83private:83private:
84 void incrementCounter();84 void incrementCounter();
85 QString messageSender();85 QString messageSender() const;
86 bool isCmdLine();86 bool isCmdLine() const;
8787
88 QSharedPointer<Notification> buildNotification(NotificationID id, const QVariantMap &hints);88 QSharedPointer<Notification> buildNotification(NotificationID id, const QVariantMap &hints);
89 NotificationModel &model;89 NotificationModel &model;
90 unsigned int idCounter;90 unsigned int idCounter;
91 QDBusConnection m_connection;91 QDBusConnection m_connection;
92 QDBusServiceWatcher m_watcher;92 QDBusServiceWatcher m_watcher;
93
94};93};
9594
96#endif95#endif
9796
=== modified file 'include/notify-backend.h.in'
--- include/notify-backend.h.in 2014-11-04 13:03:18 +0000
+++ include/notify-backend.h.in 2016-08-01 14:19:24 +0000
@@ -22,38 +22,13 @@
22#ifndef NOTIFY_BACKEND_22#ifndef NOTIFY_BACKEND_
23#define NOTIFY_BACKEND_23#define NOTIFY_BACKEND_
2424
25#include <cstdlib>
26
27typedef unsigned int NotificationID;25typedef unsigned int NotificationID;
2826
29/*enum Urgency {
30 URGENCY_LOW,
31 URGENCY_NORMAL,
32 URGENCY_CRITICAL
33};
34
35enum NotificationType {
36 SYNCHRONOUS,
37 SNAP,
38 INTERACTIVE,
39 ASYNCHRONOUS
40};*/
41
42const unsigned int MAX_NOTIFICATIONS = 50;27const unsigned int MAX_NOTIFICATIONS = 50;
4328
44class Renderer;
45class NotificationBackend;
46class Notification;
47
48#if 0
49#define DBUS_SERVICE_NAME "com.canonical.notificationproto"
50#define DBUS_INTERFACE "com.canonical.notificationproto"
51#define DBUS_PATH "/com/canonical/notificationproto"
52#else
53#define DBUS_SERVICE_NAME "org.freedesktop.Notifications"29#define DBUS_SERVICE_NAME "org.freedesktop.Notifications"
54#define DBUS_INTERFACE "org.freedesktop.Notifications"30#define DBUS_INTERFACE "org.freedesktop.Notifications"
55#define DBUS_PATH "/org/freedesktop/Notifications"31#define DBUS_PATH "/org/freedesktop/Notifications"
56#endif
5732
58#define VALUE_HINT "value"33#define VALUE_HINT "value"
59#define VALUE_TINT_HINT "x-canonical-value-bar-tint"34#define VALUE_TINT_HINT "x-canonical-value-bar-tint"
6035
=== modified file 'src/ActionModel.cpp'
--- src/ActionModel.cpp 2015-06-16 08:11:33 +0000
+++ src/ActionModel.cpp 2016-08-01 14:19:24 +0000
@@ -17,8 +17,8 @@
17#include "ActionModel.h"17#include "ActionModel.h"
1818
19struct ActionModelPrivate {19struct ActionModelPrivate {
20 QList<QString> labels;20 QStringList labels;
21 QList<QString> ids;21 QStringList ids;
22};22};
2323
24ActionModel::ActionModel(QObject *parent) : QStringListModel(parent), p(new ActionModelPrivate) {24ActionModel::ActionModel(QObject *parent) : QStringListModel(parent), p(new ActionModelPrivate) {
@@ -33,17 +33,17 @@
3333
34QVariant ActionModel::data(const QModelIndex &index, int role) const {34QVariant ActionModel::data(const QModelIndex &index, int role) const {
35 if (!index.isValid())35 if (!index.isValid())
36 return QVariant();36 return QVariant();
3737
38 switch(role) {38 switch(role) {
39 case RoleActionLabel:39 case RoleActionLabel:
40 return QVariant(p->labels[index.row()]);40 return p->labels.at(index.row());
4141
42 case RoleActionId:42 case RoleActionId:
43 return QVariant(p->ids[index.row()]);43 return p->ids.at(index.row());
4444
45 default:45 default:
46 return QVariant();46 return QVariant();
47 }47 }
48}48}
4949
5050
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2015-06-23 09:11:39 +0000
+++ src/CMakeLists.txt 2016-08-01 14:19:24 +0000
@@ -1,4 +1,3 @@
1include(FindPkgConfig)
2pkg_check_modules(NOTIFICATIONS_API REQUIRED unity-shell-notifications=3)1pkg_check_modules(NOTIFICATIONS_API REQUIRED unity-shell-notifications=3)
32
4set(CORE_SRCS3set(CORE_SRCS
54
=== modified file 'src/Notification.cpp'
--- src/Notification.cpp 2015-10-12 15:04:29 +0000
+++ src/Notification.cpp 2016-08-01 14:19:24 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013 Canonical, Ltd.2 * Copyright (C) 2013-2016 Canonical, Ltd.
3 *3 *
4 * Authors:4 * Authors:
5 * Jussi Pakkanen <jussi.pakkanen@canonical.com>5 * Jussi Pakkanen <jussi.pakkanen@canonical.com>
@@ -20,7 +20,7 @@
2020
21#include "NotificationServer.h"21#include "NotificationServer.h"
22#include "Notification.h"22#include "Notification.h"
23#include <string>23
24#include <QXmlStreamReader>24#include <QXmlStreamReader>
2525
26using namespace std;26using namespace std;
@@ -74,8 +74,9 @@
74}74}
7575
76Notification::~Notification() {76Notification::~Notification() {
77 if(p->server)77 if (p->server) {
78 p->server->forceCloseNotification(p->id);78 p->server->forceCloseNotification(p->id);
79 }
79}80}
8081
81QString Notification::getBody() const {82QString Notification::getBody() const {
@@ -116,8 +117,8 @@
116}117}
117118
118void Notification::setIcon(const QString &icon) {119void Notification::setIcon(const QString &icon) {
119 if (icon.startsWith(" ") || icon.size() == 0) {120 if (icon.startsWith(" ") || icon.isEmpty()) {
120 p->icon = nullptr;121 p->icon.clear();
121 }122 }
122 else {123 else {
123 p->icon = icon;124 p->icon = icon;
@@ -136,8 +137,8 @@
136}137}
137138
138void Notification::setSecondaryIcon(const QString &secondaryIcon) {139void Notification::setSecondaryIcon(const QString &secondaryIcon) {
139 if (secondaryIcon.startsWith(" ") || secondaryIcon.size() == 0) {140 if (secondaryIcon.startsWith(" ") || secondaryIcon.isEmpty()) {
140 p->secondaryIcon = nullptr;141 p->secondaryIcon.clear();
141 }142 }
142 else {143 else {
143 p->secondaryIcon = secondaryIcon;144 p->secondaryIcon = secondaryIcon;
@@ -177,6 +178,7 @@
177Notification::Urgency Notification::getUrgency() const {178Notification::Urgency Notification::getUrgency() const {
178 return p->urg;179 return p->urg;
179}180}
181
180void Notification::setUrgency(Notification::Urgency urg) {182void Notification::setUrgency(Notification::Urgency urg) {
181 if(p->urg != urg) {183 if(p->urg != urg) {
182 p->urg = urg;184 p->urg = urg;
@@ -238,14 +240,6 @@
238 }240 }
239}241}
240242
241void Notification::onHovered() {
242
243}
244
245void Notification::onDisplayed() {
246
247}
248
249void Notification::invokeAction(const QString &action) {243void Notification::invokeAction(const QString &action) {
250 for(int i=0; i<p->actions.size(); i++) {244 for(int i=0; i<p->actions.size(); i++) {
251 if(p->actions[i] == action) {245 if(p->actions[i] == action) {
252246
=== modified file 'src/NotificationModel.cpp'
--- src/NotificationModel.cpp 2015-10-13 13:49:02 +0000
+++ src/NotificationModel.cpp 2016-08-01 14:19:24 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013 Canonical, Ltd.2 * Copyright (C) 2013-2016 Canonical, Ltd.
3 *3 *
4 * Authors:4 * Authors:
5 * Jussi Pakkanen <jussi.pakkanen@canonical.com>5 * Jussi Pakkanen <jussi.pakkanen@canonical.com>
@@ -46,8 +46,6 @@
46}46}
4747
48NotificationModel::NotificationModel(QObject *parent) : QAbstractListModel(parent), p(new NotificationModelPrivate) {48NotificationModel::NotificationModel(QObject *parent) : QAbstractListModel(parent), p(new NotificationModelPrivate) {
49 p->displayedNotifications.append(QSharedPointer<Notification>(new Notification(0, -1, Notification::Normal, QString(), Notification::PlaceHolder),
50 &QObject::deleteLater));
51 connect(&(p->timer), SIGNAL(timeout()), this, SLOT(timeout()));49 connect(&(p->timer), SIGNAL(timeout()), this, SLOT(timeout()));
52 p->timer.setSingleShot(true);50 p->timer.setSingleShot(true);
53}51}
@@ -178,8 +176,7 @@
178 }176 }
179 }177 }
180178
181 QSharedPointer<Notification> empty;179 return QSharedPointer<Notification>();
182 return empty;
183}180}
184181
185QSharedPointer<Notification> NotificationModel::getNotification(const QString &summary) const {182QSharedPointer<Notification> NotificationModel::getNotification(const QString &summary) const {
@@ -204,16 +201,14 @@
204 }201 }
205 }202 }
206203
207 QSharedPointer<Notification> empty;204 return QSharedPointer<Notification>();
208 return empty;
209}205}
210206
211QSharedPointer<Notification> NotificationModel::getDisplayedNotification(int index) const {207QSharedPointer<Notification> NotificationModel::getDisplayedNotification(int index) const {
212 if (index < p->displayedNotifications.size()) {208 if (index < p->displayedNotifications.size()) {
213 return p->displayedNotifications[index];209 return p->displayedNotifications[index];
214 } else {210 } else {
215 QSharedPointer<Notification> empty;211 return QSharedPointer<Notification>();
216 return empty;
217 }212 }
218}213}
219214
@@ -318,8 +313,7 @@
318}313}
319314
320QSharedPointer<Notification> NotificationModel::deleteFromVisible(int loc) {315QSharedPointer<Notification> NotificationModel::deleteFromVisible(int loc) {
321 QModelIndex deletePoint = QModelIndex();316 beginRemoveRows(QModelIndex(), loc, loc);
322 beginRemoveRows(deletePoint, loc, loc);
323 QSharedPointer<Notification> n = p->displayedNotifications[loc];317 QSharedPointer<Notification> n = p->displayedNotifications[loc];
324 p->displayTimes.erase(p->displayTimes.find(n->getID()));318 p->displayTimes.erase(p->displayTimes.find(n->getID()));
325 auto notification = p->displayedNotifications.takeAt(loc);319 auto notification = p->displayedNotifications.takeAt(loc);
@@ -345,8 +339,7 @@
345 // Snap decisions override everything.339 // Snap decisions override everything.
346 if(showingNotificationOfType(Notification::Type::SnapDecision) || !p->snapQueue.empty()) {340 if(showingNotificationOfType(Notification::Type::SnapDecision) || !p->snapQueue.empty()) {
347 if(countShowing(Notification::Type::SnapDecision) < maxSnapsShown && !p->snapQueue.empty()) {341 if(countShowing(Notification::Type::SnapDecision) < maxSnapsShown && !p->snapQueue.empty()) {
348 QSharedPointer<Notification> n = p->snapQueue[0];342 QSharedPointer<Notification> n = p->snapQueue.takeFirst();
349 p->snapQueue.pop_front();
350 insertToVisible(n, insertionPoint(n));343 insertToVisible(n, insertionPoint(n));
351 restartTimer = true;344 restartTimer = true;
352 Q_EMIT queueSizeChanged(queued());345 Q_EMIT queueSizeChanged(queued());
@@ -365,15 +358,13 @@
365bool NotificationModel::nonSnapTimeout() {358bool NotificationModel::nonSnapTimeout() {
366 bool restartTimer;359 bool restartTimer;
367 if(!showingNotificationOfType(Notification::Type::Interactive) && !p->interactiveQueue.empty()) {360 if(!showingNotificationOfType(Notification::Type::Interactive) && !p->interactiveQueue.empty()) {
368 QSharedPointer<Notification> n = p->interactiveQueue[0];361 QSharedPointer<Notification> n = p->interactiveQueue.takeFirst();
369 p->interactiveQueue.pop_front();
370 insertToVisible(n, insertionPoint(n));362 insertToVisible(n, insertionPoint(n));
371 restartTimer = true;363 restartTimer = true;
372 Q_EMIT queueSizeChanged(queued());364 Q_EMIT queueSizeChanged(queued());
373 }365 }
374 if(!showingNotificationOfType(Notification::Type::Ephemeral) && !p->ephemeralQueue.empty()) {366 if(!showingNotificationOfType(Notification::Type::Ephemeral) && !p->ephemeralQueue.empty()) {
375 QSharedPointer<Notification> n = p->ephemeralQueue[0];367 QSharedPointer<Notification> n = p->ephemeralQueue.takeFirst();
376 p->ephemeralQueue.pop_front();
377 insertToVisible(n, insertionPoint(n));368 insertToVisible(n, insertionPoint(n));
378 restartTimer = true;369 restartTimer = true;
379 Q_EMIT queueSizeChanged(queued());370 Q_EMIT queueSizeChanged(queued());
@@ -392,19 +383,6 @@
392 }383 }
393}384}
394385
395void NotificationModel::removeNonSnap() {
396 for(int i=p->displayedNotifications.size()-1; i>=0; i--) {
397 QSharedPointer<Notification> n = p->displayedNotifications[i];
398 switch(n->getType()) {
399 case Notification::Type::SnapDecision : break;
400 case Notification::Type::Confirmation : deleteFromVisible(i); break;
401 case Notification::Type::Ephemeral : deleteFromVisible(i); p->ephemeralQueue.push_front(n); queueSizeChanged(queued()); break;
402 case Notification::Type::Interactive : deleteFromVisible(i); p->interactiveQueue.push_front(n); queueSizeChanged(queued()); break;
403 case Notification::Type::PlaceHolder : break;
404 }
405 }
406}
407
408int NotificationModel::nextTimeout() const {386int NotificationModel::nextTimeout() const {
409 int mintime = INT_MAX;387 int mintime = INT_MAX;
410 if(p->displayedNotifications.empty()) {388 if(p->displayedNotifications.empty()) {
@@ -430,51 +408,35 @@
430void NotificationModel::insertEphemeral(const QSharedPointer<Notification> &n) {408void NotificationModel::insertEphemeral(const QSharedPointer<Notification> &n) {
431 Q_ASSERT(n->getType() == Notification::Type::Ephemeral);409 Q_ASSERT(n->getType() == Notification::Type::Ephemeral);
432410
433 if(showingNotificationOfType(Notification::Type::SnapDecision)) {411 if(showingNotificationOfType(Notification::Type::Ephemeral)) {
434 p->ephemeralQueue.push_back(n);
435 qStableSort(p->ephemeralQueue.begin(), p->ephemeralQueue.end(), notificationCompare);
436 Q_EMIT queueSizeChanged(queued());
437 } else if(showingNotificationOfType(Notification::Type::Ephemeral)) {
438 int loc = findFirst(Notification::Type::Ephemeral);412 int loc = findFirst(Notification::Type::Ephemeral);
439 QSharedPointer<Notification> showing = p->displayedNotifications[loc];413 QSharedPointer<Notification> showing = p->displayedNotifications[loc];
440 if(n->getUrgency() > showing->getUrgency()) {414 if(n->getUrgency() > showing->getUrgency()) {
441 deleteFromVisible(loc);415 insertToVisible(n, qMax(0, loc-1));
442 insertToVisible(n, loc);
443 p->ephemeralQueue.push_front(showing);
444 } else {416 } else {
445 p->ephemeralQueue.push_back(n);417 insertToVisible(n, loc+1);
446 }418 }
447 qStableSort(p->ephemeralQueue.begin(), p->ephemeralQueue.end(), notificationCompare);
448 Q_EMIT queueSizeChanged(queued());
449 } else {419 } else {
450 insertToVisible(n);420 int loc = insertionPoint(n);
421 insertToVisible(n, loc);
451 }422 }
452}423}
453424
454void NotificationModel::insertInteractive(const QSharedPointer<Notification> &n) {425void NotificationModel::insertInteractive(const QSharedPointer<Notification> &n) {
455 Q_ASSERT(n->getType() == Notification::Type::Interactive);426 Q_ASSERT(n->getType() == Notification::Type::Interactive);
456427
457 if(showingNotificationOfType(Notification::Type::SnapDecision)) {428 if(showingNotificationOfType(Notification::Type::Interactive)) {
458 p->interactiveQueue.push_back(n);
459 qStableSort(p->interactiveQueue.begin(), p->interactiveQueue.end(), notificationCompare);
460 Q_EMIT queueSizeChanged(queued());
461 } else if(showingNotificationOfType(Notification::Type::Interactive)) {
462 int loc = findFirst(Notification::Type::Interactive);429 int loc = findFirst(Notification::Type::Interactive);
463 QSharedPointer<Notification> showing = p->displayedNotifications[loc];430 QSharedPointer<Notification> showing = p->displayedNotifications[loc];
464 if(n->getUrgency() > showing->getUrgency()) {431 if(n->getUrgency() > showing->getUrgency()) {
465 deleteFromVisible(loc);432 insertToVisible(n, qMax(0, loc-1));
466 insertToVisible(n, loc);
467 p->interactiveQueue.push_front(showing);
468 } else {433 } else {
469 p->interactiveQueue.push_back(n);434 insertToVisible(n, loc+1);
470 }435 }
471 qStableSort(p->interactiveQueue.begin(), p->interactiveQueue.end(), notificationCompare);
472 Q_EMIT queueSizeChanged(queued());
473 } else {436 } else {
474 int loc = insertionPoint(n);437 int loc = insertionPoint(n);
475 insertToVisible(n, loc);438 insertToVisible(n, loc);
476 }439 }
477
478}440}
479441
480442
@@ -489,7 +451,6 @@
489451
490void NotificationModel::insertSnap(const QSharedPointer<Notification> &n) {452void NotificationModel::insertSnap(const QSharedPointer<Notification> &n) {
491 Q_ASSERT(n->getType() == Notification::Type::SnapDecision);453 Q_ASSERT(n->getType() == Notification::Type::SnapDecision);
492 removeNonSnap();
493 int showing = countShowing(n->getType());454 int showing = countShowing(n->getType());
494 if(showing >= maxSnapsShown) {455 if(showing >= maxSnapsShown) {
495 int loc = findFirst(Notification::Type::SnapDecision);456 int loc = findFirst(Notification::Type::SnapDecision);
@@ -522,7 +483,7 @@
522 }483 }
523484
524 if (!inserted) {485 if (!inserted) {
525 insertToVisible(n, 1);486 insertToVisible(n, showingNotificationOfType(Notification::Type::Confirmation) ? 1 : 0);
526 }487 }
527 }488 }
528}489}
@@ -541,7 +502,7 @@
541 int i=0;502 int i=0;
542 for(; i<p->displayedNotifications.size(); i++) {503 for(; i<p->displayedNotifications.size(); i++) {
543 if(p->displayedNotifications[i]->getType() > n->getType()) {504 if(p->displayedNotifications[i]->getType() > n->getType()) {
544 break;505 return i+1;
545 }506 }
546 }507 }
547 return i;508 return i;
@@ -555,10 +516,7 @@
555 printf("Bad insert.\n");516 printf("Bad insert.\n");
556 return;517 return;
557 }518 }
558 //QModelIndex insertionPoint = QAbstractItemModel::createIndex(location, 0);519 beginInsertRows(QModelIndex(), location, location);
559 //beginInsertRows(insertionPoint, location, location);
560 QModelIndex insertionPoint = QModelIndex();
561 beginInsertRows(insertionPoint, location, location);
562 p->displayedNotifications.insert(location, n);520 p->displayedNotifications.insert(location, n);
563 endInsertRows();521 endInsertRows();
564 p->displayTimes[n->getID()] = 0;522 p->displayTimes[n->getID()] = 0;
565523
=== modified file 'src/NotificationServer.cpp'
--- src/NotificationServer.cpp 2015-10-13 11:15:28 +0000
+++ src/NotificationServer.cpp 2016-08-01 14:19:24 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013 Canonical, Ltd.2 * Copyright (C) 2013-2016 Canonical, Ltd.
3 *3 *
4 * Authors:4 * Authors:
5 * Jussi Pakkanen <jussi.pakkanen@canonical.com>5 * Jussi Pakkanen <jussi.pakkanen@canonical.com>
@@ -28,7 +28,7 @@
2828
29static const char* LOCAL_OWNER = "local";29static const char* LOCAL_OWNER = "local";
3030
31static bool isAuthorised(const QString& clientId, QSharedPointer<Notification> notification)31static bool isAuthorised(const QString& clientId, const QSharedPointer<Notification> &notification)
32{32{
33 return (clientId == LOCAL_OWNER) || (notification->getClientId() == clientId);33 return (clientId == LOCAL_OWNER) || (notification->getClientId() == clientId);
34}34}
@@ -97,7 +97,7 @@
9797
98NotificationDataList NotificationServer::GetNotifications(const QString &app_name) {98NotificationDataList NotificationServer::GetNotifications(const QString &app_name) {
99 NotificationDataList results;99 NotificationDataList results;
100 for (auto notification: model.getAllNotifications()) {100 Q_FOREACH(const auto &notification, model.getAllNotifications()) {
101 NotificationData data;101 NotificationData data;
102 data.appName = app_name;102 data.appName = app_name;
103 data.id = notification->getID();103 data.id = notification->getID();
@@ -159,7 +159,7 @@
159 }159 }
160}160}
161161
162QString NotificationServer::messageSender() {162QString NotificationServer::messageSender() const {
163 QString sender(LOCAL_OWNER);163 QString sender(LOCAL_OWNER);
164 if (calledFromDBus()) {164 if (calledFromDBus()) {
165 sender = message().service();165 sender = message().service();
@@ -167,7 +167,7 @@
167 return sender;167 return sender;
168}168}
169169
170bool NotificationServer::isCmdLine() {170bool NotificationServer::isCmdLine() const {
171 if (!calledFromDBus()) {171 if (!calledFromDBus()) {
172 return false;172 return false;
173 }173 }
@@ -179,8 +179,8 @@
179179
180void NotificationServer::serviceUnregistered(const QString &clientId) {180void NotificationServer::serviceUnregistered(const QString &clientId) {
181 m_watcher.removeWatchedService(clientId);181 m_watcher.removeWatchedService(clientId);
182 auto notifications = model.removeAllNotificationsForClient(clientId);182 const auto notifications = model.removeAllNotificationsForClient(clientId);
183 for (auto notification: notifications) {183 Q_FOREACH(const auto &notification, notifications) {
184 Q_EMIT NotificationClosed(notification->getID(), 1);184 Q_EMIT NotificationClosed(notification->getID(), 1);
185 }185 }
186}186}
@@ -276,12 +276,7 @@
276 notification->setBody(body);276 notification->setBody(body);
277 notification->setIcon(app_icon);277 notification->setIcon(app_icon);
278 notification->setSummary(summary);278 notification->setSummary(summary);
279279 notification->setHints(hints);
280 QVariantMap notifyHints;
281 for (auto iter = hints.constBegin(), end = hints.constEnd(); iter != end; ++iter) {
282 notifyHints[iter.key()] = iter.value();
283 }
284 notification->setHints(notifyHints);
285280
286 QVariant secondaryIcon = hints[SECONDARY_ICON_HINT];281 QVariant secondaryIcon = hints[SECONDARY_ICON_HINT];
287 notification->setSecondaryIcon(secondaryIcon.toString());282 notification->setSecondaryIcon(secondaryIcon.toString());
288283
=== modified file 'test/notificationtest.cpp'
--- test/notificationtest.cpp 2015-10-12 15:21:27 +0000
+++ test/notificationtest.cpp 2016-08-01 14:19:24 +0000
@@ -4,11 +4,6 @@
44
5#include <QtTest/QtTest>5#include <QtTest/QtTest>
66
7typedef struct {
8 const char* before;
9 const char* expected;
10} TextComparisons;
11
12class TestNotifications: public QObject7class TestNotifications: public QObject
13{8{
14 Q_OBJECT9 Q_OBJECT
@@ -33,11 +28,11 @@
33 QSharedPointer<Notification> n(new Notification(42, timeout, Notification::Low, "this is text"));28 QSharedPointer<Notification> n(new Notification(42, timeout, Notification::Low, "this is text"));
34 NotificationModel m;29 NotificationModel m;
3530
36 QCOMPARE(m.numNotifications(), 1);31 QCOMPARE(m.numNotifications(), 0);
37 m.insertNotification(n);32 m.insertNotification(n);
38 QCOMPARE(m.numNotifications(), 2);33 QCOMPARE(m.numNotifications(), 1);
39 m.removeNotification(n->getID());34 m.removeNotification(n->getID());
40 QCOMPARE(m.numNotifications(), 1);35 QCOMPARE(m.numNotifications(), 0);
41}36}
4237
43void TestNotifications::testTypeSimple() {38void TestNotifications::testTypeSimple() {
@@ -60,9 +55,9 @@
60 const int timeout = 1000;55 const int timeout = 1000;
61 static NotificationModel *m = new NotificationModel(this);56 static NotificationModel *m = new NotificationModel(this);
62 static NotificationServer *s = new NotificationServer(QDBusConnection::sessionBus(), *m);57 static NotificationServer *s = new NotificationServer(QDBusConnection::sessionBus(), *m);
63 QStringList actions = QStringList();58 QStringList actions;
64 QVariantMap hints;59 QVariantMap hints;
65 int id[3];60 int id[4];
6661
67 hints[URGENCY_HINT] = QVariant::fromValue(Notification::Urgency::Low);62 hints[URGENCY_HINT] = QVariant::fromValue(Notification::Urgency::Low);
68 id[0] = s->Notify ("test-name-low", 0, "icon-low", "summary-low", "body-low", actions, hints, timeout);63 id[0] = s->Notify ("test-name-low", 0, "icon-low", "summary-low", "body-low", actions, hints, timeout);
@@ -70,22 +65,41 @@
7065
71 hints[URGENCY_HINT] = QVariant::fromValue(Notification::Urgency::Normal);66 hints[URGENCY_HINT] = QVariant::fromValue(Notification::Urgency::Normal);
72 id[1] = s->Notify ("test-name-normal", 0, "icon-normal", "summary-normal", "body-normal", actions, hints, timeout);67 id[1] = s->Notify ("test-name-normal", 0, "icon-normal", "summary-normal", "body-normal", actions, hints, timeout);
73 QVERIFY(!m->showingNotification(id[0]));68 QVERIFY(m->showingNotification(id[0]));
74 QVERIFY(m->showingNotification(id[1]));69 QVERIFY(m->showingNotification(id[1]));
75 QVERIFY(m->queued() == 1);70 QVERIFY(m->getNotification(id[1]) == m->getDisplayedNotification(0)); // verify it's ordered by urgency
71 QVERIFY(m->queued() == 0);
7672
77 hints[URGENCY_HINT] = QVariant::fromValue(Notification::Urgency::Critical);73 hints[URGENCY_HINT] = QVariant::fromValue(Notification::Urgency::Critical);
78 id[2] = s->Notify ("test-name-critical", 0, "icon-critical", "summary-critical", "body-critical", actions, hints, timeout);74 id[2] = s->Notify ("test-name-critical", 0, "icon-critical", "summary-critical", "body-critical", actions, hints, timeout);
79 QVERIFY(!m->showingNotification(id[0]));75 QVERIFY(m->showingNotification(id[0]));
80 QVERIFY(!m->showingNotification(id[1]));76 QVERIFY(m->showingNotification(id[1]));
81 QVERIFY(m->showingNotification(id[2]));77 QVERIFY(m->showingNotification(id[2]));
82 QCOMPARE(m->queued(), 2);78 QVERIFY(m->getNotification(id[2]) == m->getDisplayedNotification(0)); // verify it's ordered by urgency
79 QCOMPARE(m->queued(), 0);
80
81 hints[SNAP_HINT] = QStringLiteral("true");
82 hints[URGENCY_HINT] = QVariant::fromValue(Notification::Urgency::Normal);
83 id[3] = s->Notify ("test-name-snap", 0, "icon-snap", "summary-snap", "body-snap", {"snap", "decision", "needs", "actions"}, hints, timeout);
84 QVERIFY(m->showingNotification(id[0]));
85 QVERIFY(m->showingNotification(id[1]));
86 QVERIFY(m->showingNotification(id[2]));
87 QVERIFY(m->showingNotification(id[3]));
88 QVERIFY(m->getNotification(id[3]) == m->getDisplayedNotification(0)); // verify it's ordered by urgency and type, snap comes first
89 QCOMPARE(m->queued(), 0);
90
91 m->removeNotification(id[3]);
92 QVERIFY(m->showingNotification(id[0]));
93 QVERIFY(m->showingNotification(id[1]));
94 QVERIFY(m->showingNotification(id[2]));
95 QVERIFY(!m->showingNotification(id[3]));
96 QCOMPARE(m->queued(), 0);
8397
84 m->removeNotification(id[2]);98 m->removeNotification(id[2]);
85 QVERIFY(!m->showingNotification(id[0]));99 QVERIFY(m->showingNotification(id[0]));
86 QVERIFY(m->showingNotification(id[1]));100 QVERIFY(m->showingNotification(id[1]));
87 QVERIFY(!m->showingNotification(id[2]));101 QVERIFY(!m->showingNotification(id[2]));
88 QCOMPARE(m->queued(), 1);102 QCOMPARE(m->queued(), 0);
89103
90 m->removeNotification(id[1]);104 m->removeNotification(id[1]);
91 QVERIFY(m->showingNotification(id[0]));105 QVERIFY(m->showingNotification(id[0]));
@@ -173,7 +187,7 @@
173 m.insertNotification(n3);187 m.insertNotification(n3);
174 m.insertNotification(n4);188 m.insertNotification(n4);
175189
176 QCOMPARE(m.getDisplayedNotification(1)->getBody(), QString("snap-decision-critical"));190 QCOMPARE(m.getDisplayedNotification(0)->getBody(), QString("snap-decision-critical"));
177}191}
178192
179void TestNotifications::testVisualSDQueueWithoutCritical() {193void TestNotifications::testVisualSDQueueWithoutCritical() {
@@ -190,10 +204,10 @@
190 m.insertNotification(n3);204 m.insertNotification(n3);
191 m.insertNotification(n4);205 m.insertNotification(n4);
192206
193 QCOMPARE(m.getDisplayedNotification(4)->getBody(), QString("snap-decision-1"));207 QCOMPARE(m.getDisplayedNotification(3)->getBody(), QString("snap-decision-1"));
194 QCOMPARE(m.getDisplayedNotification(3)->getBody(), QString("snap-decision-2"));208 QCOMPARE(m.getDisplayedNotification(2)->getBody(), QString("snap-decision-2"));
195 QCOMPARE(m.getDisplayedNotification(2)->getBody(), QString("snap-decision-3"));209 QCOMPARE(m.getDisplayedNotification(1)->getBody(), QString("snap-decision-3"));
196 QCOMPARE(m.getDisplayedNotification(1)->getBody(), QString("snap-decision-4"));210 QCOMPARE(m.getDisplayedNotification(0)->getBody(), QString("snap-decision-4"));
197}211}
198212
199void TestNotifications::testConfirmationValue() {213void TestNotifications::testConfirmationValue() {
@@ -213,8 +227,8 @@
213 m.insertNotification(ephemeral);227 m.insertNotification(ephemeral);
214 m.insertNotification(confirmation);228 m.insertNotification(confirmation);
215229
216 QCOMPARE(m.getDisplayedNotification(2)->getBody(), QString("ephemeral"));230 QCOMPARE(m.getDisplayedNotification(1)->getBody(), QString("ephemeral"));
217 QCOMPARE(m.getDisplayedNotification(1)->getBody(), QString(""));231 QCOMPARE(m.getDisplayedNotification(0)->getBody(), QString(""));
218}232}
219233
220void TestNotifications::testTextFilter_data() {234void TestNotifications::testTextFilter_data() {
@@ -273,11 +287,11 @@
273 const int max = 20;287 const int max = 20;
274 static NotificationModel *m = new NotificationModel();288 static NotificationModel *m = new NotificationModel();
275 static NotificationServer *s = new NotificationServer(QDBusConnection::sessionBus(), *m);289 static NotificationServer *s = new NotificationServer(QDBusConnection::sessionBus(), *m);
276 QStringList actions = QStringList();290 QStringList actions;
277 QVariantMap hints;291 QVariantMap hints;
278 int before = m->numNotifications();292 int before = m->numNotifications();
279293
280 for (int i = 1; i <= max; i++) {294 for (int i = 0; i < max; i++) {
281 s->Notify ("test-app-name",295 s->Notify ("test-app-name",
282 0,296 0,
283 "test-icon",297 "test-icon",
@@ -288,11 +302,11 @@
288 timeout);302 timeout);
289 }303 }
290304
291 QCOMPARE(m->numNotifications(), max+1);305 QCOMPARE(m->numNotifications(), max);
292306
293 for (int i = max; i >= 1; i--) {307 for (int i = max; i >= 1; i--) {
294 m->getNotification(i)->close();308 m->getNotification(i)->close();
295 QCOMPARE(m->numNotifications(), i);309 QCOMPARE(m->numNotifications(), i-1);
296 }310 }
297311
298 QCOMPARE(m->numNotifications(), before);312 QCOMPARE(m->numNotifications(), before);

Subscribers

People subscribed via source and target branches

to all changes: