init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
70
Telegram/ThirdParty/xdg-desktop-portal/tests/templates/wallpaper.py
vendored
Normal file
70
Telegram/ThirdParty/xdg-desktop-portal/tests/templates/wallpaper.py
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
#
|
||||
# This file is formatted with Python Black
|
||||
# mypy: disable-error-code="misc"
|
||||
|
||||
from tests.templates import Response, init_logger, ImplRequest
|
||||
|
||||
import dbus
|
||||
import dbus.service
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
BUS_NAME = "org.freedesktop.impl.portal.Test"
|
||||
MAIN_OBJ = "/org/freedesktop/portal/desktop"
|
||||
SYSTEM_BUS = False
|
||||
MAIN_IFACE = "org.freedesktop.impl.portal.Wallpaper"
|
||||
|
||||
|
||||
logger = init_logger(__name__)
|
||||
|
||||
|
||||
@dataclass
|
||||
class WallpaperParameters:
|
||||
delay: int
|
||||
response: int
|
||||
expect_close: bool
|
||||
|
||||
|
||||
def load(mock, parameters={}):
|
||||
logger.debug(f"Loading parameters: {parameters}")
|
||||
|
||||
assert not hasattr(mock, "wallpaper_params")
|
||||
mock.wallpaper_params = WallpaperParameters(
|
||||
delay=parameters.get("delay", 200),
|
||||
response=parameters.get("response", 0),
|
||||
expect_close=parameters.get("expect-close", False),
|
||||
)
|
||||
|
||||
|
||||
@dbus.service.method(
|
||||
MAIN_IFACE,
|
||||
in_signature="osssa{sv}",
|
||||
out_signature="u",
|
||||
async_callbacks=("cb_success", "cb_error"),
|
||||
)
|
||||
def SetWallpaperURI(
|
||||
self, handle, app_id, parent_window, uri, options, cb_success, cb_error
|
||||
):
|
||||
logger.debug(
|
||||
f"SetWallpaperURI({handle}, {app_id}, {parent_window}, {uri}, {options})"
|
||||
)
|
||||
params = self.wallpaper_params
|
||||
|
||||
# This is irregular: the backend doesn't return the results vardict
|
||||
def internal_cb_success(response, results):
|
||||
cb_success(response)
|
||||
|
||||
request = ImplRequest(
|
||||
self,
|
||||
BUS_NAME,
|
||||
handle,
|
||||
logger,
|
||||
internal_cb_success,
|
||||
cb_error,
|
||||
)
|
||||
|
||||
if params.expect_close:
|
||||
request.wait_for_close()
|
||||
else:
|
||||
request.respond(Response(params.response, {}), delay=params.delay)
|
||||
Reference in New Issue
Block a user