2023-12-12 06:17:27 +08:00
|
|
|
use std::sync::{
|
|
|
|
atomic::{AtomicBool, Ordering},
|
|
|
|
Arc,
|
|
|
|
};
|
|
|
|
|
2024-03-27 08:12:13 +08:00
|
|
|
use zng::{image::Img, prelude::*, widget::parallel};
|
2023-12-09 03:58:36 +08:00
|
|
|
|
2023-12-13 10:48:37 +08:00
|
|
|
#[test]
|
2023-12-09 03:58:36 +08:00
|
|
|
fn error_view_recursion() {
|
2024-04-11 02:20:05 +08:00
|
|
|
let mut app = APP.defaults().run_headless(false);
|
2024-03-27 08:12:13 +08:00
|
|
|
zng_app::test_log();
|
2023-12-09 03:58:36 +08:00
|
|
|
|
2024-01-07 02:52:23 +08:00
|
|
|
let img = var(Img::dummy(Some("test error".to_txt()))).read_only();
|
2023-12-09 03:58:36 +08:00
|
|
|
|
2024-03-27 08:12:13 +08:00
|
|
|
zng::image::IMAGES.load_in_headless().set(true);
|
2023-12-09 03:58:36 +08:00
|
|
|
let ok = Arc::new(AtomicBool::new(false));
|
|
|
|
let window_id = app.open_window(async_clmv!(ok, {
|
|
|
|
Window! {
|
2023-12-12 06:17:27 +08:00
|
|
|
parallel = false;
|
2023-12-09 03:58:36 +08:00
|
|
|
child = Image! {
|
|
|
|
source = img.clone();
|
|
|
|
img_error_fn = wgt_fn!(ok, |_| {
|
|
|
|
ok.store(true, Ordering::Relaxed);
|
|
|
|
Image! {
|
|
|
|
source = img.clone();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
|
|
|
let _ = app.update(false);
|
|
|
|
app.close_window(window_id);
|
|
|
|
|
|
|
|
assert!(ok.load(Ordering::Relaxed));
|
2023-12-12 03:12:59 +08:00
|
|
|
}
|