winit-appkit: fix tests on systems without MonitorId(1)

Use `CGMainDisplayID` instead of `1` to make tests pass on systems
without `MonitorId(1)`.
This commit is contained in:
ShikiSuen
2025-11-06 13:46:28 +08:00
committed by GitHub
parent 82eab465e0
commit d837c88855

View File

@@ -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());