mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-24 10:16:59 -06:00
Test the app bar scroll bar at 115% scale in the test window (#481)
This commit is contained in:
@@ -843,6 +843,20 @@ mod tests {
|
||||
assert_eq!(after, before);
|
||||
}
|
||||
|
||||
/// At 115% the app bar fits a wide window exactly: it must not scroll sideways by a rounding error.
|
||||
#[test]
|
||||
fn the_app_bar_does_not_scroll_at_115_percent() {
|
||||
let w = 1400.0;
|
||||
let mut h = test_window::open_scaled(app(), vec2(w, 900.0), 1.15);
|
||||
assert_eq!(h.ctx.pixels_per_point(), 1.15);
|
||||
let before = [rect(&h, "Help"), rect(&h, "Share")];
|
||||
assert!(before.iter().all(|r| r.max.x <= w), "{before:?}");
|
||||
wheel(&mut h, before[0].center(), vec2(0.0, -3000.0));
|
||||
wheel(&mut h, before[0].center(), vec2(-3000.0, 0.0));
|
||||
let after = [rect(&h, "Help"), rect(&h, "Share")];
|
||||
assert_eq!(after, before, "the app bar scrolled sideways although everything fits");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_scrolled_bar_keeps_its_captions_on_one_line() {
|
||||
let mut app = app();
|
||||
|
||||
@@ -1330,11 +1330,16 @@ pub(crate) mod test_window {
|
||||
}
|
||||
|
||||
/// The window at `size` with a new document open.
|
||||
pub fn open(mut app: crate::DesignApp, size: egui::Vec2) -> Harness<'static, Window> {
|
||||
pub fn open(app: crate::DesignApp, size: egui::Vec2) -> Harness<'static, Window> {
|
||||
open_scaled(app, size, 1.0)
|
||||
}
|
||||
|
||||
/// The window at a size in points and a scale, with a new document open.
|
||||
pub fn open_scaled(mut app: crate::DesignApp, size: egui::Vec2, pixels_per_point: f32) -> Harness<'static, Window> {
|
||||
if app.session.active().is_none() {
|
||||
app.run("file.new", serde_json::json!({})).unwrap();
|
||||
}
|
||||
let mut h = Harness::builder().with_size(size).with_max_steps(1000).build_ui_state(
|
||||
let mut h = Harness::builder().with_size(size).with_pixels_per_point(pixels_per_point).with_max_steps(1000).build_ui_state(
|
||||
|ui, w: &mut Window| {
|
||||
// The builder runs a frame before the texture size can be raised: skip it.
|
||||
if !w.ready {
|
||||
|
||||
Reference in New Issue
Block a user