mirror of
https://github.com/lc-soft/LCUI.git
synced 2026-11-30 16:48:21 +01:00
Restructure the test infrastructure with these changes: * Extend libctest with ctest_suite_t, ctest_parse_args, ctest_run_suites and CTEST_MAIN macro to standardize test entry points; support --grep / --grep= / --list / --interactive flags; add ctest-tests for self-tests. * Regroup tests by lib boundary: sink unit tests into lib/<name>/tests/ with <lib>_<topic> entry function names, move fixtures into lib/<name>/tests/fixtures/, rename top-level tests/cases/ to tests/integration/ for cross-lib integration tests. * Add tests/scenes/ for reusable widget tree builders shared by integration cases and visual preview binaries; add tests/previews/ with 4 diagnostic binaries (flex_layout, block_layout, widget_opacity, scrollbar). * Rewrite all describe/equal description strings using 'should ...' style or noun topic names; drop redundant lcui_quit/lcui_main calls from integration cases. * Integrate xmake test via add_tests(\default\) and a shared tests.runnable rule defined in the root xmake.lua; the rule wraps the test binary with drmemory (Windows) or valgrind (Linux) when option memcheck=y. * Drop the lcui-tests aggregation: lcui-tests now contains only integration cases and scenes, not the union of lib tests. Use xmake test to run everything across libs. * Fix .clang-format: InsertNewlineAtEndOfFile -> InsertNewlineAtEOF (correct key for clang-format 16+). * Update AGENTS.md with the new test layout, naming rules, description style and run commands. * Update CI to use xmake test and xmake f --memcheck=y instead of per-lib runs.
65 lines
2.1 KiB
C
65 lines
2.1 KiB
C
/*
|
|
* lib/ui-xml/tests/test_xml_parser.c
|
|
*
|
|
* Copyright (c) 2023, Liu Chao <i@lc-soft.io> All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
* This file is part of LCUI, distributed under the MIT License found in the
|
|
* LICENSE.TXT file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include <ui.h>
|
|
#include <ui_xml.h>
|
|
#include <ctest.h>
|
|
|
|
static void check_widget_attribute(void)
|
|
{
|
|
ui_widget_t *w;
|
|
|
|
w = ui_get_widget("test-attr-disabled-1");
|
|
ctest_equal_bool("should be disabled for element-1", w->disabled, true);
|
|
w = ui_get_widget("test-attr-disabled-2");
|
|
ctest_equal_bool("should be disabled for element-2", w->disabled, true);
|
|
w = ui_get_widget("test-attr-disabled-3");
|
|
ctest_equal_bool("should be disabled for element-3", w->disabled, true);
|
|
w = ui_get_widget("test-attr-disabled-4");
|
|
ctest_equal_bool("should not be disabled for element-4", w->disabled,
|
|
false);
|
|
}
|
|
|
|
static void check_widget_loaded_from_nested_xml(void)
|
|
{
|
|
ui_widget_t *w;
|
|
|
|
w = ui_get_widget("test-nested-1");
|
|
ctest_equal_bool("should exist for test-nested-1", w != NULL, true);
|
|
w = ui_get_widget("test-nested-2");
|
|
ctest_equal_bool("should exist for test-nested-2", w != NULL, true);
|
|
w = ui_get_widget("test-nested-3");
|
|
ctest_equal_bool("should exist for test-nested-3", w != NULL, true);
|
|
w = ui_get_widget("test-nested-4");
|
|
ctest_equal_bool("should exist for test-nested-4", w != NULL, true);
|
|
}
|
|
|
|
void test_ui_xml_parser(void)
|
|
{
|
|
ui_widget_t *pack;
|
|
|
|
ui_init();
|
|
ctest_equal_bool(
|
|
"should load XML file",
|
|
(pack = ui_load_xml_file("test_xml_parser.xml")) != NULL, true);
|
|
if (!pack) {
|
|
ui_destroy();
|
|
return;
|
|
}
|
|
ui_root_append(pack);
|
|
ui_widget_unwrap(pack);
|
|
ui_update();
|
|
ctest_describe("widget attribute", check_widget_attribute);
|
|
ctest_describe("widgets loaded from nested xml",
|
|
check_widget_loaded_from_nested_xml);
|
|
ui_destroy();
|
|
}
|