summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-03-26 17:26:54 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-03-27 15:30:57 +0100
commit1dcd0d54831cf2eccd030de50509bbaa5a63954b (patch)
tree55501bc8c7498ca7a5a70fe362a90be96822d5ef /tests
parent591f6ceffdc6724e9f8fc9f514485349c5ee2e45 (diff)
downloadqutebrowser-1dcd0d54831cf2eccd030de50509bbaa5a63954b.tar.gz
qutebrowser-1dcd0d54831cf2eccd030de50509bbaa5a63954b.zip
notifications: Implement closing via web
Diffstat (limited to 'tests')
-rw-r--r--tests/end2end/data/javascript/notifications.html10
-rw-r--r--tests/end2end/features/notifications.feature6
-rw-r--r--tests/end2end/features/test_notifications_bdd.py6
-rw-r--r--tests/end2end/fixtures/notificationserver.py9
4 files changed, 31 insertions, 0 deletions
diff --git a/tests/end2end/data/javascript/notifications.html b/tests/end2end/data/javascript/notifications.html
index b93efdeaa..719d9e23e 100644
--- a/tests/end2end/data/javascript/notifications.html
+++ b/tests/end2end/data/javascript/notifications.html
@@ -64,6 +64,15 @@
});
}
+ function show_closing_notification() {
+ get_notification_permission(() => {
+ let notification = new Notification("closing notification");
+ notification.onclose = function() { console.log("notification closed"); };
+ notification.onshow = function() { console.log("notification shown"); };
+ setTimeout(() => notification.close(), 100);
+ });
+ }
+
function show_image_notification(title, filename) {
get_notification_permission(() => {
let notification = new Notification(title, { icon: `img/${filename}` });
@@ -80,6 +89,7 @@
<input type="button" onclick="show_notification()" value="Show notification" id="show-button">
<input type="button" onclick="show_symbol_notification()" value="Show notification with symbols" id="show-symbols-button">
<input type="button" onclick="show_replacing_notifications()" value="Show replacing notifications" id="show-replacing-button">
+ <input type="button" onclick="show_closing_notification()" value="Show and close notification" id="show-closing-button">
</div>
<div>
<input type="button" onclick="show_image_notification('RGBA', 'rgba.png')" value="Show image notification" id="show-image-button">
diff --git a/tests/end2end/features/notifications.feature b/tests/end2end/features/notifications.feature
index 6e4e7bab9..21ba110d4 100644
--- a/tests/end2end/features/notifications.feature
+++ b/tests/end2end/features/notifications.feature
@@ -52,6 +52,12 @@ Feature: Notifications
And notification 1 should have title "Padded"
And notification 1 should have image dimensions 46x46
+ Scenario: Closing notification via web
+ When I run :click-element id show-closing-button
+ Then the javascript message "notification shown" should be logged
+ And the javascript message "notification closed" should be logged
+ And notification 1 should be closed via web
+
# As a WORKAROUND for https://www.riverbankcomputing.com/pipermail/pyqt/2020-May/042918.html
# and other issues, those can only run with PyQtWebEngine >= 5.15.0
#
diff --git a/tests/end2end/features/test_notifications_bdd.py b/tests/end2end/features/test_notifications_bdd.py
index 6a5bd78a6..53e63180f 100644
--- a/tests/end2end/features/test_notifications_bdd.py
+++ b/tests/end2end/features/test_notifications_bdd.py
@@ -87,6 +87,12 @@ def notification_image_dimensions(notification_server, id_, width, height):
assert (msg.img_width, msg.img_height) == (width, height)
+@bdd.then(bdd.parsers.cfparse('notification {id_:d} should be closed via web'))
+def notification_closed(notification_server, id_):
+ msg = notification_server.messages[id_]
+ assert msg.closed_via_web
+
+
@bdd.when(bdd.parsers.cfparse('I close the notification with id {id_:d}'))
def close_notification(notification_server, id_):
notification_server.close(id_)
diff --git a/tests/end2end/fixtures/notificationserver.py b/tests/end2end/fixtures/notificationserver.py
index ee12dcba1..ded74e28f 100644
--- a/tests/end2end/fixtures/notificationserver.py
+++ b/tests/end2end/fixtures/notificationserver.py
@@ -39,6 +39,7 @@ class NotificationProperties:
replaces_id: int
img_width: int
img_height: int
+ closed_via_web: bool = False
def _as_uint32(x: int) -> QVariant:
@@ -203,6 +204,14 @@ class TestNotificationServer(QObject):
capabilities.append("body-markup")
return capabilities
+ @pyqtSlot(QDBusMessage)
+ def CloseNotification(self, dbus_message: QDBusMessage) -> None:
+ assert dbus_message.signature() == 'u'
+ assert dbus_message.type() == QDBusMessage.MethodCallMessage
+
+ message_id = dbus_message.arguments()[0]
+ self.messages[message_id].closed_via_web = True
+
@pytest.fixture
def notification_server(qapp):