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