diff --git a/test_fixtures/overflow_scrollbars_take_up_space_both_axis.html b/test_fixtures/overflow_scrollbars_take_up_space_both_axis.html new file mode 100644 index 000000000..592724b8e --- /dev/null +++ b/test_fixtures/overflow_scrollbars_take_up_space_both_axis.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/overflow_scrollbars_take_up_space_cross_axis.html b/test_fixtures/overflow_scrollbars_take_up_space_cross_axis.html new file mode 100644 index 000000000..0f3901cbc --- /dev/null +++ b/test_fixtures/overflow_scrollbars_take_up_space_cross_axis.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/overflow_scrollbars_take_up_space_main_axis.html b/test_fixtures/overflow_scrollbars_take_up_space_main_axis.html new file mode 100644 index 000000000..bdb218068 --- /dev/null +++ b/test_fixtures/overflow_scrollbars_take_up_space_main_axis.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/tests/generated/mod.rs b/tests/generated/mod.rs index a76a86b8e..3f710a2e0 100644 --- a/tests/generated/mod.rs +++ b/tests/generated/mod.rs @@ -852,6 +852,9 @@ mod overflow_main_axis_shrink_auto; mod overflow_main_axis_shrink_hidden; mod overflow_main_axis_shrink_scroll; mod overflow_main_axis_shrink_visible; +mod overflow_scrollbars_take_up_space_both_axis; +mod overflow_scrollbars_take_up_space_cross_axis; +mod overflow_scrollbars_take_up_space_main_axis; mod padding_align_end_child; mod padding_border_overrides_max_size; mod padding_border_overrides_min_size; diff --git a/tests/generated/overflow_scrollbars_take_up_space_both_axis.rs b/tests/generated/overflow_scrollbars_take_up_space_both_axis.rs new file mode 100644 index 000000000..0d44b5f7c --- /dev/null +++ b/tests/generated/overflow_scrollbars_take_up_space_both_axis.rs @@ -0,0 +1,39 @@ +#[test] +fn overflow_scrollbars_take_up_space_both_axis() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15u8, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 50f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 50f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 35f32, size.width); + assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 35f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/overflow_scrollbars_take_up_space_cross_axis.rs b/tests/generated/overflow_scrollbars_take_up_space_cross_axis.rs new file mode 100644 index 000000000..e44063768 --- /dev/null +++ b/tests/generated/overflow_scrollbars_take_up_space_cross_axis.rs @@ -0,0 +1,39 @@ +#[test] +fn overflow_scrollbars_take_up_space_cross_axis() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Visible, + y: taffy::style::Overflow::Scroll, + }, + scrollbar_width: 15u8, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 50f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 50f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 35f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/overflow_scrollbars_take_up_space_main_axis.rs b/tests/generated/overflow_scrollbars_take_up_space_main_axis.rs new file mode 100644 index 000000000..dcc2e3fad --- /dev/null +++ b/tests/generated/overflow_scrollbars_take_up_space_main_axis.rs @@ -0,0 +1,39 @@ +#[test] +fn overflow_scrollbars_take_up_space_main_axis() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { + x: taffy::style::Overflow::Scroll, + y: taffy::style::Overflow::Visible, + }, + scrollbar_width: 15u8, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 50f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 50f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.width); + assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 35f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +}