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.
lcui-router
(English/中文)
Introduction
LCUI Router is the official router for LCUI. It provides a similar development experience to the Vue Router and make building multiple views applications with LCUI a breeze. Features include:
- Nested route/view mapping
- Modular, component-based router configuration
- Route params, query, wildcards
- Fine-grained navigation control
- Links with automatic active CSS classes
Getting Started
Note: We will using lcui-cli tool to manage the configuration and source code for the router.
Create an LCUI application project:
lcui create myapp
cd myapp
Overwrite the following code to the file app/assets/views/app.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<lcui-app>
<resource type="text/css" src="assets/stylesheets/app.css"/>
<ui>
<w>
<textview>Hello App!</textview>
<w>
<!-- use router-link component for navigation. -->
<!-- specify the link by passing the `to` prop. -->
<router-link to="/foo">Go to Foo</router-link>
<router-link to="/bar">Go to Bar</router-link>
</w>
<!-- route outlet -->
<!-- component matched by the route will render here -->
<router-view />
</w>
</ui>
</lcui-app>
Generate two widgets:
lcui generate widget foo
lcui generate widget bar
Save following code as file config/router.js:
module.exports = [
{ path: '/foo', component: 'foo' },
{ path: '/bar', component: 'bar' }
]
Compile config file for router:
lcui compile router
Run app:
lcpkg run start
For more examples, please see the lcui-router-app project.
Documentation
LCUI Router is referenced from Vue Router, so you can read the Vue Router documentation to learn about the basic usage of LCUI Router.