⎇ d8c8bb472833ba92d694a9420e4c5bd8308e32e3
tests/generated/gap_row_gap_determines_parent_height.rs
Historia
Quién tocó qué
crudo
Fix/additional flex gap tests (#284)
1#[test]
2fn gap_row_gap_determines_parent_height() {
3 #[allow(unused_imports)]
4 use taffy::prelude::*;
5 let mut taffy = taffy::Taffy::new();
6 let node0 = taffy
7 .new_with_children(
8 taffy::style::Style {
9 size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() },
10 ..Default::default()
11 },
12 &[],
13 )
14 .unwrap();
15 let node1 = taffy
16 .new_with_children(
17 taffy::style::Style {
18 size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() },
19 ..Default::default()
20 },
21 &[],
22 )
23 .unwrap();
24 let node2 = taffy
25 .new_with_children(
26 taffy::style::Style {
27 size: taffy::geometry::Size { height: taffy::style::Dimension::Points(30f32), ..Size::auto() },
28 ..Default::default()
29 },
30 &[],
31 )
32 .unwrap();
33 let node = taffy
34 .new_with_children(
35 taffy::style::Style {
36 flex_direction: taffy::style::FlexDirection::Column,
37 gap: taffy::geometry::Size { height: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() },
38 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() },
39 ..Default::default()
40 },
41 &[node0, node1, node2],
42 )
43 .unwrap();
44 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
45 println!("\nComputed tree:");
46 taffy::debug::print_tree(&taffy, node);
47 println!();
48 assert_eq!(taffy.layout(node).unwrap().size.width, 100f32);
49 assert_eq!(taffy.layout(node).unwrap().size.height, 80f32);
50 assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
51 assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
52 assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32);
53 assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32);
54 assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
55 assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
56 assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32);
57 assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32);
58 assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32);
59 assert_eq!(taffy.layout(node1).unwrap().location.y, 20f32);
60 assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32);
61 assert_eq!(taffy.layout(node2).unwrap().size.height, 30f32);
62 assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32);
63 assert_eq!(taffy.layout(node2).unwrap().location.y, 50f32);
64}