"#
)
}
#[test]
fn margin_collapse_max_height() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_collapse_max_height_2() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_collapse_cross_flex() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_collapse_cross_flex_2() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_collapse_cross_flex_3() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_collapse_cross_flex_4() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_collapse_cross_flex_5() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_collapse_cross_flex_6() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_collapse_cross_flex_7() {
assert_xml!(
r#"
"#
)
}
//
//
#[test]
fn margin_collapse_between_sibling_and_empty_block_1() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_collapse_between_sibling_and_empty_block_2() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_collapse_between_sibling_and_empty_block_3() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_collapse_between_sibling_and_empty_block_4() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_collapse_between_parent_and_empty_block_1() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_collapse_between_parent_and_empty_block_2() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_collapse_between_parent_and_empty_block_3() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_auto() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_inline() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_inline_1() {
assert_xml!(
r#"
"#
)
}
#[test]
fn margin_inline_2() {
assert_xml!(
r#"
"#
)
}
use float_pigment_forest::{convert_node_ref_to_ptr, ChildOperation, Node, StyleSetter};
use float_pigment_layout::{DefLength, LayoutTreeNode, OptionNum, OptionSize, Size};
unsafe fn as_ref<'a>(node: *mut Node) -> &'a Node {
&*node
}
#[test]
pub fn margin_root() {
unsafe {
let container = as_ref(Node::new_ptr());
let root = as_ref(Node::new_ptr());
let child = as_ref(Node::new_ptr());
child.set_margin_top(DefLength::Points(Len::from_f32(10.)));
child.set_margin_bottom(DefLength::Points(Len::from_f32(10.)));
child.set_padding_top(DefLength::Points(Len::from_f32(10.)));
child.set_padding_bottom(DefLength::Points(Len::from_f32(10.)));
container.append_child(convert_node_ref_to_ptr(root));
root.append_child(convert_node_ref_to_ptr(child));
container.layout(
OptionSize::new(OptionNum::some(Len::from_f32(375.)), OptionNum::none()),
Size::new(Len::from_f32(0.), Len::from_f32(0.)),
);
assert_eq!(root.layout_position().top, 0.);
assert_eq!(child.layout_position().top, 0.);
assert_eq!(child.layout_position().height, 20.);
}
}
#[test]
pub fn margin_root_empty_block() {
unsafe {
let root = as_ref(Node::new_ptr());
root.set_margin_top(DefLength::Points(Len::from_f32(10.)));
root.set_margin_right(DefLength::Points(Len::from_f32(20.)));
root.set_margin_bottom(DefLength::Points(Len::from_f32(30.)));
root.set_margin_left(DefLength::Points(Len::from_f32(40.)));
root.layout(
OptionSize::new(OptionNum::some(Len::from_f32(375.)), OptionNum::none()),
Size::new(Len::from_f32(0.), Len::from_f32(0.)),
);
assert_eq!(root.layout_node().computed_style().margin.top, 10.);
assert_eq!(root.layout_node().computed_style().margin.right, 20.);
assert_eq!(root.layout_node().computed_style().margin.bottom, 30.);
assert_eq!(root.layout_node().computed_style().margin.left, 40.);
}
}
#[test]
pub fn margin_root_3() {
unsafe {
let root = as_ref(Node::new_ptr());
// root.set_margin(DefLength::Points(100.));
root.set_display(float_pigment_css::typing::Display::Inline);
let child = as_ref(Node::new_ptr());
child.set_height(DefLength::Points(Len::from_f32(100.)));
child.set_margin(DefLength::Points(Len::from_f32(100.)));
root.append_child(convert_node_ref_to_ptr(child));
root.layout(
OptionSize::new(OptionNum::some(Len::from_f32(375.)), OptionNum::none()),
Size::new(Len::from_f32(0.), Len::from_f32(0.)),
);
assert_eq!(root.layout_node().computed_style().margin.bottom, 100.);
assert_eq!(root.layout_position().height, 100.);
assert_eq!(child.layout_position().height, 100.);
}
}
#[test]
pub fn margin_root_4() {
unsafe {
let root = as_ref(Node::new_ptr());
let child = as_ref(Node::new_ptr());
child.set_display(float_pigment_css::typing::Display::Inline);
let child_child = as_ref(Node::new_ptr());
child_child.set_height(DefLength::Points(Len::from_f32(100.)));
child_child.set_margin(DefLength::Points(Len::from_f32(100.)));
root.append_child(convert_node_ref_to_ptr(child));
child.append_child(convert_node_ref_to_ptr(child_child));
root.layout(
OptionSize::new(OptionNum::some(Len::from_f32(375.)), OptionNum::none()),
Size::new(Len::from_f32(0.), Len::from_f32(0.)),
);
assert_eq!(root.layout_node().computed_style().margin.bottom, 100.);
assert_eq!(root.layout_position().height, 100.);
assert_eq!(child.layout_position().height, 100.);
assert_eq!(child_child.layout_position().height, 100.);
}
}