⎇ 568f643327ec6b4879df0087def7f4e66b6acafb
tests/generated/gap_column_gap_flexible.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Rename `Points`/`points` to `Length`/`length` in many APIs (#459)
1#[test]
2fn gap_column_gap_flexible() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout};
5 let mut taffy = taffy::Taffy::new();
6 let node0 = taffy
7 .new_leaf(taffy::style::Style {
8 flex_grow: 1f32,
9 flex_shrink: 1f32,
10 flex_basis: taffy::style::Dimension::Percent(0f32),
11 ..Default::default()
12 })
13 .unwrap();
14 let node1 = taffy
15 .new_leaf(taffy::style::Style {
16 flex_grow: 1f32,
17 flex_shrink: 1f32,
18 flex_basis: taffy::style::Dimension::Percent(0f32),
19 ..Default::default()
20 })
21 .unwrap();
22 let node2 = taffy
23 .new_leaf(taffy::style::Style {
24 flex_grow: 1f32,
25 flex_shrink: 1f32,
26 flex_basis: taffy::style::Dimension::Percent(0f32),
27 ..Default::default()
28 })
29 .unwrap();
30 let node = taffy
31 .new_with_children(
32 taffy::style::Style {
33 gap: taffy::geometry::Size {
34 width: taffy::style::LengthPercentage::Length(10f32),
35 height: taffy::style::LengthPercentage::Length(20f32),
36 },
37 size: taffy::geometry::Size {
38 width: taffy::style::Dimension::Length(80f32),
39 height: taffy::style::Dimension::Length(100f32),
40 },
41 ..Default::default()
42 },
43 &[node0, node1, node2],
44 )
45 .unwrap();
46 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
47 println!("\nComputed tree:");
48 taffy::util::print_tree(&taffy, node);
49 println!();
50 let Layout { size, location, .. } = taffy.layout(node).unwrap();
51 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width);
52 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
53 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
54 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
55 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
56 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width);
57 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
58 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
59 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
60 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
61 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width);
62 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height);
63 assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x);
64 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
65 let Layout { size, location, .. } = taffy.layout(node2).unwrap();
66 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width);
67 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height);
68 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x);
69 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
70}