test: ensure sender-pid hint is set in Linux notifications (#43951)

test: expect a `sender-pid` hint in Linux notifications.

This PR ensures that the `sender-pid` hint is set for new notifications.
It also updates the spec to confirm that DBus receives the hint and that
it has the correct value.

This fixes a spec failure when running libnotify >= 0.7.12 (2022-05-05).
Starting with that version, libnotify started injecting `sender-pid` if
not provided by the client. So our tests received a slightly different
DBus payload depending on what version of libnotify was installed,
causing our deep-equals tests to fail.

By always providing and testing the `sender-pid` hint, our behavior and
tests should be consistent across distros.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
trop[bot] 2024-09-25 14:02:07 -05:00 committed by GitHub
parent 6c1233a7d2
commit e99de2b5c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 0 deletions

View file

@ -76,6 +76,7 @@ if (is_linux) {
"notify_notification_set_timeout",
"notify_notification_set_urgency",
"notify_notification_set_hint_string",
"notify_notification_set_hint",
"notify_notification_show",
"notify_notification_close",
]

View file

@ -10,6 +10,7 @@
#include "base/files/file_enumerator.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/process/process_handle.h"
#include "base/strings/utf_string_conversions.h"
#include "shell/browser/notifications/notification_delegate.h"
#include "shell/browser/ui/gtk_util.h"
@ -145,6 +146,10 @@ void LibnotifyNotification::Show(const NotificationOptions& options) {
notification_, "desktop-entry", desktop_id.c_str());
}
libnotify_loader_.notify_notification_set_hint(
notification_, "sender-pid",
g_variant_new_int64(base::GetCurrentProcId()));
GError* error = nullptr;
libnotify_loader_.notify_notification_show(notification_, &error);
if (error) {

View file

@ -118,6 +118,7 @@ ifdescribe(!skip)('Notification module (dbus)', () => {
hints: {
append: 'true',
'desktop-entry': appName,
'sender-pid': process.pid,
urgency: 1
}
});