mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-17 07:35:00 +00:00
Frozen panes: test the scrolled freeze-handle drag and the frozen text's painted extent (#2544)
Review follow-up: a column-handle drop on the last frozen column while scrolled, which fails if freeze_boundary measures with x(c + 1), and a check that frozen A1's text lies inside its clip, not only that the clip is A1.
This commit is contained in:
1 parent
17f733a81e
commit
56f0679fed
2 files changed
+31
No files matched your search
@@ -82,3 +82,20 @@ fn last_frozen_column_ends_at_the_freeze_line_when_scrolled() {
|
||||
assert!(g.x(&sh, 2) < split.x && g.y(&sh, 2) < split.y, "C and row 3 are scrolled under the frozen panes");
|
||||
assert!(g.same_col_pane(0, 1) && g.same_col_pane(2, 9) && !g.same_col_pane(1, 2));
|
||||
}
|
||||
|
||||
/// Dropping the column handle on the left part of the last frozen column while scrolled freezes
|
||||
/// up to its left edge: the column's right edge is the freeze line, not the next column's
|
||||
/// scrolled position (#2544).
|
||||
#[test]
|
||||
fn dragging_the_column_handle_when_scrolled_measures_the_last_frozen_column() {
|
||||
let mut h = harness();
|
||||
h.state_mut().run("view.freezePanes", serde_json::json!({"cell": "C1"})).unwrap();
|
||||
h.state_mut().view_mut().unwrap().scroll = egui::vec2(300.0, 0.0);
|
||||
h.run_steps(2);
|
||||
let g = geo(&h);
|
||||
let sh = h.state().session.active().unwrap().wb.active().unwrap().clone();
|
||||
let (cols, _) = freeze_handles(&g);
|
||||
assert!(g.x(&sh, 2) < g.x(&sh, 1), "C is scrolled left of B");
|
||||
drag(&mut h, cols.center(), pos2(g.x(&sh, 1) + 10.0, g.cells.top() + 40.0));
|
||||
assert_eq!(freeze(&h), Some((0, 1)));
|
||||
}
|
||||
@@ -53,6 +53,18 @@ fn text_clips(h: &Harness, text: &str) -> Vec<Rect> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Painted extents of the text shapes whose text is `text`, cut to their clip rects.
|
||||
fn text_visible_rects(h: &Harness, text: &str) -> Vec<Rect> {
|
||||
h.output()
|
||||
.shapes
|
||||
.iter()
|
||||
.filter_map(|s| match &s.shape {
|
||||
Shape::Text(t) if t.galley.job.text == text => Some(t.visual_bounding_rect().intersect(s.clip_rect)),
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn cell_rect(h: &Harness, cell: &str) -> Rect {
|
||||
let app = h.state();
|
||||
let sheet = app.session.active().unwrap().wb.active().unwrap();
|
||||
@@ -408,6 +420,8 @@ fn frozen_column_text_keeps_its_cell_when_scrolled() {
|
||||
(clips[0].left() - a1.left()).abs() <= 0.5 && (clips[0].right() - a1.right()).abs() <= 0.5,
|
||||
"A1's text spans A1 at column {col}: {clips:?} vs {a1:?}"
|
||||
);
|
||||
let visible = text_visible_rects(&h, LEFT);
|
||||
assert!(visible.len() == 1 && visible[0].is_positive(), "A1's text shows inside its clip at column {col}: {visible:?}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user