audit combobox
This commit is contained in:
@@ -2,8 +2,8 @@ use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use gpui::{
|
||||
AppContext as _, Context, Entity, IntoElement, ParentElement as _, Render, SharedString,
|
||||
Styled as _, TestAppContext, VisualTestContext, Window, div,
|
||||
AppContext as _, Context, Entity, IntoElement, MouseButton, ParentElement as _, Render,
|
||||
SharedString, Styled as _, TestAppContext, VisualTestContext, Window, div, point, px,
|
||||
};
|
||||
use gpui_native_core::combobox::{Combobox, ComboboxOption, ComboboxState};
|
||||
use gpui_native_core::init;
|
||||
@@ -99,6 +99,31 @@ fn draw(visual: &mut VisualTestContext) {
|
||||
});
|
||||
}
|
||||
|
||||
fn click(visual: &mut VisualTestContext, position: gpui::Point<gpui::Pixels>) {
|
||||
visual.simulate_mouse_down(position, MouseButton::Left, gpui::Modifiers::default());
|
||||
visual.simulate_mouse_up(position, MouseButton::Left, gpui::Modifiers::default());
|
||||
}
|
||||
|
||||
/// Clicking into a valueless combobox field opens the options right away:
|
||||
/// no keystroke is needed to see the choices.
|
||||
#[test]
|
||||
fn clicking_the_empty_field_opens_the_popup() {
|
||||
let mut host = combo_host(false, false);
|
||||
|
||||
// Inside the field, which sits at the top of the padded host.
|
||||
click(&mut host.visual, point(px(100.), px(27.)));
|
||||
draw(&mut host.visual);
|
||||
|
||||
assert!(
|
||||
host.state.read_with(&host.cx, |state, _| state.is_open()),
|
||||
"clicking the empty field should show the options"
|
||||
);
|
||||
assert!(
|
||||
host.visual.debug_bounds("test-combo-panel").is_some(),
|
||||
"the options panel should be rendered"
|
||||
);
|
||||
}
|
||||
|
||||
fn focus(host: &mut ComboHost) {
|
||||
let state = host.state.clone();
|
||||
host.visual.update(|window, cx| {
|
||||
|
||||
Reference in New Issue
Block a user