diff --git a/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_border_top.html b/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_border_top.html new file mode 100644 index 000000000..d0a3cad71 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_border_top.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_x_hidden.html b/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_x_hidden.html new file mode 100644 index 000000000..314499b5e --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_x_hidden.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_x_scroll.html b/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_x_scroll.html new file mode 100644 index 000000000..7053141b0 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_x_scroll.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_y_hidden.html b/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_y_hidden.html new file mode 100644 index 000000000..221777274 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_y_hidden.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_y_scroll.html b/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_y_scroll.html new file mode 100644 index 000000000..e18793a81 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_y_scroll.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_padding_top.html b/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_padding_top.html new file mode 100644 index 000000000..fb8f5021c --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_first_child_collapse_blocked_by_padding_top.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_first_child_collapse_not_blocked_by_border_bottom.html b/test_fixtures/block_margin_y_fixed_size_first_child_collapse_not_blocked_by_border_bottom.html new file mode 100644 index 000000000..2ab650516 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_first_child_collapse_not_blocked_by_border_bottom.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_first_child_collapse_not_blocked_by_padding_bottom.html b/test_fixtures/block_margin_y_fixed_size_first_child_collapse_not_blocked_by_padding_bottom.html new file mode 100644 index 000000000..205bb62f7 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_first_child_collapse_not_blocked_by_padding_bottom.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_border_bottom.html b/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_border_bottom.html new file mode 100644 index 000000000..0f8b280ac --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_border_bottom.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_x_hidden.html b/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_x_hidden.html new file mode 100644 index 000000000..63e824aa1 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_x_hidden.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_x_scroll.html b/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_x_scroll.html new file mode 100644 index 000000000..62f5a4829 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_x_scroll.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_y_hidden.html b/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_y_hidden.html new file mode 100644 index 000000000..71287104f --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_y_hidden.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_y_scroll.html b/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_y_scroll.html new file mode 100644 index 000000000..784444f5c --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_y_scroll.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_padding_bottom.html b/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_padding_bottom.html new file mode 100644 index 000000000..2dd974c83 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_last_child_collapse_blocked_by_padding_bottom.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_last_child_collapse_not_blocked_by_border_top.html b/test_fixtures/block_margin_y_fixed_size_last_child_collapse_not_blocked_by_border_top.html new file mode 100644 index 000000000..f074fe9f6 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_last_child_collapse_not_blocked_by_border_top.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_last_child_collapse_not_blocked_by_padding_top.html b/test_fixtures/block_margin_y_fixed_size_last_child_collapse_not_blocked_by_padding_top.html new file mode 100644 index 000000000..80e2bdbff --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_last_child_collapse_not_blocked_by_padding_top.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_border_top.rs b/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_border_top.rs new file mode 100644 index 000000000..6d2928a48 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_border_top.rs @@ -0,0 +1,76 @@ +#[test] +fn block_margin_y_fixed_size_first_child_collapse_blocked_by_border_top() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, 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); +} diff --git a/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_x_hidden.rs b/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_x_hidden.rs new file mode 100644 index 000000000..54f7cae08 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_x_hidden.rs @@ -0,0 +1,81 @@ +#[test] +fn block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_x_hidden() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Visible, + }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); + assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, 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); +} diff --git a/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_x_scroll.rs b/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_x_scroll.rs new file mode 100644 index 000000000..deeffc39d --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_x_scroll.rs @@ -0,0 +1,81 @@ +#[test] +fn block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_x_scroll() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Visible, + }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node, 45f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); + assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, 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); +} diff --git a/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_y_hidden.rs b/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_y_hidden.rs new file mode 100644 index 000000000..a91e6eed7 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_y_hidden.rs @@ -0,0 +1,81 @@ +#[test] +fn block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_y_hidden() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); + assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, 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); +} diff --git a/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_y_scroll.rs b/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_y_scroll.rs new file mode 100644 index 000000000..8f1e22d0f --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_y_scroll.rs @@ -0,0 +1,81 @@ +#[test] +fn block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_y_scroll() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node00, 35f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); + assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); + let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node000, 35f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, 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); +} diff --git a/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_padding_top.rs b/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_padding_top.rs new file mode 100644 index 000000000..3a1eff4fc --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_first_child_collapse_blocked_by_padding_top.rs @@ -0,0 +1,82 @@ +#[test] +fn block_margin_y_fixed_size_first_child_collapse_blocked_by_padding_top() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + padding: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: zero(), + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 31f32, "height of node {:?}. Expected {}. Actual {}", node, 31f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 21f32, "height of node {:?}. Expected {}. Actual {}", node0, 21f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); + assert_eq!(location.y, 11f32, "y of node {:?}. Expected {}. Actual {}", node00, 11f32, location.y); + let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, 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); +} diff --git a/tests/generated/block_margin_y_fixed_size_first_child_collapse_not_blocked_by_border_bottom.rs b/tests/generated/block_margin_y_fixed_size_first_child_collapse_not_blocked_by_border_bottom.rs new file mode 100644 index 000000000..3e5729d5e --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_first_child_collapse_not_blocked_by_border_bottom.rs @@ -0,0 +1,76 @@ +#[test] +fn block_margin_y_fixed_size_first_child_collapse_not_blocked_by_border_bottom() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, 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); +} diff --git a/tests/generated/block_margin_y_fixed_size_first_child_collapse_not_blocked_by_padding_bottom.rs b/tests/generated/block_margin_y_fixed_size_first_child_collapse_not_blocked_by_padding_bottom.rs new file mode 100644 index 000000000..171069bea --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_first_child_collapse_not_blocked_by_padding_bottom.rs @@ -0,0 +1,82 @@ +#[test] +fn block_margin_y_fixed_size_first_child_collapse_not_blocked_by_padding_bottom() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + padding: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentage::Length(1f32), + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 21f32, "height of node {:?}. Expected {}. Actual {}", node, 21f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 11f32, "height of node {:?}. Expected {}. Actual {}", node0, 11f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); + let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, 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); +} diff --git a/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_border_bottom.rs b/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_border_bottom.rs new file mode 100644 index 000000000..1d8f41841 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_border_bottom.rs @@ -0,0 +1,76 @@ +#[test] +fn block_margin_y_fixed_size_last_child_collapse_blocked_by_border_bottom() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, 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); +} diff --git a/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_x_hidden.rs b/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_x_hidden.rs new file mode 100644 index 000000000..2c1fe0802 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_x_hidden.rs @@ -0,0 +1,81 @@ +#[test] +fn block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_x_hidden() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Hidden, + y: taffy::style::Overflow::Visible, + }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, 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); +} diff --git a/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_x_scroll.rs b/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_x_scroll.rs new file mode 100644 index 000000000..73aa64782 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_x_scroll.rs @@ -0,0 +1,81 @@ +#[test] +fn block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_x_scroll() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Visible, + }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node, 45f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, 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); +} diff --git a/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_y_hidden.rs b/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_y_hidden.rs new file mode 100644 index 000000000..e57c25832 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_y_hidden.rs @@ -0,0 +1,81 @@ +#[test] +fn block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_y_hidden() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Hidden, + }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, 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); +} diff --git a/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_y_scroll.rs b/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_y_scroll.rs new file mode 100644 index 000000000..f580f21f3 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_y_scroll.rs @@ -0,0 +1,81 @@ +#[test] +fn block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_y_scroll() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, 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, 35f32, "width of node {:?}. Expected {}. Actual {}", node00, 35f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, 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, 35f32, "width of node {:?}. Expected {}. Actual {}", node000, 35f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, 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); +} diff --git a/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_padding_bottom.rs b/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_padding_bottom.rs new file mode 100644 index 000000000..528b0529c --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_last_child_collapse_blocked_by_padding_bottom.rs @@ -0,0 +1,82 @@ +#[test] +fn block_margin_y_fixed_size_last_child_collapse_blocked_by_padding_bottom() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + padding: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentage::Length(1f32), + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 31f32, "height of node {:?}. Expected {}. Actual {}", node, 31f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 21f32, "height of node {:?}. Expected {}. Actual {}", node0, 21f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, 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); +} diff --git a/tests/generated/block_margin_y_fixed_size_last_child_collapse_not_blocked_by_border_top.rs b/tests/generated/block_margin_y_fixed_size_last_child_collapse_not_blocked_by_border_top.rs new file mode 100644 index 000000000..28f9fb729 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_last_child_collapse_not_blocked_by_border_top.rs @@ -0,0 +1,76 @@ +#[test] +fn block_margin_y_fixed_size_last_child_collapse_not_blocked_by_border_top() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, 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); +} diff --git a/tests/generated/block_margin_y_fixed_size_last_child_collapse_not_blocked_by_padding_top.rs b/tests/generated/block_margin_y_fixed_size_last_child_collapse_not_blocked_by_padding_top.rs new file mode 100644 index 000000000..a7f466107 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_last_child_collapse_not_blocked_by_padding_top.rs @@ -0,0 +1,82 @@ +#[test] +fn block_margin_y_fixed_size_last_child_collapse_not_blocked_by_padding_top() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + padding: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: zero(), + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 21f32, "height of node {:?}. Expected {}. Actual {}", node, 21f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 11f32, "height of node {:?}. Expected {}. Actual {}", node0, 11f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); + assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node00, 1f32, location.y); + let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, 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); +} diff --git a/tests/generated/mod.rs b/tests/generated/mod.rs index bcb64bd41..685125358 100644 --- a/tests/generated/mod.rs +++ b/tests/generated/mod.rs @@ -328,18 +328,34 @@ mod block_margin_y_fixed_size_collapse_through_negative; mod block_margin_y_fixed_size_collapse_through_positive; mod block_margin_y_fixed_size_collapse_through_positive_and_negative; mod block_margin_y_fixed_size_collapse_through_with_absolute_child; +mod block_margin_y_fixed_size_first_child_collapse_blocked_by_border_top; +mod block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_x_hidden; +mod block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_x_scroll; +mod block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_y_hidden; +mod block_margin_y_fixed_size_first_child_collapse_blocked_by_overflow_y_scroll; +mod block_margin_y_fixed_size_first_child_collapse_blocked_by_padding_top; mod block_margin_y_fixed_size_first_child_collapse_negative_equal; mod block_margin_y_fixed_size_first_child_collapse_negative_parent_larger; mod block_margin_y_fixed_size_first_child_collapse_negative_parent_smaller; +mod block_margin_y_fixed_size_first_child_collapse_not_blocked_by_border_bottom; +mod block_margin_y_fixed_size_first_child_collapse_not_blocked_by_padding_bottom; mod block_margin_y_fixed_size_first_child_collapse_positive_and_negative; mod block_margin_y_fixed_size_first_child_collapse_positive_equal; mod block_margin_y_fixed_size_first_child_collapse_positive_parent_larger; mod block_margin_y_fixed_size_first_child_collapse_positive_parent_smaller; mod block_margin_y_fixed_size_first_granchild_collapse_positive_and_negative; mod block_margin_y_fixed_size_first_granchild_collapse_positive_equal; +mod block_margin_y_fixed_size_last_child_collapse_blocked_by_border_bottom; +mod block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_x_hidden; +mod block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_x_scroll; +mod block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_y_hidden; +mod block_margin_y_fixed_size_last_child_collapse_blocked_by_overflow_y_scroll; +mod block_margin_y_fixed_size_last_child_collapse_blocked_by_padding_bottom; mod block_margin_y_fixed_size_last_child_collapse_negative_equal; mod block_margin_y_fixed_size_last_child_collapse_negative_parent_larger; mod block_margin_y_fixed_size_last_child_collapse_negative_parent_smaller; +mod block_margin_y_fixed_size_last_child_collapse_not_blocked_by_border_top; +mod block_margin_y_fixed_size_last_child_collapse_not_blocked_by_padding_top; mod block_margin_y_fixed_size_last_child_collapse_positive_and_negative; mod block_margin_y_fixed_size_last_child_collapse_positive_equal; mod block_margin_y_fixed_size_last_child_collapse_positive_parent_larger;