chore: audit all components (#2)
Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
@@ -67,25 +67,45 @@ fn click(visual: &mut VisualTestContext, position: gpui::Point<gpui::Pixels>) {
|
||||
visual.simulate_mouse_up(position, MouseButton::Left, gpui::Modifiers::default());
|
||||
}
|
||||
|
||||
/// The trigger band is `16..46`; the panel hangs 4 px below it with a 4 px
|
||||
/// inner padding, so the three rows ride `~58..90`, `~90..122`, `~122..154`.
|
||||
/// Every option must answer a pointer press — a popup that clips its last
|
||||
/// item never does.
|
||||
/// The three option rows must answer a pointer press wherever they were laid
|
||||
/// out — a popup that clips its last item never does. Row positions come from
|
||||
/// the rendered bounds, so the stated menu row metric can change freely.
|
||||
#[test]
|
||||
fn every_option_row_answers_the_pointer() {
|
||||
let (_cx, mut visual, changes) = level_window();
|
||||
|
||||
let expected = [
|
||||
(px(74.), Level::Low),
|
||||
(px(106.), Level::Mid),
|
||||
(px(138.), Level::High),
|
||||
];
|
||||
for (y, value) in expected {
|
||||
// Open once to measure where the rows were actually drawn.
|
||||
click(&mut visual, point(px(100.), px(31.)));
|
||||
visual.update(|window, cx| {
|
||||
window.draw(cx).clear(cx);
|
||||
});
|
||||
let centers: Vec<gpui::Point<gpui::Pixels>> = (0..3)
|
||||
.map(|index| {
|
||||
let selector: &'static str = Box::leak(format!("menu-item-{index}").into_boxed_str());
|
||||
let row = visual
|
||||
.debug_bounds(selector)
|
||||
.unwrap_or_else(|| panic!("row {index} should have been laid out"));
|
||||
point(
|
||||
row.left() + row.size.width / 2.0,
|
||||
row.top() + row.size.height / 2.0,
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Close again; each iteration below opens the popup fresh.
|
||||
click(&mut visual, point(px(100.), px(31.)));
|
||||
visual.update(|window, cx| {
|
||||
window.draw(cx).clear(cx);
|
||||
});
|
||||
|
||||
let expected = [(Level::Low, 0), (Level::Mid, 1), (Level::High, 2)];
|
||||
for (value, index) in expected {
|
||||
// Choosing the previous row closed the popup; reopen it.
|
||||
click(&mut visual, point(px(100.), px(31.)));
|
||||
visual.update(|window, cx| {
|
||||
window.draw(cx).clear(cx);
|
||||
});
|
||||
click(&mut visual, point(px(100.), y));
|
||||
click(&mut visual, centers[index]);
|
||||
visual.update(|window, cx| {
|
||||
window.draw(cx).clear(cx);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user