forked from reya/gpui-native-kit
feat: add dropdown menu component
This commit is contained in:
@@ -142,12 +142,16 @@ fn pair_window() -> (TestAppContext, VisualTestContext, Changes, Changes) {
|
||||
fn choosing_an_option_reports_the_value_and_closes() {
|
||||
let (_cx, mut visual, changes) = select_window();
|
||||
|
||||
// The trigger opens the popup; the panel grabs focus, so the first option
|
||||
// is keyboard-highlighted and Enter activates it.
|
||||
// The trigger opens the popup; with no value yet nothing is armed, so
|
||||
// the first Enter does nothing and the next Down arms the first option.
|
||||
click(&mut visual, point(px(100.), px(31.)));
|
||||
draw(&mut visual);
|
||||
visual.simulate_keystrokes("enter");
|
||||
draw(&mut visual);
|
||||
assert_eq!(*changes.borrow(), Vec::<Option<Strategy>>::new());
|
||||
|
||||
visual.simulate_keystrokes("down enter");
|
||||
draw(&mut visual);
|
||||
assert_eq!(*changes.borrow(), vec![Some(Strategy::Curated)]);
|
||||
|
||||
// The popup closed with the choice, so another Enter reports nothing.
|
||||
@@ -155,7 +159,8 @@ fn choosing_an_option_reports_the_value_and_closes() {
|
||||
draw(&mut visual);
|
||||
assert_eq!(*changes.borrow(), vec![Some(Strategy::Curated)]);
|
||||
|
||||
// The trigger reopens; the second option is two Downs away.
|
||||
// The trigger reopens with the chosen value armed; the next option is
|
||||
// one Down away.
|
||||
click(&mut visual, point(px(100.), px(31.)));
|
||||
draw(&mut visual);
|
||||
visual.simulate_keystrokes("down");
|
||||
@@ -173,11 +178,12 @@ fn the_controlled_value_round_trips_through_the_owner() {
|
||||
|
||||
click(&mut visual, point(px(100.), px(31.)));
|
||||
draw(&mut visual);
|
||||
visual.simulate_keystrokes("down");
|
||||
visual.simulate_keystrokes("down down");
|
||||
visual.simulate_keystrokes("enter");
|
||||
draw(&mut visual);
|
||||
|
||||
// The harness stored the reported value, so the select now holds it.
|
||||
// The harness stored the reported value, so the select now holds it;
|
||||
// reopening arms it and Enter reports it straight back.
|
||||
click(&mut visual, point(px(100.), px(31.)));
|
||||
draw(&mut visual);
|
||||
visual.simulate_keystrokes("enter");
|
||||
@@ -195,7 +201,7 @@ fn two_selects_keep_their_popups_independent() {
|
||||
// Opening the second select never touches the first.
|
||||
click(&mut visual, point(px(100.), px(69.)));
|
||||
draw(&mut visual);
|
||||
visual.simulate_keystrokes("enter");
|
||||
visual.simulate_keystrokes("down enter");
|
||||
draw(&mut visual);
|
||||
|
||||
assert_eq!(*first_changes.borrow(), vec![]);
|
||||
@@ -232,7 +238,7 @@ fn a_click_on_another_control_dismisses_and_reaches_it() {
|
||||
// the second.
|
||||
click(&mut visual, point(px(300.), px(69.)));
|
||||
draw(&mut visual);
|
||||
visual.simulate_keystrokes("enter");
|
||||
visual.simulate_keystrokes("down enter");
|
||||
draw(&mut visual);
|
||||
|
||||
assert_eq!(*first_changes.borrow(), Vec::<Option<Strategy>>::new());
|
||||
|
||||
Reference in New Issue
Block a user