Skip to content

Commit

Permalink
Merge branch 'jb50443' into 'master'
Browse files Browse the repository at this point in the history
[lipstick] Remove handling of the x-nemo-hidden notification hint. Contributes to JB#50443

See merge request mer-core/lipstick!148
  • Loading branch information
adenexter committed Aug 18, 2020
2 parents 645c9e3 + 0abda12 commit be06414
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 66 deletions.
7 changes: 0 additions & 7 deletions src/notifications/lipsticknotification.cpp
Expand Up @@ -41,7 +41,6 @@ const char *LipstickNotification::HINT_REMOTE_ACTION_PREFIX = "x-nemo-remote-act
const char *LipstickNotification::HINT_REMOTE_ACTION_ICON_PREFIX = "x-nemo-remote-action-icon-";
const char *LipstickNotification::HINT_USER_REMOVABLE = "x-nemo-user-removable";
const char *LipstickNotification::HINT_FEEDBACK = "x-nemo-feedback";
const char *LipstickNotification::HINT_HIDDEN = "x-nemo-hidden";
const char *LipstickNotification::HINT_DISPLAY_ON = "x-nemo-display-on";
const char *LipstickNotification::HINT_SUPPRESS_DISPLAY_ON = "x-nemo-suppress-display-on";
const char *LipstickNotification::HINT_ORIGIN = "x-nemo-origin";
Expand Down Expand Up @@ -309,11 +308,6 @@ bool LipstickNotification::isUserRemovableByHint() const
return (m_hints.value(LipstickNotification::HINT_USER_REMOVABLE, QVariant(true)).toBool());
}

bool LipstickNotification::hidden() const
{
return m_hints.value(LipstickNotification::HINT_HIDDEN, QVariant(false)).toBool();
}

QVariantList LipstickNotification::remoteActions() const
{
QVariantList rv;
Expand Down Expand Up @@ -456,7 +450,6 @@ void LipstickNotification::updateHintValues()
hint.compare(LipstickNotification::HINT_PRIORITY, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_CATEGORY, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_USER_REMOVABLE, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_HIDDEN, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_ORIGIN, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_OWNER, Qt::CaseInsensitive) != 0 &&
hint.compare(LipstickNotification::HINT_MAX_CONTENT_LINES, Qt::CaseInsensitive) != 0 &&
Expand Down
6 changes: 0 additions & 6 deletions src/notifications/lipsticknotification.h
Expand Up @@ -118,9 +118,6 @@ class LIPSTICK_EXPORT LipstickNotification : public QObject
//! Nemo hint: Feedback of the notification.
static const char *HINT_FEEDBACK;

//! Nemo hint: Whether the notification is hidden.
static const char *HINT_HIDDEN;

//! Nemo hint: Whether to turn the screen on when displaying preview
static const char *HINT_DISPLAY_ON;

Expand Down Expand Up @@ -252,9 +249,6 @@ class LIPSTICK_EXPORT LipstickNotification : public QObject
//! Returns the user removability hint state
bool isUserRemovableByHint() const;

//! Returns true if the notification has been hidden to prevent further display
bool hidden() const;

//! Returns the remote actions invokable by the notification
QVariantList remoteActions() const;

Expand Down
2 changes: 1 addition & 1 deletion src/notifications/notificationfeedbackplayer.cpp
Expand Up @@ -115,7 +115,7 @@ void NotificationFeedbackPlayer::removeNotification(uint id)

bool NotificationFeedbackPlayer::isEnabled(LipstickNotification *notification, int minimumPriority)
{
if (notification->hidden() || notification->restored())
if (notification->restored())
return false;

uint mode = AllNotificationsEnabled;
Expand Down
2 changes: 1 addition & 1 deletion src/notifications/notificationlistmodel.cpp
Expand Up @@ -153,5 +153,5 @@ void NotificationListModel::removeNotifications(const QList<uint> &ids)

bool NotificationListModel::notificationShouldBeShown(LipstickNotification *notification)
{
return !notification->hidden() && (!notification->body().isEmpty() || !notification->summary().isEmpty());
return !notification->body().isEmpty() || !notification->summary().isEmpty();
}
3 changes: 1 addition & 2 deletions src/notifications/notificationpreviewpresenter.cpp
Expand Up @@ -184,8 +184,7 @@ void NotificationPreviewPresenter::createWindowIfNecessary()

bool NotificationPreviewPresenter::notificationShouldBeShown(LipstickNotification *notification)
{
if (notification->hidden()
|| notification->restored()
if (notification->restored()
|| (notification->previewBody().isEmpty() && notification->previewSummary().isEmpty())) {
return false;
}
Expand Down
Expand Up @@ -200,19 +200,6 @@ void Ut_NotificationFeedbackPlayer::testMultipleFeedbackIds()
QCOMPARE(eventIds, QSet<quint32>() << 1 << 2);
}

void Ut_NotificationFeedbackPlayer::testHiddenNotification()
{
// Create a notification
LipstickNotification *notification = createNotification(1);
QVariantHash hints(notification->hints());
hints.insert(LipstickNotification::HINT_HIDDEN, true);
notification->setHints(hints);
player->addNotification(1);

// Check that NGFAdapter::play() was not called for the feedback
QCOMPARE(gClientStub->stubCallCount("play"), 0);
}

void Ut_NotificationFeedbackPlayer::testNotificationSoundSuppressed()
{
gClientStub->stubSetReturnValue("play", (quint32)1);
Expand Down
Expand Up @@ -35,7 +35,6 @@ private slots:
void testAddAndRemoveNotification();
void testWithoutFeedbackId();
void testMultipleFeedbackIds();
void testHiddenNotification();
void testNotificationSoundSuppressed();
void testUpdateNotification();
void testUpdateNotificationAfterRestart();
Expand Down
11 changes: 0 additions & 11 deletions tests/ut_notificationlistmodel/ut_notificationlistmodel.cpp
Expand Up @@ -91,17 +91,6 @@ void Ut_NotificationListModel::testNotificationIsNotAddedIfNoSummaryOrBody()
QCOMPARE(model.itemCount(), addItemCount);
}

void Ut_NotificationListModel::testNotificationIsNotAddedIfHidden()
{
QVariantHash hints;
hints.insert(LipstickNotification::HINT_HIDDEN, true);
LipstickNotification notification("appName", "appName", 1, "appIcon", "summary", "body", QStringList() << "action", hints, 1);
gNotificationManagerStub->stubSetReturnValue("notificationIds", QList<uint>() << 1);
gNotificationManagerStub->stubSetReturnValue("notification", &notification);
NotificationListModel model;
QCOMPARE(model.itemCount(), 0);
}

void Ut_NotificationListModel::testAlreadyAddedNotificationIsRemovedIfNoLongerAddable()
{
LipstickNotification notification("appName", "appName", 1, "appIcon", "", "", QStringList() << "action", QVariantHash(), 1);
Expand Down
1 change: 0 additions & 1 deletion tests/ut_notificationlistmodel/ut_notificationlistmodel.h
Expand Up @@ -28,7 +28,6 @@ private slots:
void testNotificationIsOnlyAddedIfNotAlreadyAdded();
void testNotificationIsNotAddedIfNoSummaryOrBody_data();
void testNotificationIsNotAddedIfNoSummaryOrBody();
void testNotificationIsNotAddedIfHidden();
void testAlreadyAddedNotificationIsRemovedIfNoLongerAddable();
void testNotificationRemoval();
void testNotificationOrdering();
Expand Down
Expand Up @@ -392,28 +392,6 @@ void Ut_NotificationPreviewPresenter::testNotificationNotShownIfNoSummaryOrBody(
}
}

void Ut_NotificationPreviewPresenter::testNotificationNotShownIfHidden()
{
NotificationPreviewPresenter presenter(screenLock, deviceLock);
QSignalSpy changedSpy(&presenter, SIGNAL(notificationChanged()));

// Create notification
QVariantHash hints;
hints.insert(LipstickNotification::HINT_PREVIEW_SUMMARY, "previewSummary");
hints.insert(LipstickNotification::HINT_PREVIEW_BODY, "previewBody");
hints.insert(LipstickNotification::HINT_HIDDEN, true);
LipstickNotification *notification = new LipstickNotification("ut_notificationpreviewpresenter", "", 1, "", "", "", QStringList(), hints, -1);
notificationManagerNotification.insert(1, notification);
presenter.updateNotification(1);

QCOMPARE(changedSpy.count(), 0);
QCOMPARE(homeWindowVisible.isEmpty(), true);

// The notification should be considered presented
QCOMPARE(playedFeedbacks(), 1);
QCOMPARE(lastFeedbackId(), (uint)1);
}

void Ut_NotificationPreviewPresenter::testNotificationNotShownIfRestored()
{
NotificationPreviewPresenter presenter(screenLock, deviceLock);
Expand Down
Expand Up @@ -38,7 +38,6 @@ private slots:
void testRemoveNotification();
void testNotificationNotShownIfNoSummaryOrBody_data();
void testNotificationNotShownIfNoSummaryOrBody();
void testNotificationNotShownIfHidden();
void testNotificationNotShownIfRestored();
void testShowingOnlyCriticalNotifications();
void testUpdateNotificationRemovesNotificationFromQueueIfNotShowable();
Expand Down

0 comments on commit be06414

Please sign in to comment.