Files
LCUI/tests/scenes/scrollbar_scene.c
Liu faa7058837 test: reorganize test suite with xmake test integration
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.
2026-05-24 17:56:23 +08:00

82 lines
3.3 KiB
C

/*
* tests/scenes/scrollbar_scene.c
*
* Copyright (c) 2026, 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 <LCUI.h>
#include "scrollbar_scene.h"
static const char *scrollbar_scene_css = "\
.container {\
width: 300px;\
height: 240px;\
padding: 10px;\
margin: 20px auto 0 auto;\
border: 1px solid #eee;\
}\
\
text {\
white-space: nowrap;\
display: inline-block;\
}\
";
static const char *scrollbar_scene_content = "\n\
/* ***************************************************************************\n\
* test_scrollbar.c -- test scrollbar\n\
*\n\
* Copyright (c) 2021, Liu chao <lc-soft@live.cn> All rights reserved.\n\
*\n\
* Redistribution and use in source and binary forms, with or without\n\
* modification, are permitted provided that the following conditions are met:\n\
*\n\
* * Redistributions of source code must retain the above copyright notice,\n\
* this list of conditions and the following disclaimer.\n\
* * Redistributions in binary form must reproduce the above copyright\n\
* notice, this list of conditions and the following disclaimer in the\n\
* documentation and/or other materials provided with the distribution.\n\
* * Neither the name of LCUI nor the names of its contributors may be used\n\
* to endorse or promote products derived from this software without\n\
* specific prior written permission.\n\
*\n\
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n\
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n\
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n\
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n\
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n\
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n\
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n\
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n\
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n\
* POSSIBILITY OF SUCH DAMAGE.\n\
*/\n\
";
void scrollbar_scene_build(void)
{
ui_widget_t *container = ui_create_scrollarea();
ui_widget_t *content = ui_create_scrollarea_content();
ui_widget_t *text = ui_create_widget("text");
ui_widget_t *vscrollbar = ui_create_scrollbar();
ui_widget_t *hscrollbar = ui_create_scrollbar();
ui_widget_resize(ui_root(), 800, 640);
ui_load_css_string(scrollbar_scene_css, __FILE__);
ui_widget_set_id(content, "license_content");
ui_text_set_content(text, scrollbar_scene_content);
ui_scrollbar_set_orientation(hscrollbar, UI_SCROLLBAR_HORIZONTAL);
ui_widget_add_class(container, "container");
ui_widget_append(content, text);
ui_widget_append(container, content);
ui_widget_append(container, vscrollbar);
ui_widget_append(container, hscrollbar);
ui_root_append(container);
}