#[test] fn android_news_feed() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); let node000000 = taffy .new_leaf(taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(120f32), height: taffy::style::Dimension::Length(120f32), }, ..Default::default() }) .unwrap(); let node00000 = taffy .new_with_children( taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 0f32, ..Default::default() }, &[node000000], ) .unwrap(); let node000010 = taffy .new_leaf(taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, ..Default::default() }) .unwrap(); let node000011 = taffy .new_leaf(taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, ..Default::default() }) .unwrap(); let node00001 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, margin: taffy::geometry::Rect { left: zero(), right: taffy::style::LengthPercentageAuto::Length(36f32), top: zero(), bottom: zero(), }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Length(36f32), right: taffy::style::LengthPercentage::Length(36f32), top: taffy::style::LengthPercentage::Length(21f32), bottom: taffy::style::LengthPercentage::Length(18f32), }, ..Default::default() }, &[node000010, node000011], ) .unwrap(); let node0000 = taffy .new_with_children( taffy::style::Style { align_items: Some(taffy::style::AlignItems::FlexStart), align_content: Some(taffy::style::AlignContent::Stretch), margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::Length(36f32), right: zero(), top: taffy::style::LengthPercentageAuto::Length(24f32), bottom: zero(), }, ..Default::default() }, &[node00000, node00001], ) .unwrap(); let node000 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, &[node0000], ) .unwrap(); let node001000 = taffy .new_leaf(taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(72f32), height: taffy::style::Dimension::Length(72f32), }, ..Default::default() }) .unwrap(); let node00100 = taffy .new_with_children( taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 0f32, ..Default::default() }, &[node001000], ) .unwrap(); let node001010 = taffy .new_leaf(taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, ..Default::default() }) .unwrap(); let node001011 = taffy .new_leaf(taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, ..Default::default() }) .unwrap(); let node00101 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 1f32, margin: taffy::geometry::Rect { left: zero(), right: taffy::style::LengthPercentageAuto::Length(36f32), top: zero(), bottom: zero(), }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Length(36f32), right: taffy::style::LengthPercentage::Length(36f32), top: taffy::style::LengthPercentage::Length(21f32), bottom: taffy::style::LengthPercentage::Length(18f32), }, ..Default::default() }, &[node001010, node001011], ) .unwrap(); let node0010 = taffy .new_with_children( taffy::style::Style { align_items: Some(taffy::style::AlignItems::FlexStart), align_content: Some(taffy::style::AlignContent::Stretch), margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::Length(174f32), right: zero(), top: taffy::style::LengthPercentageAuto::Length(24f32), bottom: zero(), }, ..Default::default() }, &[node00100, node00101], ) .unwrap(); let node001 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, &[node0010], ) .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, &[node000, node001], ) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_shrink: 0f32, ..Default::default() }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 0f32, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(1080f32), height: auto() }, ..Default::default() }, &[node0], ) .unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); let Layout { size, location, .. } = taffy.layout(node).unwrap(); assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node, 1080f32, size.width); assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); let Layout { size, location, .. } = taffy.layout(node0).unwrap(); assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node0, 1080f32, size.width); assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); let Layout { size, location, .. } = taffy.layout(node00).unwrap(); assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node00, 1080f32, size.width); assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node00, 240f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); let Layout { size, location, .. } = taffy.layout(node000).unwrap(); assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node000, 1080f32, size.width); assert_eq!(size.height, 144f32, "height of node {:?}. Expected {}. Actual {}", node000, 144f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); let Layout { size, location, .. } = taffy.layout(node0000).unwrap(); assert_eq!(size.width, 1044f32, "width of node {:?}. Expected {}. Actual {}", node0000, 1044f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0000, 120f32, size.height); assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node0000, 36f32, location.x); assert_eq!(location.y, 24f32, "y of node {:?}. Expected {}. Actual {}", node0000, 24f32, location.y); let Layout { size, location, .. } = taffy.layout(node00000).unwrap(); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node00000, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node00000, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00000, 0f32, location.y); let Layout { size, location, .. } = taffy.layout(node000000).unwrap(); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node000000, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node000000, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000000, 0f32, location.y); let Layout { size, location, .. } = taffy.layout(node00001).unwrap(); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node00001, 72f32, size.width); assert_eq!(size.height, 39f32, "height of node {:?}. Expected {}. Actual {}", node00001, 39f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node00001, 120f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00001, 0f32, location.y); let Layout { size, location, .. } = taffy.layout(node000010).unwrap(); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000010, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000010, 0f32, size.height); assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node000010, 36f32, location.x); assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node000010, 21f32, location.y); let Layout { size, location, .. } = taffy.layout(node000011).unwrap(); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000011, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000011, 0f32, size.height); assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node000011, 36f32, location.x); assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node000011, 21f32, location.y); let Layout { size, location, .. } = taffy.layout(node001).unwrap(); assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node001, 1080f32, size.width); assert_eq!(size.height, 96f32, "height of node {:?}. Expected {}. Actual {}", node001, 96f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node001, 0f32, location.x); assert_eq!(location.y, 144f32, "y of node {:?}. Expected {}. Actual {}", node001, 144f32, location.y); let Layout { size, location, .. } = taffy.layout(node0010).unwrap(); assert_eq!(size.width, 906f32, "width of node {:?}. Expected {}. Actual {}", node0010, 906f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0010, 72f32, size.height); assert_eq!(location.x, 174f32, "x of node {:?}. Expected {}. Actual {}", node0010, 174f32, location.x); assert_eq!(location.y, 24f32, "y of node {:?}. Expected {}. Actual {}", node0010, 24f32, location.y); let Layout { size, location, .. } = taffy.layout(node00100).unwrap(); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node00100, 72f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node00100, 72f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00100, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00100, 0f32, location.y); let Layout { size, location, .. } = taffy.layout(node001000).unwrap(); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node001000, 72f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node001000, 72f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node001000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node001000, 0f32, location.y); let Layout { size, location, .. } = taffy.layout(node00101).unwrap(); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node00101, 72f32, size.width); assert_eq!(size.height, 39f32, "height of node {:?}. Expected {}. Actual {}", node00101, 39f32, size.height); assert_eq!(location.x, 72f32, "x of node {:?}. Expected {}. Actual {}", node00101, 72f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00101, 0f32, location.y); let Layout { size, location, .. } = taffy.layout(node001010).unwrap(); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node001010, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node001010, 0f32, size.height); assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node001010, 36f32, location.x); assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node001010, 21f32, location.y); let Layout { size, location, .. } = taffy.layout(node001011).unwrap(); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node001011, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node001011, 0f32, size.height); assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node001011, 36f32, location.x); assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node001011, 21f32, location.y); }