diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-03-12 20:18:49 -0400 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-03-12 20:18:49 -0400 |
| commit | 22ff2a06ec70b5ad856ff8fbce3d15041f8aa99d (patch) | |
| tree | ded554560b08a4cacd5a8e5229bd625e37788b53 /tests | |
| parent | 14fa08a4a3ac34c10e9a8b754eb49778f60c2372 (diff) | |
pke: static ui position static + dynamic test
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/pke-test-static-ui.cpp | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/tests/pke-test-static-ui.cpp b/tests/pke-test-static-ui.cpp index 38528cf..0b88295 100644 --- a/tests/pke-test-static-ui.cpp +++ b/tests/pke-test-static-ui.cpp @@ -113,8 +113,52 @@ int pke_test_static_ui_100() { } -// test flex +// test dynamic + static int pke_test_static_ui_200() { + DynArray<pke_ui_box_instance_buffer_item> arr{}; + float unit; + float calculated_offset_x, calculated_offset_y; + uint8_t err_index = 0; + + pke_ui_box *ui_box = pke_ui_box_new_root(); + ui_box->flags = PKE_UI_BOX_FLAG_POSITION_TYPE_DYNAMIC; + ui_box->pos_top_left_x = 0.1; + ui_box->pos_top_left_y = 0.1; + ui_box->max_width = 0.8; + ui_box->max_height = 0.8; + + pke_ui_box *c_ui_box = pke_ui_box_new_child(ui_box); + c_ui_box->flags = PKE_UI_BOX_FLAG_POSITION_TYPE_STATIC; + c_ui_box->pos_top_left_x = 1; + c_ui_box->pos_top_left_y = 1; + c_ui_box->max_width = 300; + c_ui_box->max_height = 300; + + unit = Extent.width * 0.1; + calculated_offset_x = unit + 1 + built_in_offset; + + unit = Extent.height * 0.1; + calculated_offset_y = unit + 1 + built_in_offset; + + pke_ui_calc_px(arr, nullptr, ui_box); + pke_ui_recalc_sizes_recursive(arr, ui_box, 0); + + PKE_TEST_ASSERT(ui_box->internal.parent == nullptr, err_index); + PKE_TEST_ASSERT(ui_box->internal.h_children == 1, err_index); + PKE_TEST_ASSERT(c_ui_box->internal.parent != nullptr, err_index); + PKE_TEST_ASSERT(c_ui_box->internal.h_children == 0, err_index); + PKE_TEST_ASSERT(c_ui_box->internal.r_children == 0, err_index); + + PKE_TEST_ASSERT(ui_box->internal.px_corner_x == Extent.width * 0.1, err_index); + PKE_TEST_ASSERT(ui_box->internal.px_corner_y == Extent.height * 0.1, err_index); + PKE_TEST_ASSERT(c_ui_box->internal.px_corner_x == calculated_offset_x, err_index); + PKE_TEST_ASSERT(c_ui_box->internal.px_corner_y == calculated_offset_y, err_index); + + PKE_TEST_ASSERT(ui_box->internal.px_width == (Extent.width * 0.1) * 8, err_index); + PKE_TEST_ASSERT(ui_box->internal.px_height == (Extent.height * 0.1) * 8, err_index); + PKE_TEST_ASSERT(c_ui_box->internal.px_width == 300, err_index); + PKE_TEST_ASSERT(c_ui_box->internal.px_height == 300, err_index); + return 0; } |
