dymokomi/luce-browser-engine
Source of release 0.6.1
0.6.1 / src / web / layout / tests_layout_flex.lucb
#==============================================================================================
#
# tests_layout_flex - flex layout of parsed documents, pinned to the reference build
#
# DESCRIPTION:
# Runs the cases of tests_layout_flex_cases through the port with the harness of
# tests_layout_geometry (layout, commit, and the three dumps of a Layout test). They are
# Ladybird's own Tests/LibWeb/Layout tests whose layout first reached the
# FlexFormattingContext (all of Layout/input/flex and the flex tests around it); the
# local oracle that wrote the table (luce-browser-tools,
# oracles/luce-browser-engine/layout_geometry, cases_flex.txt) runs the reference
# build's LibWeb on the same documents. They lay out flex containers in every
# direction and wrapping mode: flex base sizes and flexible lengths, automatic minimum
# sizes, aspect ratios, intrinsic sizes of flex containers and items, justify-content,
# align-items/align-self/align-content, auto margins, gaps, baselines, abspos children's
# static positions, percentages against definite and indefinite containers, quirks.
#
#==============================================================================================
# mark: Tests ===================================================================================
test "flex layout (flex lines, flexible lengths, alignment, intrinsic sizes, abspos children) matches the reference build":
web_initialize_strings()
test_fonts_setup()
let vm = web_test_create_vm()
defer web_test_destroy_vm(vm)
var (realm, realm_root) = test_layout_tree_window_realm(vm)
defer gc.root_release(&realm_root)
let heap = vm_heap(vm)
var passed: usize = 0
var failed: usize = 0
let allocator: memory.Allocator = heap
with allocator:
test_page_client_color_scheme = CssPreferredColorScheme.light
defer test_page_client_color_scheme = CssPreferredColorScheme.auto
test_media_invalidation_install_user_agent_sheets(realm)
defer test_style_computer_release_user_agent_sheets()
for test_case in &test_layout_flex_cases:
let actual = test_layout_geometry_run_case(heap, realm, test_case)
let actual_view = ak.string_bytes_as_string_view(&actual)
if ak.string_view_equals(&actual_view, test_case.expected):
passed += 1
else:
failed += 1
print(f"flex layout case mismatch: {test_case.html} / {test_case.css}")
print(f"expected:\n{test_case.expected}actual:\n{ak.string_view_text(actual_view)}")
print(f"flex layout: {passed} passed, {failed} failed")
assert(failed == 0)
assert(passed > 0)