From d837c88855a4abfee7c21c5f7fd756ac100c5a7a Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Thu, 6 Nov 2025 13:46:28 +0800 Subject: [PATCH] winit-appkit: fix tests on systems without MonitorId(1) Use `CGMainDisplayID` instead of `1` to make tests pass on systems without `MonitorId(1)`. --- winit-appkit/src/monitor.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/winit-appkit/src/monitor.rs b/winit-appkit/src/monitor.rs index edec6868..d40b854e 100644 --- a/winit-appkit/src/monitor.rs +++ b/winit-appkit/src/monitor.rs @@ -352,8 +352,10 @@ mod tests { #[test] fn uuid_stable() { - let handle_a = MonitorHandle::new(1).unwrap(); - let handle_b = MonitorHandle::new(1).unwrap(); + let primary_id = CGMainDisplayID(); + + let handle_a = MonitorHandle::new(primary_id).unwrap(); + let handle_b = MonitorHandle::new(primary_id).unwrap(); assert_eq!(handle_a, handle_b); assert_eq!(handle_a.display_id(), handle_b.display_id()); assert_eq!(handle_a.uuid(), handle_b.uuid()); @@ -368,8 +370,10 @@ mod tests { /// Test the MonitorHandle::new fallback. #[test] fn monitorhandle_from_zero() { + let primary_id = CGMainDisplayID(); + let handle0 = MonitorHandle::new(0).unwrap(); - let handle1 = MonitorHandle::new(1).unwrap(); + let handle1 = MonitorHandle::new(primary_id).unwrap(); assert_eq!(handle0, handle1); assert_eq!(handle0.display_id(), handle1.display_id()); assert_eq!(handle0.uuid(), handle1.uuid());