⎇ 48e4800f14c6af5cd26275fb570d11b93e279654
tests/generated/flex/wrapped_row_within_align_items_flex_end.rs
History
Who touched what
raw
Sort test fixtures and generated tests into folders (#514)
1#[test]
2fn wrapped_row_within_align_items_flex_end() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout};
5 let mut taffy = taffy::Taffy::new();
6 let node00 = taffy
7 .new_leaf(taffy::style::Style {
8 size: taffy::geometry::Size {
9 width: taffy::style::Dimension::Length(150f32),
10 height: taffy::style::Dimension::Length(80f32),
11 },
12 ..Default::default()
13 })
14 .unwrap();
15 let node01 = taffy
16 .new_leaf(taffy::style::Style {
17 size: taffy::geometry::Size {
18 width: taffy::style::Dimension::Length(80f32),
19 height: taffy::style::Dimension::Length(80f32),
20 },
21 ..Default::default()
22 })
23 .unwrap();
24 let node0 = taffy
25 .new_with_children(
26 taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() },
27 &[node00, node01],
28 )
29 .unwrap();
30 let node = taffy
31 .new_with_children(
32 taffy::style::Style {
33 flex_direction: taffy::style::FlexDirection::Column,
34 align_items: Some(taffy::style::AlignItems::FlexEnd),
35 size: taffy::geometry::Size {
36 width: taffy::style::Dimension::Length(200f32),
37 height: taffy::style::Dimension::Length(200f32),
38 },
39 ..Default::default()
40 },
41 &[node0],
42 )
43 .unwrap();
44 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
45 println!("\nComputed tree:");
46 taffy::util::print_tree(&taffy, node);
47 println!();
48 let Layout { size, location, .. } = taffy.layout(node).unwrap();
49 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width);
50 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height);
51 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
52 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
53 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
54 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
55 assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node0, 160f32, size.height);
56 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
57 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
58 let Layout { size, location, .. } = taffy.layout(node00).unwrap();
59 assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node00, 150f32, size.width);
60 assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node00, 80f32, size.height);
61 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
62 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
63 let Layout { size, location, .. } = taffy.layout(node01).unwrap();
64 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node01, 80f32, size.width);
65 assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node01, 80f32, size.height);
66 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x);
67 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node01, 80f32, location.y);
68}