use morphorm::*;
use morphorm_ecs::*;
#[test]
fn wrap_row_basic() {
let mut world = World::default();
let root = world.add(None);
world.set_width(root, Units::Pixels(300.0));
world.set_height(root, Units::Pixels(300.0));
world.set_layout_type(root, LayoutType::Row);
world.set_wrap(root, LayoutWrap::Wrap);
world.set_alignment(root, Alignment::TopLeft);
let node1 = world.add(Some(root));
world.set_width(node1, Units::Pixels(100.0));
world.set_height(node1, Units::Pixels(50.0));
let node2 = world.add(Some(root));
world.set_width(node2, Units::Pixels(100.0));
world.set_height(node2, Units::Pixels(50.0));
let node3 = world.add(Some(root));
world.set_width(node3, Units::Pixels(100.0));
world.set_height(node3, Units::Pixels(50.0));
root.layout(&mut world.cache, &world.tree, &world.store, &mut ());
assert_eq!(world.cache.bounds(node1), Some(&Rect { posx: 0.0, posy: 0.0, width: 100.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node2), Some(&Rect { posx: 100.0, posy: 0.0, width: 100.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node3), Some(&Rect { posx: 200.0, posy: 0.0, width: 100.0, height: 50.0 }));
}
#[test]
fn wrap_row_with_gap() {
let mut world = World::default();
let root = world.add(None);
world.set_width(root, Units::Pixels(300.0));
world.set_height(root, Units::Pixels(300.0));
world.set_layout_type(root, LayoutType::Row);
world.set_wrap(root, LayoutWrap::Wrap);
world.set_alignment(root, Alignment::TopLeft);
world.set_horizontal_gap(root, Units::Pixels(20.0));
world.set_vertical_gap(root, Units::Pixels(10.0));
let node1 = world.add(Some(root));
world.set_width(node1, Units::Pixels(80.0));
world.set_height(node1, Units::Pixels(50.0));
let node2 = world.add(Some(root));
world.set_width(node2, Units::Pixels(80.0));
world.set_height(node2, Units::Pixels(50.0));
let node3 = world.add(Some(root));
world.set_width(node3, Units::Pixels(80.0));
world.set_height(node3, Units::Pixels(50.0));
let node4 = world.add(Some(root));
world.set_width(node4, Units::Pixels(80.0));
world.set_height(node4, Units::Pixels(50.0));
root.layout(&mut world.cache, &world.tree, &world.store, &mut ());
assert_eq!(world.cache.bounds(node1), Some(&Rect { posx: 0.0, posy: 0.0, width: 80.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node2), Some(&Rect { posx: 100.0, posy: 0.0, width: 80.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node3), Some(&Rect { posx: 200.0, posy: 0.0, width: 80.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node4), Some(&Rect { posx: 0.0, posy: 60.0, width: 80.0, height: 50.0 }));
}
#[test]
fn wrap_column_basic() {
let mut world = World::default();
let root = world.add(None);
world.set_width(root, Units::Pixels(200.0));
world.set_height(root, Units::Pixels(250.0));
world.set_layout_type(root, LayoutType::Column);
world.set_wrap(root, LayoutWrap::Wrap);
world.set_alignment(root, Alignment::TopLeft);
let node1 = world.add(Some(root));
world.set_width(node1, Units::Pixels(80.0));
world.set_height(node1, Units::Pixels(100.0));
let node2 = world.add(Some(root));
world.set_width(node2, Units::Pixels(80.0));
world.set_height(node2, Units::Pixels(100.0));
let node3 = world.add(Some(root));
world.set_width(node3, Units::Pixels(80.0));
world.set_height(node3, Units::Pixels(100.0));
root.layout(&mut world.cache, &world.tree, &world.store, &mut ());
assert_eq!(world.cache.bounds(node1), Some(&Rect { posx: 0.0, posy: 0.0, width: 80.0, height: 100.0 }));
assert_eq!(world.cache.bounds(node2), Some(&Rect { posx: 0.0, posy: 100.0, width: 80.0, height: 100.0 }));
assert_eq!(world.cache.bounds(node3), Some(&Rect { posx: 80.0, posy: 0.0, width: 80.0, height: 100.0 }));
}
#[test]
fn wrap_column_rtl_absolute_only_flips_horizontal_offsets() {
let mut world = World::default();
let root = world.add(None);
world.set_width(root, Units::Pixels(200.0));
world.set_height(root, Units::Pixels(250.0));
world.set_layout_type(root, LayoutType::Column);
world.set_wrap(root, LayoutWrap::Wrap);
world.set_direction(root, Direction::RightToLeft);
let node = world.add(Some(root));
world.set_position_type(node, PositionType::Absolute);
world.set_width(node, Units::Pixels(80.0));
world.set_height(node, Units::Pixels(100.0));
world.set_left(node, Units::Pixels(20.0));
world.set_top(node, Units::Pixels(10.0));
root.layout(&mut world.cache, &world.tree, &world.store, &mut ());
assert_eq!(world.cache.bounds(node), Some(&Rect { posx: 100.0, posy: 10.0, width: 80.0, height: 100.0 }));
}
#[test]
fn wrap_row_with_stretch() {
let mut world = World::default();
let root = world.add(None);
world.set_width(root, Units::Pixels(300.0));
world.set_height(root, Units::Pixels(300.0));
world.set_layout_type(root, LayoutType::Row);
world.set_wrap(root, LayoutWrap::Wrap);
world.set_alignment(root, Alignment::TopLeft);
let node1 = world.add(Some(root));
world.set_width(node1, Units::Stretch(1.0));
world.set_height(node1, Units::Pixels(50.0));
let node2 = world.add(Some(root));
world.set_width(node2, Units::Stretch(1.0));
world.set_height(node2, Units::Pixels(50.0));
let node3 = world.add(Some(root));
world.set_width(node3, Units::Pixels(100.0));
world.set_height(node3, Units::Pixels(50.0));
root.layout(&mut world.cache, &world.tree, &world.store, &mut ());
assert_eq!(world.cache.bounds(node1), Some(&Rect { posx: 0.0, posy: 0.0, width: 100.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node2), Some(&Rect { posx: 100.0, posy: 0.0, width: 100.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node3), Some(&Rect { posx: 200.0, posy: 0.0, width: 100.0, height: 50.0 }));
}
#[test]
fn wrap_row_stretch_children_resolve_to_line_max_cross() {
let mut world = World::default();
let root = world.add(None);
world.set_width(root, Units::Pixels(260.0));
world.set_height(root, Units::Pixels(220.0));
world.set_layout_type(root, LayoutType::Row);
world.set_wrap(root, LayoutWrap::Wrap);
world.set_alignment(root, Alignment::TopLeft);
world.set_horizontal_gap(root, Units::Pixels(10.0));
world.set_vertical_gap(root, Units::Pixels(8.0));
let node1 = world.add(Some(root));
world.set_width(node1, Units::Stretch(1.0));
world.set_height(node1, Units::Stretch(1.0));
world.set_min_width(node1, Units::Pixels(80.0));
world.set_min_height(node1, Units::Pixels(30.0));
let node2 = world.add(Some(root));
world.set_width(node2, Units::Stretch(1.0));
world.set_height(node2, Units::Stretch(1.0));
world.set_min_width(node2, Units::Pixels(120.0));
world.set_min_height(node2, Units::Pixels(70.0));
let node3 = world.add(Some(root));
world.set_width(node3, Units::Stretch(1.0));
world.set_height(node3, Units::Stretch(1.0));
world.set_min_width(node3, Units::Pixels(80.0));
world.set_min_height(node3, Units::Pixels(30.0));
root.layout(&mut world.cache, &world.tree, &world.store, &mut ());
assert_eq!(world.cache.bounds(node1), Some(&Rect { posx: 0.0, posy: 0.0, width: 125.0, height: 70.0 }));
assert_eq!(world.cache.bounds(node2), Some(&Rect { posx: 135.0, posy: 0.0, width: 125.0, height: 70.0 }));
assert_eq!(world.cache.bounds(node3), Some(&Rect { posx: 0.0, posy: 78.0, width: 260.0, height: 30.0 }));
}
#[test]
fn wrap_row_stretch_mixed_min_cross_respects_parent_padding() {
let mut world = World::default();
let root = world.add(None);
world.set_width(root, Units::Pixels(280.0));
world.set_height(root, Units::Pixels(240.0));
world.set_padding_left(root, Units::Pixels(10.0));
world.set_padding_right(root, Units::Pixels(10.0));
world.set_padding_top(root, Units::Pixels(10.0));
world.set_padding_bottom(root, Units::Pixels(10.0));
world.set_layout_type(root, LayoutType::Row);
world.set_wrap(root, LayoutWrap::Wrap);
world.set_alignment(root, Alignment::TopLeft);
world.set_horizontal_gap(root, Units::Pixels(10.0));
world.set_vertical_gap(root, Units::Pixels(8.0));
let node1 = world.add(Some(root));
world.set_width(node1, Units::Stretch(1.0));
world.set_height(node1, Units::Stretch(1.0));
world.set_min_width(node1, Units::Pixels(80.0));
world.set_min_height(node1, Units::Pixels(30.0));
let node2 = world.add(Some(root));
world.set_width(node2, Units::Stretch(1.0));
world.set_height(node2, Units::Stretch(1.0));
world.set_min_width(node2, Units::Pixels(120.0));
world.set_min_height(node2, Units::Pixels(70.0));
let node3 = world.add(Some(root));
world.set_width(node3, Units::Stretch(1.0));
world.set_height(node3, Units::Stretch(1.0));
world.set_min_width(node3, Units::Pixels(80.0));
world.set_min_height(node3, Units::Pixels(30.0));
root.layout(&mut world.cache, &world.tree, &world.store, &mut ());
assert_eq!(world.cache.bounds(node1), Some(&Rect { posx: 10.0, posy: 10.0, width: 125.0, height: 70.0 }));
assert_eq!(world.cache.bounds(node2), Some(&Rect { posx: 145.0, posy: 10.0, width: 125.0, height: 70.0 }));
assert_eq!(world.cache.bounds(node3), Some(&Rect { posx: 10.0, posy: 88.0, width: 260.0, height: 30.0 }));
}
#[test]
fn wrap_column_stretch_mixed_min_cross_respects_parent_padding() {
let mut world = World::default();
let root = world.add(None);
world.set_width(root, Units::Pixels(240.0));
world.set_height(root, Units::Pixels(280.0));
world.set_padding_left(root, Units::Pixels(10.0));
world.set_padding_right(root, Units::Pixels(10.0));
world.set_padding_top(root, Units::Pixels(10.0));
world.set_padding_bottom(root, Units::Pixels(10.0));
world.set_layout_type(root, LayoutType::Column);
world.set_wrap(root, LayoutWrap::Wrap);
world.set_alignment(root, Alignment::TopLeft);
world.set_vertical_gap(root, Units::Pixels(10.0));
world.set_horizontal_gap(root, Units::Pixels(8.0));
let node1 = world.add(Some(root));
world.set_width(node1, Units::Stretch(1.0));
world.set_height(node1, Units::Stretch(1.0));
world.set_min_width(node1, Units::Pixels(30.0));
world.set_min_height(node1, Units::Pixels(80.0));
let node2 = world.add(Some(root));
world.set_width(node2, Units::Stretch(1.0));
world.set_height(node2, Units::Stretch(1.0));
world.set_min_width(node2, Units::Pixels(70.0));
world.set_min_height(node2, Units::Pixels(120.0));
let node3 = world.add(Some(root));
world.set_width(node3, Units::Stretch(1.0));
world.set_height(node3, Units::Stretch(1.0));
world.set_min_width(node3, Units::Pixels(30.0));
world.set_min_height(node3, Units::Pixels(80.0));
root.layout(&mut world.cache, &world.tree, &world.store, &mut ());
assert_eq!(world.cache.bounds(node1), Some(&Rect { posx: 10.0, posy: 10.0, width: 70.0, height: 125.0 }));
assert_eq!(world.cache.bounds(node2), Some(&Rect { posx: 10.0, posy: 145.0, width: 70.0, height: 125.0 }));
assert_eq!(world.cache.bounds(node3), Some(&Rect { posx: 88.0, posy: 10.0, width: 30.0, height: 260.0 }));
}
#[test]
fn wrap_row_stretch_large_min_main_preserves_line_padding() {
let mut world = World::default();
let root = world.add(None);
world.set_width(root, Units::Pixels(872.0));
world.set_height(root, Units::Pixels(934.0));
world.set_layout_type(root, LayoutType::Row);
world.set_wrap(root, LayoutWrap::Wrap);
world.set_alignment(root, Alignment::TopLeft);
world.set_padding_left(root, Units::Pixels(10.0));
world.set_padding_right(root, Units::Pixels(10.0));
world.set_padding_top(root, Units::Pixels(10.0));
world.set_padding_bottom(root, Units::Pixels(10.0));
world.set_horizontal_gap(root, Units::Pixels(10.0));
world.set_vertical_gap(root, Units::Pixels(10.0));
let mins = [180.0, 180.0, 180.0, 300.0, 180.0, 180.0, 180.0];
let mut nodes = Vec::new();
for min in mins {
let node = world.add(Some(root));
world.set_width(node, Units::Stretch(1.0));
world.set_height(node, Units::Stretch(1.0));
world.set_min_width(node, Units::Pixels(min));
world.set_min_height(node, Units::Pixels(min));
nodes.push(node);
}
root.layout(&mut world.cache, &world.tree, &world.store, &mut ());
assert_eq!(world.cache.bounds(nodes[0]), Some(&Rect { posx: 10.0, posy: 10.0, width: 277.0, height: 180.0 }));
assert_eq!(world.cache.bounds(nodes[1]), Some(&Rect { posx: 297.0, posy: 10.0, width: 277.0, height: 180.0 }));
assert_eq!(world.cache.bounds(nodes[2]), Some(&Rect { posx: 584.0, posy: 10.0, width: 277.0, height: 180.0 }));
assert_eq!(world.cache.bounds(nodes[3]), Some(&Rect { posx: 10.0, posy: 200.0, width: 300.0, height: 300.0 }));
assert_eq!(world.cache.bounds(nodes[4]), Some(&Rect { posx: 320.0, posy: 200.0, width: 266.0, height: 300.0 }));
assert_eq!(world.cache.bounds(nodes[5]), Some(&Rect { posx: 596.0, posy: 200.0, width: 266.0, height: 300.0 }));
assert_eq!(world.cache.bounds(nodes[6]), Some(&Rect { posx: 10.0, posy: 510.0, width: 852.0, height: 180.0 }));
}
#[test]
fn wrap_row_no_wrap_mode() {
let mut world = World::default();
let root = world.add(None);
world.set_width(root, Units::Pixels(300.0));
world.set_height(root, Units::Pixels(300.0));
world.set_layout_type(root, LayoutType::Row);
world.set_wrap(root, LayoutWrap::NoWrap);
world.set_alignment(root, Alignment::TopLeft);
let node1 = world.add(Some(root));
world.set_width(node1, Units::Pixels(100.0));
world.set_height(node1, Units::Pixels(50.0));
let node2 = world.add(Some(root));
world.set_width(node2, Units::Pixels(100.0));
world.set_height(node2, Units::Pixels(50.0));
let node3 = world.add(Some(root));
world.set_width(node3, Units::Pixels(100.0));
world.set_height(node3, Units::Pixels(50.0));
root.layout(&mut world.cache, &world.tree, &world.store, &mut ());
assert_eq!(world.cache.bounds(node1), Some(&Rect { posx: 0.0, posy: 0.0, width: 100.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node2), Some(&Rect { posx: 100.0, posy: 0.0, width: 100.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node3), Some(&Rect { posx: 200.0, posy: 0.0, width: 100.0, height: 50.0 }));
}
#[test]
fn wrap_row_single_item_per_line() {
let mut world = World::default();
let root = world.add(None);
world.set_width(root, Units::Pixels(250.0));
world.set_height(root, Units::Pixels(300.0));
world.set_layout_type(root, LayoutType::Row);
world.set_wrap(root, LayoutWrap::Wrap);
world.set_alignment(root, Alignment::TopLeft);
let node1 = world.add(Some(root));
world.set_width(node1, Units::Pixels(200.0));
world.set_height(node1, Units::Pixels(50.0));
let node2 = world.add(Some(root));
world.set_width(node2, Units::Pixels(200.0));
world.set_height(node2, Units::Pixels(50.0));
let node3 = world.add(Some(root));
world.set_width(node3, Units::Pixels(200.0));
world.set_height(node3, Units::Pixels(50.0));
root.layout(&mut world.cache, &world.tree, &world.store, &mut ());
assert_eq!(world.cache.bounds(node1), Some(&Rect { posx: 0.0, posy: 0.0, width: 200.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node2), Some(&Rect { posx: 0.0, posy: 50.0, width: 200.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node3), Some(&Rect { posx: 0.0, posy: 100.0, width: 200.0, height: 50.0 }));
}
#[test]
fn wrap_with_alignment() {
let mut world = World::default();
let root = world.add(None);
world.set_width(root, Units::Pixels(300.0));
world.set_height(root, Units::Pixels(300.0));
world.set_layout_type(root, LayoutType::Row);
world.set_wrap(root, LayoutWrap::Wrap);
world.set_alignment(root, Alignment::Center);
let node1 = world.add(Some(root));
world.set_width(node1, Units::Pixels(100.0));
world.set_height(node1, Units::Pixels(50.0));
let node2 = world.add(Some(root));
world.set_width(node2, Units::Pixels(100.0));
world.set_height(node2, Units::Pixels(50.0));
root.layout(&mut world.cache, &world.tree, &world.store, &mut ());
assert_eq!(world.cache.bounds(node1), Some(&Rect { posx: 50.0, posy: 0.0, width: 100.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node2), Some(&Rect { posx: 150.0, posy: 0.0, width: 100.0, height: 50.0 }));
}
#[test]
fn wrap_auto_container() {
let mut world = World::default();
let root = world.add(None);
world.set_width(root, Units::Pixels(250.0));
world.set_height(root, Units::Pixels(250.0));
world.set_layout_type(root, LayoutType::Row);
world.set_wrap(root, LayoutWrap::Wrap);
world.set_alignment(root, Alignment::TopLeft);
let node1 = world.add(Some(root));
world.set_width(node1, Units::Pixels(100.0));
world.set_height(node1, Units::Pixels(50.0));
let node2 = world.add(Some(root));
world.set_width(node2, Units::Pixels(100.0));
world.set_height(node2, Units::Pixels(50.0));
let node3 = world.add(Some(root));
world.set_width(node3, Units::Pixels(100.0));
world.set_height(node3, Units::Pixels(50.0));
root.layout(&mut world.cache, &world.tree, &world.store, &mut ());
assert_eq!(world.cache.bounds(node1), Some(&Rect { posx: 0.0, posy: 0.0, width: 100.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node2), Some(&Rect { posx: 100.0, posy: 0.0, width: 100.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node3), Some(&Rect { posx: 0.0, posy: 50.0, width: 100.0, height: 50.0 }));
}
#[test]
fn wrap_with_different_line_heights() {
let mut world = World::default();
let root = world.add(None);
world.set_width(root, Units::Pixels(250.0));
world.set_height(root, Units::Pixels(300.0));
world.set_layout_type(root, LayoutType::Row);
world.set_wrap(root, LayoutWrap::Wrap);
world.set_alignment(root, Alignment::TopLeft);
let node1 = world.add(Some(root));
world.set_width(node1, Units::Pixels(100.0));
world.set_height(node1, Units::Pixels(50.0));
let node2 = world.add(Some(root));
world.set_width(node2, Units::Pixels(100.0));
world.set_height(node2, Units::Pixels(80.0));
let node3 = world.add(Some(root));
world.set_width(node3, Units::Pixels(100.0));
world.set_height(node3, Units::Pixels(60.0));
root.layout(&mut world.cache, &world.tree, &world.store, &mut ());
assert_eq!(world.cache.bounds(node1), Some(&Rect { posx: 0.0, posy: 0.0, width: 100.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node2), Some(&Rect { posx: 100.0, posy: 0.0, width: 100.0, height: 80.0 }));
assert_eq!(world.cache.bounds(node3), Some(&Rect { posx: 0.0, posy: 80.0, width: 100.0, height: 60.0 }));
}
#[test]
fn wrap_row_with_padding() {
let mut world = World::default();
let root = world.add(None);
world.set_width(root, Units::Pixels(320.0));
world.set_height(root, Units::Pixels(320.0));
world.set_padding_left(root, Units::Pixels(10.0));
world.set_padding_right(root, Units::Pixels(10.0));
world.set_padding_top(root, Units::Pixels(10.0));
world.set_padding_bottom(root, Units::Pixels(10.0));
world.set_layout_type(root, LayoutType::Row);
world.set_wrap(root, LayoutWrap::Wrap);
world.set_alignment(root, Alignment::TopLeft);
let node1 = world.add(Some(root));
world.set_width(node1, Units::Pixels(100.0));
world.set_height(node1, Units::Pixels(50.0));
let node2 = world.add(Some(root));
world.set_width(node2, Units::Pixels(100.0));
world.set_height(node2, Units::Pixels(50.0));
let node3 = world.add(Some(root));
world.set_width(node3, Units::Pixels(100.0));
world.set_height(node3, Units::Pixels(50.0));
let node4 = world.add(Some(root));
world.set_width(node4, Units::Pixels(100.0));
world.set_height(node4, Units::Pixels(50.0));
root.layout(&mut world.cache, &world.tree, &world.store, &mut ());
assert_eq!(world.cache.bounds(node1), Some(&Rect { posx: 10.0, posy: 10.0, width: 100.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node2), Some(&Rect { posx: 110.0, posy: 10.0, width: 100.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node3), Some(&Rect { posx: 210.0, posy: 10.0, width: 100.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node4), Some(&Rect { posx: 10.0, posy: 60.0, width: 100.0, height: 50.0 }));
}
#[test]
fn wrap_row_rtl() {
let mut world = World::default();
let root = world.add(None);
world.set_width(root, Units::Pixels(250.0));
world.set_height(root, Units::Pixels(300.0));
world.set_layout_type(root, LayoutType::Row);
world.set_direction(root, Direction::RightToLeft);
world.set_wrap(root, LayoutWrap::Wrap);
world.set_alignment(root, Alignment::TopLeft);
let node1 = world.add(Some(root));
world.set_width(node1, Units::Pixels(100.0));
world.set_height(node1, Units::Pixels(50.0));
let node2 = world.add(Some(root));
world.set_width(node2, Units::Pixels(100.0));
world.set_height(node2, Units::Pixels(50.0));
let node3 = world.add(Some(root));
world.set_width(node3, Units::Pixels(100.0));
world.set_height(node3, Units::Pixels(50.0));
root.layout(&mut world.cache, &world.tree, &world.store, &mut ());
assert_eq!(world.cache.bounds(node1), Some(&Rect { posx: 150.0, posy: 0.0, width: 100.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node2), Some(&Rect { posx: 50.0, posy: 0.0, width: 100.0, height: 50.0 }));
assert_eq!(world.cache.bounds(node3), Some(&Rect { posx: 150.0, posy: 50.0, width: 100.0, height: 50.0 }));
}
#[test]
fn wrap_row_auto_height_includes_lines_gap_and_padding() {
let mut world = World::default();
let root = world.add(None);
world.set_width(root, Units::Pixels(400.0));
world.set_height(root, Units::Pixels(400.0));
world.set_layout_type(root, LayoutType::Column);
world.set_alignment(root, Alignment::TopLeft);
let wrap = world.add(Some(root));
world.set_width(wrap, Units::Pixels(250.0));
world.set_height(wrap, Units::Auto);
world.set_layout_type(wrap, LayoutType::Row);
world.set_wrap(wrap, LayoutWrap::Wrap);
world.set_alignment(wrap, Alignment::TopLeft);
world.set_padding_top(wrap, Units::Pixels(5.0));
world.set_padding_bottom(wrap, Units::Pixels(5.0));
world.set_vertical_gap(wrap, Units::Pixels(10.0));
let a = world.add(Some(wrap));
world.set_width(a, Units::Pixels(100.0));
world.set_height(a, Units::Pixels(50.0));
let b = world.add(Some(wrap));
world.set_width(b, Units::Pixels(100.0));
world.set_height(b, Units::Pixels(50.0));
let c = world.add(Some(wrap));
world.set_width(c, Units::Pixels(100.0));
world.set_height(c, Units::Pixels(50.0));
root.layout(&mut world.cache, &world.tree, &world.store, &mut ());
assert_eq!(world.cache.bounds(wrap), Some(&Rect { posx: 0.0, posy: 0.0, width: 250.0, height: 120.0 }));
assert_eq!(world.cache.bounds(a), Some(&Rect { posx: 0.0, posy: 5.0, width: 100.0, height: 50.0 }));
assert_eq!(world.cache.bounds(b), Some(&Rect { posx: 100.0, posy: 5.0, width: 100.0, height: 50.0 }));
assert_eq!(world.cache.bounds(c), Some(&Rect { posx: 0.0, posy: 65.0, width: 100.0, height: 50.0 }));
}