#[cfg(target_os = "macos")]
use core_animation::prelude::*;
#[cfg(target_os = "macos")]
use std::time::Duration;
#[cfg(target_os = "macos")]
fn main() {
println!("Testing window visibility behavior...\n");
println!("Test 1: Basic show/hide cycle");
{
let window = WindowBuilder::new()
.title("Visibility Test 1")
.size(200.0, 100.0)
.centered()
.background_color(Color::rgb(0.2, 0.4, 0.8))
.build();
assert!(
!window.is_visible(),
"FAIL: Window should not be visible before show()"
);
println!(" [PASS] Window is not visible before show()");
window.show();
assert!(
window.is_visible(),
"FAIL: Window should be visible after show()"
);
println!(" [PASS] Window is visible after show()");
window.hide();
assert!(
!window.is_visible(),
"FAIL: Window should not be visible after hide()"
);
println!(" [PASS] Window is not visible after hide()");
for i in 1..=3 {
window.show();
assert!(
window.is_visible(),
"FAIL: Window should be visible in cycle {}",
i
);
window.hide();
assert!(
!window.is_visible(),
"FAIL: Window should be hidden in cycle {}",
i
);
}
println!(" [PASS] Show/hide cycle works correctly (3 cycles)");
}
println!("\nTest 2: show_for() closes window after duration");
{
let window = WindowBuilder::new()
.title("Visibility Test 2")
.size(200.0, 100.0)
.centered()
.background_color(Color::rgb(0.8, 0.2, 0.4))
.build();
println!(" Showing window for 500ms...");
window.show_for(Duration::from_millis(500));
assert!(
!window.is_visible(),
"FAIL: Window should NOT be visible after show_for() returns"
);
println!(" [PASS] Window is NOT visible after show_for() returns");
}
println!("\nTest 3: Multiple show_for() calls");
for i in 1..=3 {
let window = WindowBuilder::new()
.title(format!("Flash {}", i))
.size(100.0, 100.0)
.centered()
.background_color(Color::rgb(0.2, 0.8, 0.2))
.build();
window.show_for(Duration::from_millis(200));
assert!(
!window.is_visible(),
"FAIL: Window {} should NOT be visible after show_for()",
i
);
}
println!(" [PASS] All 3 flash windows closed correctly");
println!("\n=== All tests passed! ===");
}
#[cfg(not(target_os = "macos"))]
fn main() {
eprintln!("This example only runs on macOS");
}