From 9818a1b8856af43a9cd7591be0388dcbae12e6ea Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 28 Oct 2026 19:33:26 -0700 Subject: [PATCH] feat(e2e): add a probe of the wallpaper of the Windows guest --- e2e/platforms/qemu_windows/w1_wallpaper.py | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 e2e/platforms/qemu_windows/w1_wallpaper.py diff --git a/e2e/platforms/qemu_windows/w1_wallpaper.py b/e2e/platforms/qemu_windows/w1_wallpaper.py new file mode 100644 index 00000000..36154937 --- /dev/null +++ b/e2e/platforms/qemu_windows/w1_wallpaper.py @@ -0,0 +1,55 @@ +"""W1: can the guest's wallpaper be read and set through IDesktopWallpaper? + +usage: python -m platforms.qemu_windows.w1_wallpaper GOLDEN OUT STATE + +Puts a PNG in a folder with a space in its name, prints the wallpaper of the +first display, sets it to the PNG, prints it again and, with a second display +plugged in, does the same for that one. A probe: it prints what it saw. +""" + +import struct +import sys +import time +import zlib +from pathlib import Path + +from .guest import Guest +from .windows_platform import WindowsPlatform + + +def png(width: int, height: int, rgb: tuple[int, int, int]) -> bytes: + row = b"\x00" + bytes(rgb) * width + + def chunk(kind: bytes, data: bytes) -> bytes: + body = kind + data + return struct.pack(">I", len(data)) + body + struct.pack( + ">I", zlib.crc32(body)) + + return (b"\x89PNG\r\n\x1a\n" + + chunk(b"IHDR", struct.pack(">IIBBBBB", width, height, 8, 2, 0, 0, 0)) + + chunk(b"IDAT", zlib.compress(row * height)) + + chunk(b"IEND", b"")) + + +def main(argv: list[str]) -> int: + golden, out = Path(argv[0]), Path(argv[1]) + state = Path(argv[2]) if len(argv) > 2 else None + out.mkdir(parents=True, exist_ok=True) + with Guest(golden, out / "guest", state=state) as guest: + platform = WindowsPlatform(guest.qmp, guest.agent, out) + path = platform.temp_path("wallpapers\\my pictures\\cool.png") + platform.put_file(path, png(64, 64, (200, 60, 40))) + print(f"PASTE put {path}") + print(f"PASTE display 0 before: {platform.wallpaper(0)!r}") + platform.set_wallpaper(path, 0) + print(f"PASTE display 0 after: {platform.wallpaper(0)!r}") + platform.add_display() + time.sleep(5) + print(f"PASTE display 1 before: {platform.wallpaper(1)!r}") + platform.set_wallpaper(path, 1) + print(f"PASTE display 1 after: {platform.wallpaper(1)!r}") + return 0 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:]))