⎇ 568f643327ec6b4879df0087def7f4e66b6acafb
tests/generated/flex_row_relative_all_sides.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Rename `Points`/`points` to `Length`/`length` in many APIs (#459)
1#[test]
2fn flex_row_relative_all_sides() {
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 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() },
9 inset: taffy::geometry::Rect {
10 left: taffy::style::LengthPercentageAuto::Length(10f32),
11 right: taffy::style::LengthPercentageAuto::Length(10f32),
12 top: taffy::style::LengthPercentageAuto::Length(10f32),
13 bottom: taffy::style::LengthPercentageAuto::Length(10f32),
14 },
15 ..Default::default()
16 })
17 .unwrap();
18 let node = taffy
19 .new_with_children(
20 taffy::style::Style {
21 size: taffy::geometry::Size {
22 width: taffy::style::Dimension::Length(100f32),
23 height: taffy::style::Dimension::Length(100f32),
24 },
25 ..Default::default()
26 },
27 &[node0],
28 )
29 .unwrap();
30 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
31 println!("\nComputed tree:");
32 taffy::util::print_tree(&taffy, node);
33 println!();
34 let Layout { size, location, .. } = taffy.layout(node).unwrap();
35 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
36 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
37 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
38 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
39 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
40 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
41 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
42 assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x);
43 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y);
44}