Add control height regression test
- Lock the rendered medium button to the 32px token height.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#![cfg(feature = "button")]
|
||||
|
||||
use gpui::{
|
||||
Context, IntoElement, ParentElement as _, Render, Styled as _, TestAppContext,
|
||||
VisualTestContext, Window, div, px, size,
|
||||
};
|
||||
use gpui_native_core::button::Button;
|
||||
use gpui_native_theme::Theme;
|
||||
|
||||
struct Harness;
|
||||
|
||||
impl Render for Harness {
|
||||
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
||||
div().size_full().child(
|
||||
Button::new("height-probe")
|
||||
.label("Probe")
|
||||
.debug_selector(|| "height-probe".to_string()),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn medium_button_renders_at_the_token_height(cx: &mut TestAppContext) {
|
||||
cx.update(Theme::init);
|
||||
let window = cx.open_window(size(px(400.), px(400.)), |_, _| Harness);
|
||||
let mut cx = VisualTestContext::from_window(window.into(), cx);
|
||||
cx.run_until_parked();
|
||||
|
||||
let bounds = cx.debug_bounds("height-probe").expect("button laid out");
|
||||
|
||||
assert_eq!(bounds.size.height, px(32.0));
|
||||
}
|
||||
Reference in New Issue
Block a user