audit combobox

This commit is contained in:
2026-11-08 11:00:39 +07:00
parent 21d32736a8
commit abb56567e4
7 changed files with 315 additions and 257 deletions
+22 -7
View File
@@ -38,8 +38,11 @@ impl Render for FieldHost {
}
}
/// A field page in a real window, with the url input focused.
fn field_host() -> (
/// A field page in a real window; the url input is focused unless
/// `focus` is false, which leaves the page truly idle.
fn field_host(
focus: bool,
) -> (
TestAppContext,
Entity<InputState>,
Rc<RefCell<usize>>,
@@ -64,8 +67,10 @@ fn field_host() -> (
});
let mut visual = VisualTestContext::from_window(window.into(), &cx);
visual.update(|window, cx| {
let focus = url.read(cx).focus_handle();
window.focus(&focus, cx);
if focus {
let focus = url.read(cx).focus_handle();
window.focus(&focus, cx);
}
window.draw(cx).clear(cx);
});
(cx, url, renders, visual)
@@ -94,17 +99,27 @@ fn type_and_time(visual: &mut VisualTestContext, text: &str) -> std::time::Durat
#[test]
fn an_idle_field_page_schedules_no_frames() {
let (_cx, _url, _renders, mut visual) = field_host();
let (_cx, _url, _renders, mut visual) = field_host(false);
let frames = visual.update(|window, cx| window.simulate_next_frame(cx));
assert_eq!(
frames, 0,
"an idle field page must not request animation frames"
"an idle unfocused field page must not request animation frames"
);
}
#[test]
fn a_focused_field_page_schedules_frames_for_its_blink() {
let (_cx, _url, _renders, mut visual) = field_host(true);
let frames = visual.update(|window, cx| window.simulate_next_frame(cx));
assert!(
frames > 0,
"the focused caret's blink needs frames to redraw at the blink cadence"
);
}
#[test]
fn field_typing_frame_cost() {
let (_cx, _url, _renders, mut visual) = field_host();
let (_cx, _url, _renders, mut visual) = field_host(true);
let elapsed = type_and_time(&mut visual, "dsdsadsadadadada");
assert!(
elapsed.as_millis() < 1000,