⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/flex/measure_remeasure_child_after_growing.rs
History
Who touched what
raw
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn measure_remeasure_child_after_growing__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node0 = taffy
8 .new_leaf(taffy::style::Style {
9 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::from_length(50f32),
11 height: taffy::style::Dimension::from_length(50f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node1 = taffy
17 .new_leaf_with_context(
18 taffy::style::Style { ..Default::default() },
19 crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal),
20 )
21 .unwrap();
22 let node = taffy
23 .new_with_children(
24 taffy::style::Style {
25 align_items: Some(taffy::style::AlignItems::Start),
26 size: taffy::geometry::Size {
27 width: taffy::style::Dimension::from_length(100f32),
28 height: taffy::style::Dimension::AUTO,
29 },
30 ..Default::default()
31 },
32 &[node0, node1],
33 )
34 .unwrap();
35 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
36 println!("\nComputed tree:");
37 taffy.print_tree(node);
38 println!();
39 let layout = taffy.layout(node).unwrap();
40 let Layout { size, location, .. } = layout;
41 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
42 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height);
43 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
44 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
45 let layout = taffy.layout(node0).unwrap();
46 let Layout { size, location, .. } = layout;
47 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
48 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
49 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
50 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
51 let layout = taffy.layout(node1).unwrap();
52 let Layout { size, location, .. } = layout;
53 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width);
54 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height);
55 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
56 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
57}
58
59#[test]
60#[allow(non_snake_case)]
61fn measure_remeasure_child_after_growing__content_box() {
62 #[allow(unused_imports)]
63 use taffy::{prelude::*, Layout};
64 let mut taffy = crate::new_test_tree();
65 let node0 = taffy
66 .new_leaf(taffy::style::Style {
67 box_sizing: taffy::style::BoxSizing::ContentBox,
68 size: taffy::geometry::Size {
69 width: taffy::style::Dimension::from_length(50f32),
70 height: taffy::style::Dimension::from_length(50f32),
71 },
72 ..Default::default()
73 })
74 .unwrap();
75 let node1 = taffy
76 .new_leaf_with_context(
77 taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() },
78 crate::TestNodeContext::ahem_text("HH", crate::WritingMode::Horizontal),
79 )
80 .unwrap();
81 let node = taffy
82 .new_with_children(
83 taffy::style::Style {
84 box_sizing: taffy::style::BoxSizing::ContentBox,
85 align_items: Some(taffy::style::AlignItems::Start),
86 size: taffy::geometry::Size {
87 width: taffy::style::Dimension::from_length(100f32),
88 height: taffy::style::Dimension::AUTO,
89 },
90 ..Default::default()
91 },
92 &[node0, node1],
93 )
94 .unwrap();
95 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
96 println!("\nComputed tree:");
97 taffy.print_tree(node);
98 println!();
99 let layout = taffy.layout(node).unwrap();
100 let Layout { size, location, .. } = layout;
101 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
102 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height);
103 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
104 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
105 let layout = taffy.layout(node0).unwrap();
106 let Layout { size, location, .. } = layout;
107 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
108 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
109 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
110 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
111 let layout = taffy.layout(node1).unwrap();
112 let Layout { size, location, .. } = layout;
113 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width);
114 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height);
115 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
116 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
117}