use crate::*;
#[test]
fn grid_with_column_gap() {
assert_xml!(
r#"
<div style="display: grid; width: 320px; grid-template-columns: 100px 100px 100px; column-gap: 10px;">
<div style="height: 50px;" expect_left="0" expect_width="100"></div>
<div style="height: 50px;" expect_left="110" expect_width="100"></div>
<div style="height: 50px;" expect_left="220" expect_width="100"></div>
</div>
"#,
true
)
}
#[test]
fn grid_with_row_gap() {
assert_xml!(
r#"
<div style="display: grid; grid-template-columns: 100px; grid-template-rows: 50px 50px; row-gap: 20px;" expect_height="120">
<div expect_top="0" expect_height="50"></div>
<div expect_top="70" expect_height="50"></div>
</div>
"#,
true
)
}
#[test]
fn grid_with_gap() {
assert_xml!(
r#"
<div style="display: grid; width: 230px; grid-template-columns: 100px 100px; grid-template-rows: 50px 50px; gap: 10px 30px;" expect_height="110">
<div expect_left="0" expect_top="0" expect_width="100" expect_height="50"></div>
<div expect_left="130" expect_top="0" expect_width="100" expect_height="50"></div>
<div expect_left="0" expect_top="60" expect_width="100" expect_height="50"></div>
<div expect_left="130" expect_top="60" expect_width="100" expect_height="50"></div>
</div>
"#,
true
)
}
#[test]
fn grid_with_gap_single_value() {
assert_xml!(
r#"
<div style="display: grid; width: 220px; grid-template-columns: 100px 100px; grid-template-rows: 50px 50px; gap: 20px;" expect_height="120">
<div expect_left="0" expect_top="0" expect_width="100" expect_height="50"></div>
<div expect_left="120" expect_top="0" expect_width="100" expect_height="50"></div>
<div expect_left="0" expect_top="70" expect_width="100" expect_height="50"></div>
<div expect_left="120" expect_top="70" expect_width="100" expect_height="50"></div>
</div>
"#,
true
)
}
#[test]
fn grid_single_column_with_gap() {
assert_xml!(
r#"
<div style="display: grid; width: 100px; grid-template-columns: 100px; grid-template-rows: 50px 50px; column-gap: 20px; row-gap: 10px;" expect_height="110" expect_width="100">
<div expect_left="0" expect_top="0" expect_width="100" expect_height="50"></div>
<div expect_left="0" expect_top="60" expect_width="100" expect_height="50"></div>
</div>
"#,
true
)
}
#[test]
fn grid_single_row_with_gap() {
assert_xml!(
r#"
<div style="display: grid; width: 230px; grid-template-columns: 100px 100px; grid-template-rows: 50px; row-gap: 20px; column-gap: 30px;" expect_height="50">
<div expect_left="0" expect_top="0" expect_width="100" expect_height="50"></div>
<div expect_left="130" expect_top="0" expect_width="100" expect_height="50"></div>
</div>
"#,
true
)
}
#[test]
fn grid_3x3_with_gap() {
assert_xml!(
r#"
<div style="display: grid; width: 340px; grid-template-columns: 100px 100px 100px; grid-template-rows: 50px 50px 50px; gap: 10px 20px;" expect_height="170">
<div expect_left="0" expect_top="0" expect_width="100" expect_height="50"></div>
<div expect_left="120" expect_top="0" expect_width="100" expect_height="50"></div>
<div expect_left="240" expect_top="0" expect_width="100" expect_height="50"></div>
<div expect_left="0" expect_top="60" expect_width="100" expect_height="50"></div>
<div expect_left="120" expect_top="60" expect_width="100" expect_height="50"></div>
<div expect_left="240" expect_top="60" expect_width="100" expect_height="50"></div>
<div expect_left="0" expect_top="120" expect_width="100" expect_height="50"></div>
<div expect_left="120" expect_top="120" expect_width="100" expect_height="50"></div>
<div expect_left="240" expect_top="120" expect_width="100" expect_height="50"></div>
</div>
"#,
true
)
}
#[test]
fn grid_gap_with_auto_columns() {
assert_xml!(
r#"
<div style="display: grid; width: 280px; grid-template-columns: auto auto auto; column-gap: 20px;" expect_height="50">
<div style="height: 50px;" expect_left="0" expect_width="80" expect_height="50"></div>
<div style="height: 50px;" expect_left="100" expect_width="80" expect_height="50"></div>
<div style="height: 50px;" expect_left="200" expect_width="80" expect_height="50"></div>
</div>
"#,
true
)
}
#[test]
fn grid_gap_with_item_margin() {
assert_xml!(
r#"
<div style="display: grid; width: 230px; grid-template-columns: 100px 100px; grid-template-rows: 60px 60px; gap: 10px 30px;">
<div style="margin: 5px; width: 50px; height: 50px;" expect_left="5" expect_top="5"></div>
<div style="margin: 5px; width: 50px; height: 50px;" expect_left="135" expect_top="5"></div>
<div style="margin: 5px; width: 50px; height: 50px;" expect_left="5" expect_top="75"></div>
<div style="margin: 5px; width: 50px; height: 50px;" expect_left="135" expect_top="75"></div>
</div>
"#,
true
)
}
#[test]
fn grid_large_gap() {
assert_xml!(
r#"
<div style="display: grid; width: 350px; grid-template-columns: 100px 100px; grid-template-rows: 50px 50px; gap: 50px;" expect_height="150">
<div expect_left="0" expect_top="0" expect_width="100" expect_height="50"></div>
<div expect_left="150" expect_top="0" expect_width="100" expect_height="50"></div>
<div expect_left="0" expect_top="100" expect_width="100" expect_height="50"></div>
<div expect_left="150" expect_top="100" expect_width="100" expect_height="50"></div>
</div>
"#,
true
)
}
#[test]
fn grid_zero_gap() {
assert_xml!(
r#"
<div style="display: grid; width: 200px; grid-template-columns: 100px 100px; grid-template-rows: 50px 50px; gap: 0px;" expect_height="100">
<div expect_left="0" expect_top="0" expect_width="100" expect_height="50"></div>
<div expect_left="100" expect_top="0" expect_width="100" expect_height="50"></div>
<div expect_left="0" expect_top="50" expect_width="100" expect_height="50"></div>
<div expect_left="100" expect_top="50" expect_width="100" expect_height="50"></div>
</div>
"#,
true
)
}