711 lines
25 KiB
MoonBit
711 lines
25 KiB
MoonBit
// Copyright 2025 International Digital Economy Academy
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
///|
|
|
test "upstream/generated/flex/measure_flex_basis_overrides_measure" {
|
|
// Ported from taffy-reference/tests/generated/flex/measure_flex_basis_overrides_measure.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf_with_context(Style::default(), {
|
|
text_content: "H",
|
|
writing_mode: Horizontal,
|
|
})
|
|
let node = taffy.new_with_children(
|
|
Style::default().with_size(Size(width=length(50.0), height=length(50.0))),
|
|
[node0],
|
|
)
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 50.0)
|
|
assert_eq(lnode.size.height, 50.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 10.0)
|
|
assert_eq(l0.size.height, 50.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/measure_height_overrides_measure" {
|
|
// Ported from taffy-reference/tests/generated/flex/measure_height_overrides_measure.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf_with_context(
|
|
Style::default().with_size(Size(width=auto(), height=length(5.0))),
|
|
{ text_content: "H", writing_mode: Horizontal },
|
|
)
|
|
let node = taffy.new_with_children(Style::default(), [node0])
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 10.0)
|
|
assert_eq(lnode.size.height, 5.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 10.0)
|
|
assert_eq(l0.size.height, 5.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/measure_remeasure_child_after_growing" {
|
|
// Ported from taffy-reference/tests/generated/flex/measure_remeasure_child_after_growing.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf(
|
|
Style::default().with_size(Size(width=length(50.0), height=length(50.0))),
|
|
)
|
|
let node1 = taffy.new_leaf_with_context(Style::default(), {
|
|
text_content: "HH",
|
|
writing_mode: Horizontal,
|
|
})
|
|
let node = taffy.new_with_children(
|
|
Style::default()
|
|
.with_align_items(align_items_start())
|
|
.with_size(Size(width=length(100.0), height=auto())),
|
|
[node0, node1],
|
|
)
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 100.0)
|
|
assert_eq(lnode.size.height, 50.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 50.0)
|
|
assert_eq(l0.size.height, 50.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
let l1 = taffy.layout(node1)
|
|
assert_eq(l1.size.width, 20.0)
|
|
assert_eq(l1.size.height, 10.0)
|
|
assert_eq(l1.location.x, 50.0)
|
|
assert_eq(l1.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/measure_remeasure_child_after_shrinking" {
|
|
// Ported from taffy-reference/tests/generated/flex/measure_remeasure_child_after_shrinking.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf(
|
|
Style::default()
|
|
.with_flex_shrink(0.0)
|
|
.with_size(Size(width=length(50.0), height=length(50.0))),
|
|
)
|
|
let node1 = taffy.new_leaf_with_context(Style::default(), {
|
|
text_content: "HH",
|
|
writing_mode: Horizontal,
|
|
})
|
|
let node = taffy.new_with_children(
|
|
Style::default()
|
|
.with_align_items(align_items_start())
|
|
.with_size(Size(width=length(100.0), height=auto())),
|
|
[node0, node1],
|
|
)
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 100.0)
|
|
assert_eq(lnode.size.height, 50.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 50.0)
|
|
assert_eq(l0.size.height, 50.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
let l1 = taffy.layout(node1)
|
|
assert_eq(l1.size.width, 20.0)
|
|
assert_eq(l1.size.height, 10.0)
|
|
assert_eq(l1.location.x, 50.0)
|
|
assert_eq(l1.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/measure_remeasure_child_after_stretching" {
|
|
// Ported from taffy-reference/tests/generated/flex/measure_remeasure_child_after_stretching.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf_with_context(Style::default(), {
|
|
text_content: "HH",
|
|
writing_mode: Horizontal,
|
|
})
|
|
let node = taffy.new_with_children(
|
|
Style::default().with_size(Size(width=length(100.0), height=length(100.0))),
|
|
[node0],
|
|
)
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 100.0)
|
|
assert_eq(lnode.size.height, 100.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 20.0)
|
|
assert_eq(l0.size.height, 100.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/measure_root" {
|
|
// Ported from taffy-reference/tests/generated/flex/measure_root.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node = taffy.new_leaf_with_context(Style::default(), {
|
|
text_content: "HHHHHH",
|
|
writing_mode: Horizontal,
|
|
})
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 60.0)
|
|
assert_eq(lnode.size.height, 10.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/measure_stretch_overrides_measure" {
|
|
// Ported from taffy-reference/tests/generated/flex/measure_stretch_overrides_measure.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf(
|
|
Style::default().with_flex_grow(1.0).with_flex_basis(length(5.0)),
|
|
)
|
|
let node1 = taffy.new_leaf_with_context(
|
|
Style::default().with_flex_grow(1.0).with_flex_basis(length(5.0)),
|
|
{ text_content: "H", writing_mode: Horizontal },
|
|
)
|
|
let node = taffy.new_with_children(
|
|
Style::default().with_size(Size(width=length(20.0), height=length(10.0))),
|
|
[node0, node1],
|
|
)
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 20.0)
|
|
assert_eq(lnode.size.height, 10.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 10.0)
|
|
assert_eq(l0.size.height, 10.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
let l1 = taffy.layout(node1)
|
|
assert_eq(l1.size.width, 10.0)
|
|
assert_eq(l1.size.height, 10.0)
|
|
assert_eq(l1.location.x, 10.0)
|
|
assert_eq(l1.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/measure_width_overrides_measure" {
|
|
// Ported from taffy-reference/tests/generated/flex/measure_width_overrides_measure.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf_with_context(
|
|
Style::default().with_size(Size(width=length(50.0), height=auto())),
|
|
{ text_content: "HHHHHHHHHH", writing_mode: Horizontal },
|
|
)
|
|
let node = taffy.new_with_children(Style::default(), [node0])
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 50.0)
|
|
assert_eq(lnode.size.height, 10.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 50.0)
|
|
assert_eq(l0.size.height, 10.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/min_height" {
|
|
// Ported from taffy-reference/tests/generated/flex/min_height.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf(
|
|
Style::default()
|
|
.with_flex_grow(1.0)
|
|
.with_min_size(Size(width=auto(), height=length(60.0))),
|
|
)
|
|
let node1 = taffy.new_leaf(Style::default().with_flex_grow(1.0))
|
|
let node = taffy.new_with_children(
|
|
Style::default()
|
|
.with_flex_direction(flex_direction_column())
|
|
.with_size(Size(width=length(100.0), height=length(100.0))),
|
|
[node0, node1],
|
|
)
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 100.0)
|
|
assert_eq(lnode.size.height, 100.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 100.0)
|
|
assert_eq(l0.size.height, 60.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
let l1 = taffy.layout(node1)
|
|
assert_eq(l1.size.width, 100.0)
|
|
assert_eq(l1.size.height, 40.0)
|
|
assert_eq(l1.location.x, 0.0)
|
|
assert_eq(l1.location.y, 60.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/min_height_larger_than_height" {
|
|
// Ported from taffy-reference/tests/generated/flex/min_height_larger_than_height.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf(
|
|
Style::default()
|
|
.with_size(Size(width=auto(), height=length(25.0)))
|
|
.with_min_size(Size(width=auto(), height=length(50.0))),
|
|
)
|
|
let node = taffy.new_with_children(
|
|
Style::default().with_size(Size(width=length(100.0), height=length(100.0))),
|
|
[node0],
|
|
)
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 100.0)
|
|
assert_eq(lnode.size.height, 100.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 0.0)
|
|
assert_eq(l0.size.height, 50.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/min_height_overrides_height" {
|
|
// Ported from taffy-reference/tests/generated/flex/min_height_overrides_height.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf(
|
|
Style::default()
|
|
.with_size(Size(width=auto(), height=length(50.0)))
|
|
.with_min_size(Size(width=auto(), height=length(100.0))),
|
|
)
|
|
let node = taffy.new_with_children(Style::default(), [node0])
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 0.0)
|
|
assert_eq(lnode.size.height, 100.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 0.0)
|
|
assert_eq(l0.size.height, 100.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/min_height_overrides_height_on_root" {
|
|
// Ported from taffy-reference/tests/generated/flex/min_height_overrides_height_on_root.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node = taffy.new_leaf(
|
|
Style::default()
|
|
.with_size(Size(width=auto(), height=length(50.0)))
|
|
.with_min_size(Size(width=auto(), height=length(100.0))),
|
|
)
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 0.0)
|
|
assert_eq(lnode.size.height, 100.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/min_height_overrides_max_height" {
|
|
// Ported from taffy-reference/tests/generated/flex/min_height_overrides_max_height.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf(
|
|
Style::default()
|
|
.with_min_size(Size(width=auto(), height=length(100.0)))
|
|
.with_max_size(Size(width=auto(), height=length(50.0))),
|
|
)
|
|
let node = taffy.new_with_children(Style::default(), [node0])
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 0.0)
|
|
assert_eq(lnode.size.height, 100.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 0.0)
|
|
assert_eq(l0.size.height, 100.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/min_height_with_nested_fixed_height" {
|
|
// Ported from taffy-reference/tests/generated/flex/min_height_with_nested_fixed_height.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node00 = taffy.new_leaf(
|
|
Style::default().with_size(Size(width=length(40.0), height=length(40.0))),
|
|
)
|
|
let node0 = taffy.new_with_children(
|
|
Style::default()
|
|
.with_flex_direction(flex_direction_column())
|
|
.with_align_self(align_items_flex_start())
|
|
.with_flex_shrink(0.0)
|
|
.with_min_size(Size(width=auto(), height=length(28.0)))
|
|
.with_margin(
|
|
Rect(
|
|
left=length(0.0),
|
|
right=length(0.0),
|
|
top=length(8.0),
|
|
bottom=length(9.0),
|
|
),
|
|
),
|
|
[node00],
|
|
)
|
|
let node = taffy.new_with_children(
|
|
Style::default()
|
|
.with_size(Size(width=length(320.0), height=auto()))
|
|
.with_min_size(Size(width=auto(), height=length(44.0)))
|
|
.with_padding(
|
|
Rect(
|
|
left=length(16.0),
|
|
right=length(16.0),
|
|
top=length(0.0),
|
|
bottom=length(0.0),
|
|
),
|
|
),
|
|
[node0],
|
|
)
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 320.0)
|
|
assert_eq(lnode.size.height, 57.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 40.0)
|
|
assert_eq(l0.size.height, 40.0)
|
|
assert_eq(l0.location.x, 16.0)
|
|
assert_eq(l0.location.y, 8.0)
|
|
let l00 = taffy.layout(node00)
|
|
assert_eq(l00.size.width, 40.0)
|
|
assert_eq(l00.size.height, 40.0)
|
|
assert_eq(l00.location.x, 0.0)
|
|
assert_eq(l00.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/min_max_percent_different_width_height" {
|
|
// Ported from taffy-reference/tests/generated/flex/min_max_percent_different_width_height.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf_with_context(
|
|
Style::default()
|
|
.with_min_size(Size(width=percent(0.1), height=percent(0.1)))
|
|
.with_max_size(Size(width=percent(0.1), height=percent(0.1))),
|
|
{ text_content: "", writing_mode: Horizontal },
|
|
)
|
|
let node = taffy.new_with_children(
|
|
Style::default()
|
|
.with_flex_direction(flex_direction_column())
|
|
.with_align_items(align_items_flex_start())
|
|
.with_size(Size(width=length(100.0), height=length(200.0))),
|
|
[node0],
|
|
)
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 100.0)
|
|
assert_eq(lnode.size.height, 200.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 10.0)
|
|
assert_eq(l0.size.height, 20.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/min_max_percent_no_width_height" {
|
|
// Ported from taffy-reference/tests/generated/flex/min_max_percent_no_width_height.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf(
|
|
Style::default()
|
|
.with_min_size(Size(width=percent(0.1), height=percent(0.1)))
|
|
.with_max_size(Size(width=percent(0.1), height=percent(0.1))),
|
|
)
|
|
let node = taffy.new_with_children(
|
|
Style::default()
|
|
.with_flex_direction(flex_direction_column())
|
|
.with_align_items(align_items_flex_start())
|
|
.with_size(Size(width=length(100.0), height=length(100.0))),
|
|
[node0],
|
|
)
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 100.0)
|
|
assert_eq(lnode.size.height, 100.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 10.0)
|
|
assert_eq(l0.size.height, 10.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/min_width" {
|
|
// Ported from taffy-reference/tests/generated/flex/min_width.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf(
|
|
Style::default()
|
|
.with_flex_grow(1.0)
|
|
.with_min_size(Size(width=length(60.0), height=auto())),
|
|
)
|
|
let node1 = taffy.new_leaf(Style::default().with_flex_grow(1.0))
|
|
let node = taffy.new_with_children(
|
|
Style::default().with_size(Size(width=length(100.0), height=length(100.0))),
|
|
[node0, node1],
|
|
)
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 100.0)
|
|
assert_eq(lnode.size.height, 100.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 60.0)
|
|
assert_eq(l0.size.height, 100.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
let l1 = taffy.layout(node1)
|
|
assert_eq(l1.size.width, 40.0)
|
|
assert_eq(l1.size.height, 100.0)
|
|
assert_eq(l1.location.x, 60.0)
|
|
assert_eq(l1.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/min_width_larger_than_width" {
|
|
// Ported from taffy-reference/tests/generated/flex/min_width_larger_than_width.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf(
|
|
Style::default()
|
|
.with_size(Size(width=length(25.0), height=auto()))
|
|
.with_min_size(Size(width=length(50.0), height=auto())),
|
|
)
|
|
let node = taffy.new_with_children(
|
|
Style::default()
|
|
.with_flex_direction(flex_direction_column())
|
|
.with_size(Size(width=length(100.0), height=length(100.0))),
|
|
[node0],
|
|
)
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 100.0)
|
|
assert_eq(lnode.size.height, 100.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 50.0)
|
|
assert_eq(l0.size.height, 0.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/min_width_overrides_max_width" {
|
|
// Ported from taffy-reference/tests/generated/flex/min_width_overrides_max_width.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf(
|
|
Style::default()
|
|
.with_min_size(Size(width=length(100.0), height=auto()))
|
|
.with_max_size(Size(width=length(50.0), height=auto())),
|
|
)
|
|
let node = taffy.new_with_children(Style::default(), [node0])
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 100.0)
|
|
assert_eq(lnode.size.height, 0.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 100.0)
|
|
assert_eq(l0.size.height, 0.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/min_width_overrides_width" {
|
|
// Ported from taffy-reference/tests/generated/flex/min_width_overrides_width.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf(
|
|
Style::default()
|
|
.with_size(Size(width=length(50.0), height=auto()))
|
|
.with_min_size(Size(width=length(100.0), height=auto())),
|
|
)
|
|
let node = taffy.new_with_children(Style::default(), [node0])
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 100.0)
|
|
assert_eq(lnode.size.height, 0.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 100.0)
|
|
assert_eq(l0.size.height, 0.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/min_width_overrides_width_on_root" {
|
|
// Ported from taffy-reference/tests/generated/flex/min_width_overrides_width_on_root.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node = taffy.new_leaf(
|
|
Style::default()
|
|
.with_size(Size(width=length(50.0), height=auto()))
|
|
.with_min_size(Size(width=length(100.0), height=auto())),
|
|
)
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 100.0)
|
|
assert_eq(lnode.size.height, 0.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/mod" {
|
|
// Ported from taffy-reference/tests/generated/flex/mod.rs
|
|
()
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/nested_overflowing_child" {
|
|
// Ported from taffy-reference/tests/generated/flex/nested_overflowing_child.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node00 = taffy.new_leaf(
|
|
Style::default().with_size(Size(width=length(200.0), height=length(200.0))),
|
|
)
|
|
let node0 = taffy.new_with_children(Style::default(), [node00])
|
|
let node = taffy.new_with_children(
|
|
Style::default().with_size(Size(width=length(100.0), height=length(100.0))),
|
|
[node0],
|
|
)
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 100.0)
|
|
assert_eq(lnode.size.height, 100.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 200.0)
|
|
assert_eq(l0.size.height, 100.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
let l00 = taffy.layout(node00)
|
|
assert_eq(l00.size.width, 200.0)
|
|
assert_eq(l00.size.height, 200.0)
|
|
assert_eq(l00.location.x, 0.0)
|
|
assert_eq(l00.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/nested_overflowing_child_in_constraint_parent" {
|
|
// Ported from taffy-reference/tests/generated/flex/nested_overflowing_child_in_constraint_parent.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node00 = taffy.new_leaf(
|
|
Style::default().with_size(Size(width=length(200.0), height=length(200.0))),
|
|
)
|
|
let node0 = taffy.new_with_children(
|
|
Style::default().with_size(Size(width=length(100.0), height=length(100.0))),
|
|
[node00],
|
|
)
|
|
let node = taffy.new_with_children(
|
|
Style::default().with_size(Size(width=length(100.0), height=length(100.0))),
|
|
[node0],
|
|
)
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 100.0)
|
|
assert_eq(lnode.size.height, 100.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 100.0)
|
|
assert_eq(l0.size.height, 100.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
let l00 = taffy.layout(node00)
|
|
assert_eq(l00.size.width, 100.0)
|
|
assert_eq(l00.size.height, 200.0)
|
|
assert_eq(l00.location.x, 0.0)
|
|
assert_eq(l00.location.y, 0.0)
|
|
}
|
|
|
|
///|
|
|
test "upstream/generated/flex/only_shrinkable_item_with_flex_basis_zero" {
|
|
// Ported from taffy-reference/tests/generated/flex/only_shrinkable_item_with_flex_basis_zero.rs
|
|
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
|
let node0 = taffy.new_leaf(
|
|
Style::default().with_flex_shrink(1.0).with_flex_basis(length(0.0)),
|
|
)
|
|
let node1 = taffy.new_leaf(
|
|
Style::default()
|
|
.with_flex_shrink(0.0)
|
|
.with_flex_basis(length(93.0))
|
|
.with_margin(
|
|
Rect(
|
|
left=length(0.0),
|
|
right=length(0.0),
|
|
top=length(0.0),
|
|
bottom=length(6.0),
|
|
),
|
|
),
|
|
)
|
|
let node2 = taffy.new_leaf(
|
|
Style::default().with_flex_shrink(0.0).with_flex_basis(length(764.0)),
|
|
)
|
|
let node = taffy.new_with_children(
|
|
Style::default()
|
|
.with_flex_direction(flex_direction_column())
|
|
.with_size(Size(width=length(480.0), height=auto()))
|
|
.with_max_size(Size(width=auto(), height=length(764.0))),
|
|
[node0, node1, node2],
|
|
)
|
|
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
|
let lnode = taffy.layout(node)
|
|
assert_eq(lnode.size.width, 480.0)
|
|
assert_eq(lnode.size.height, 764.0)
|
|
assert_eq(lnode.location.x, 0.0)
|
|
assert_eq(lnode.location.y, 0.0)
|
|
let l0 = taffy.layout(node0)
|
|
assert_eq(l0.size.width, 480.0)
|
|
assert_eq(l0.size.height, 0.0)
|
|
assert_eq(l0.location.x, 0.0)
|
|
assert_eq(l0.location.y, 0.0)
|
|
let l1 = taffy.layout(node1)
|
|
assert_eq(l1.size.width, 480.0)
|
|
assert_eq(l1.size.height, 93.0)
|
|
assert_eq(l1.location.x, 0.0)
|
|
assert_eq(l1.location.y, 0.0)
|
|
let l2 = taffy.layout(node2)
|
|
assert_eq(l2.size.width, 480.0)
|
|
assert_eq(l2.size.height, 764.0)
|
|
assert_eq(l2.location.x, 0.0)
|
|
assert_eq(l2.location.y, 99.0)
|
|
}
|