1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
use anyhow::Result;
use fission_core::ui::{Button, Grid, GridItem, Text, TextContent, TextInput, Widget};
use fission_core::{op::GridTrack, WidgetId};
use fission_test::TestHarness;
use fission_widgets::{HStack, VStack};
#[derive(Debug, Default, Clone)]
struct GlobalState {}
impl fission_core::action::GlobalState for GlobalState {}
#[derive(Clone)]
struct HeaderRepro;
impl From<HeaderRepro> for Widget {
fn from(_component: HeaderRepro) -> Self {
let (_ctx, _view) = fission_core::build::current::<GlobalState>();
Grid {
columns: vec![
GridTrack::Points(220.0),
GridTrack::Points(380.0),
GridTrack::Fr(1.0),
],
rows: vec![GridTrack::Fr(1.0)],
children: vec![
// Col 2 Content
GridItem::new(VStack {
spacing: Some(0.0),
children: vec![
// Header
HStack {
spacing: Some(8.0),
children: vec![
TextInput {
width: Some(200.0),
..Default::default()
}
.into(),
// Popover logic simulated
// Anchor button
Button {
id: Some(WidgetId::explicit("filter_btn")),
child: Some(
Text {
content: TextContent::Literal("Filter".into()),
..Default::default()
}
.into(),
),
..Default::default()
}
.into(),
],
}
.into(),
],
})
.cell(1, 2)
.into(),
],
..Default::default()
}
.into()
}
}
#[test]
fn test_inbox_header_layout_coords() -> Result<()> {
let mut h = TestHarness::new(GlobalState::default()).with_root_widget(HeaderRepro);
h.pump()?; // Build + Layout
let filter_btn_id: WidgetId = WidgetId::explicit("filter_btn").into();
if let Some(snapshot) = &h.last_snapshot {
if let Some(geom) = snapshot.get_node_geometry(filter_btn_id) {
println!("Filter Button Rect: {:?}", geom.rect);
// Expected: 220 (Col 1) + 200 (Input) + 8 (Gap) = 428?
// Gap spacing is accounted for in the row layout.
// If Input is 200.
// Button is at X=428?
// Let's assert it is reasonable.
assert!(
geom.rect.x() > 400.0 && geom.rect.x() < 500.0,
"Filter button X {} should be around 428",
geom.rect.x()
);
} else {
panic!("Filter button not found in layout snapshot");
}
} else {
panic!("No snapshot");
}
Ok(())
}