layout tests: arms the first mutation round left unpinned
This commit is contained in:
parent
ee42148eb0
commit
9852e95541
1 changed files with 60 additions and 0 deletions
|
|
@ -423,6 +423,66 @@ fn taffy_edges() {
|
|||
assert_eq!((node("root").clip, node("root").content), (false, None));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn item_alignment_and_content_arms() {
|
||||
// align_items Auto is CSS normal: items stretch across the cross axis.
|
||||
let column = BoxStyle { direction: Direction::Column, align_items: ItemAlign::Auto, size: size2(px(200.0), Dimension::Auto), ..plain() };
|
||||
let laid = lay(bx("root", column, vec![bx("stretched", plain(), vec![embed("e", 10.0, 10.0)])]), 800.0, 600.0);
|
||||
assert_eq!(rect(&laid, "stretched").2, 200.0);
|
||||
|
||||
// basis Content ignores the declared width: the item takes its content.
|
||||
let basis = BoxStyle { basis: Dimension::Content, ..sized(100.0, 10.0) };
|
||||
let laid = lay(bx("root", plain(), vec![bx("b", basis, vec![embed("e", 30.0, 10.0)])]), 800.0, 600.0);
|
||||
assert_eq!(rect(&laid, "b").2, 30.0);
|
||||
|
||||
// A Content track is as wide as its widest item and does not stretch; an Auto track does.
|
||||
let mut grid = BoxStyle { display: Display::Grid, size: size2(px(400.0), Dimension::Auto), justify_content: ContentAlign::Stretch, ..plain() };
|
||||
grid.grid_columns = vec![Dimension::Content, Dimension::Auto];
|
||||
let laid = lay(bx("root", grid, vec![embed("c1", 50.0, 10.0), embed("c2", 10.0, 10.0)]), 800.0, 600.0);
|
||||
assert_eq!(rect(&laid, "c2").0, 50.0);
|
||||
|
||||
// A Fr track holds at least its content.
|
||||
let mut grid = BoxStyle { display: Display::Grid, size: size2(px(100.0), Dimension::Auto), ..plain() };
|
||||
let fr = || Dimension::Fr(Scalar { value: 1.0 });
|
||||
grid.grid_columns = vec![fr(), fr()];
|
||||
let laid = lay(bx("root", grid, vec![embed("f1", 80.0, 10.0), embed("f2", 10.0, 10.0)]), 800.0, 600.0);
|
||||
assert_eq!(rect(&laid, "f2").0, 80.0);
|
||||
|
||||
// Scroll lets a flex item shrink below its content; Clip does not.
|
||||
let item = |overflow| BoxStyle { overflow, ..plain() };
|
||||
let laid = lay(
|
||||
bx("root", sized(100.0, 20.0), vec![
|
||||
bx("scroll", item(Overflow::Scroll), vec![embed("a", 300.0, 10.0)]),
|
||||
]),
|
||||
800.0,
|
||||
600.0,
|
||||
);
|
||||
assert_eq!(rect(&laid, "scroll").2, 100.0);
|
||||
let laid = lay(
|
||||
bx("root", sized(100.0, 20.0), vec![bx("clip", item(Overflow::Clip), vec![embed("a", 300.0, 10.0)])]),
|
||||
800.0,
|
||||
600.0,
|
||||
);
|
||||
assert_eq!(rect(&laid, "clip").2, 300.0);
|
||||
|
||||
// A scrollable content size is whole device pixels.
|
||||
let mut scroll = sized(100.0, 50.0);
|
||||
scroll.overflow = Overflow::Scroll;
|
||||
let laid = lay(bx("root", plain(), vec![bx("s", scroll, vec![embed("big", 200.4, 300.6)])]), 800.0, 600.0);
|
||||
assert_eq!(laid.nodes[1].content, Some((200.0, 301.0)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn available_space_is_logical() {
|
||||
// A shrink-to-fit box wraps its text at the room it is offered: 100 logical px at any scale.
|
||||
let wrapped = BoxStyle { size: size2(Dimension::Content, Dimension::Auto), ..plain() };
|
||||
let root = bx("root", sized(100.0, 600.0), vec![bx("wrap", wrapped, vec![text("t", &"x".repeat(40))])]);
|
||||
for scale in [1.0, 2.0] {
|
||||
let laid = lay_with(&mut MemState::new(), root.clone(), &pixels(800.0, 600.0, scale));
|
||||
assert_eq!(rect(&laid, "wrap").2, 100.0 * scale);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn repeat_splice() {
|
||||
let laid = &laid_fixture(Fixture::F01SwarmDashboard, &pixels(800.0, 600.0, 1.0))[0].1;
|
||||
|
|
|
|||
Loading…
Reference in a new issue