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
+27 -24
View File
@@ -269,42 +269,45 @@ fn read_only_refuses_edits_but_keeps_selection_and_copy() {
assert_eq!(clipboard, "lo");
// The caret is suppressed entirely while read-only.
let caret = cx.update(|cx| state.update(cx, |state, cx| state.caret_visible(true, cx)));
let caret = cx.update(|cx| state.update(cx, |state, _| state.caret_visible(true)));
assert!(!caret);
}
#[test]
fn caret_blinks_while_focused_and_holds_solid_while_typing() {
fn the_caret_visibility_is_pure_time_math_against_the_epoch() {
let (cx, state, mut visual) = input_window("", false);
focus(&mut visual, &state);
visual.update(|window, cx| {
window.draw(cx).clear(cx);
});
visual.run_until_parked();
let caret = || cx.update(|cx| state.update(cx, |state, _| state.caret_visible(true)));
let caret = || cx.update(|cx| state.update(cx, |state, cx| state.caret_visible(true, cx)));
// The caret shows on focus, hides after one interval, and reappears
// after another.
assert!(caret());
cx.executor().advance_clock(Duration::from_millis(500));
visual.run_until_parked();
assert!(!caret());
cx.executor().advance_clock(Duration::from_millis(500));
visual.run_until_parked();
// Fresh focus starts a new epoch: the caret shows solid — the elapsed
// time since the epoch began is microseconds, far under one interval.
assert!(caret());
// Typing holds the caret solid and restarts the cycle.
// Typing restarts the epoch, so the caret stays solid through edits.
visual.simulate_keystrokes("a");
assert!(caret());
cx.executor().advance_clock(Duration::from_millis(500));
visual.run_until_parked();
assert!(!caret());
// An unfocused field reports no caret.
let caret_unfocused =
cx.update(|cx| state.update(cx, |state, cx| state.caret_visible(false, cx)));
assert!(!caret_unfocused);
// The blink cadence itself: hidden in the second half of the cycle.
let hidden = cx.update(|cx| {
state.update(cx, |state, _| {
state.caret_blink_visible_at(true, Duration::from_millis(700))
})
});
assert!(!hidden);
let visible = cx.update(|cx| {
state.update(cx, |state, _| {
state.caret_blink_visible_at(true, Duration::from_millis(300))
})
});
assert!(visible);
// An unfocused field reports no caret, at any point in the cycle.
let unfocused = cx.update(|cx| {
state.update(cx, |state, _| {
state.caret_blink_visible_at(false, Duration::from_millis(100))
})
});
assert!(!unfocused);
}
#[test]