diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 23:41:31 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 23:41:31 +0300 |
| commit | 76073fe5fad8799e5850805f2f090af2cb62c741 (patch) | |
| tree | 9658019babe4760a3634bdab4da0731a10e42e68 /tests/test_api.cpp | |
| parent | dd1775a9927922c14f8679ccbc4d3ca8d5917e20 (diff) | |
Simplify the public event and CPU API
Applications now need far less ceremony: hello.c is a 20-line loop that
handles REFRESH, CLOSE and QUIT and draws into the surface's own pixels.
- Fold GEOMETRY, STATE and FOCUS into one WINDOW event carrying size,
scale and state; unchanged values send nothing.
- Guarantee REFRESH once a window has a size and after every resize,
never at size zero.
- Merge DROP_HOVER into DROP with over/leave/data actions and give drag
and drop actions enums.
- Keep event strings valid until the next wait and drop
yasl_event_release; empty or failed waits report NONE.
- Replace copy-in presentation with a lent pixel buffer:
yasl_cpu_pixels and yasl_cpu_present.
- Remove yasl_poll_event, yasl_cpu_read_pixels, unused event fields and
comments that restated names.
- Wayland: resize floating windows in request_size instead of reporting
it unsupported, and stop marking new GPU surfaces as Vulkan so
yasl_vulkan_create_surface no longer fails with NATIVE_WINDOW_IN_USE.
Also includes the in-progress public API refactor that was uncommitted
in the tree (removal of the app/loop layer, new surface, GL and Vulkan
entry points).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/test_api.cpp')
| -rw-r--r-- | tests/test_api.cpp | 95 |
1 files changed, 16 insertions, 79 deletions
diff --git a/tests/test_api.cpp b/tests/test_api.cpp index c5859cd..c0693eb 100644 --- a/tests/test_api.cpp +++ b/tests/test_api.cpp @@ -1,89 +1,26 @@ -#include "yasl/native.h" -#include "yasl/app.h" +#include <yasl/yasl.h> +#include <yasl/cpu.h> +#include <yasl/gl.h> +#include <yasl/metal.h> +#include <yasl/desktop.h> +#if YASL_HAS_VULKAN +#include <yasl/vulkan.h> +#endif #if YASL_HAS_WAYLAND -#include "yasl/native/wayland.h" +#include <yasl/native/wayland.h> #endif #if YASL_HAS_X11 -#include "yasl/native/x11.h" +#include <yasl/native/x11.h> #endif #if YASL_HAS_COCOA -#include "yasl/native/cocoa.h" +#include <yasl/native/cocoa.h> #endif -#include "yasl/desktop.h" -#include "yasl/loop.h" -#include <yasl/timing.h> -#include <yasl/yasl.h> #include <cassert> - int main() { - yasl_window_cbs callbacks{}; - yasl_window_spec window{}; - window.size = {640, 480}; - window.cbs = &callbacks; - window.ud = &window; - assert(!yasl_surface_create_toplevel(nullptr, &window)); - assert(!yasl_surface_create_native(nullptr, &window, &window)); - - yasl_timing timing = yasl_surface_timing(nullptr); - assert(timing.source == YASL_TIMING_UNKNOWN); - assert(yasl_scale_to_device(10.0, 240) == 20); - yasl_geometry geometry = yasl_surface_geometry(nullptr); - assert(geometry.scale_120 == YASL_SCALE_UNIT); - assert(!yasl_display_get_native_handle(nullptr)); - assert(!yasl_surface_get_native_handle(nullptr)); - yasl_native_frame native{}; - assert(!yasl_surface_get_native_frame(nullptr, nullptr, &native)); - - yasl_loop *loop = yasl_loop_create(); - assert(loop); - assert(yasl_loop_step(loop, 0) >= 0); - yasl_loop_destroy(loop); - - yasl_message message{}; - assert(!yasl_display_post(nullptr, &message)); - assert(!yasl_frame_present(nullptr, nullptr, 0)); - assert(!yasl_display_poll_event(nullptr, nullptr)); - assert(!yasl_surface_set_size(nullptr, {640, 480})); - assert(!yasl_surface_set_fullscreen(nullptr, true)); - assert(!yasl_surface_set_maximized(nullptr, true)); - assert(!yasl_surface_minimize(nullptr)); - assert(!yasl_surface_set_pacing(nullptr, YASL_PACING_CONTINUOUS)); - assert(!yasl_surface_set_callbacks(nullptr, nullptr, nullptr)); - assert(!yasl_clipboard_set(nullptr, YASL_CLIPBOARD, "")); - assert(!yasl_clipboard_request(nullptr, YASL_CLIPBOARD)); - assert(!yasl_app_window(nullptr)); - yasl_app_exit(nullptr, YASL_APP_ERROR); - - yasl_event event{}; - event.key.key = YASL_KEY_A; - assert(event.key.key == YASL_KEY_A); - event.pointer.scroll = {0.25, -0.5}; - assert(event.pointer.scroll.x == 0.25 && event.pointer.scroll.y == -0.5); - assert(!yasl_surface_poll_event(nullptr, &event)); - assert(!yasl_display_drag_start(nullptr, nullptr, nullptr, nullptr, nullptr)); - assert(!yasl_surface_drag_carry(nullptr, {0, 0})); - -#if YASL_HAS_WAYLAND - assert(!yasl_wayland_display_get_wl_display(nullptr)); - assert(!yasl_wayland_surface_get_wl_surface(nullptr)); -#endif - -#if YASL_HAS_X11 - assert(!yasl_x11_display_get_display(nullptr)); - assert(!yasl_x11_surface_get_window(nullptr)); -#endif - -#if YASL_HAS_COCOA - assert(!yasl_cocoa_display_get_application(nullptr)); - assert(!yasl_cocoa_surface_get_window(nullptr)); - assert(!yasl_cocoa_surface_get_view(nullptr)); -#endif - - assert(!yasl_display_open_uri(nullptr, "https://example.com")); - assert(yasl_display_appearance(nullptr) == 0); - assert(!yasl_surface_bell(nullptr)); - assert(yasl_executable_path(nullptr, 0) > 0); - - return 0; + yasl_event e{}; + e.pen.x=1.5;e.pen.pressure=0.25; + assert(e.pen.pressure==0.25); + assert(!yasl_surface_create("invalid",-1,10,0)); + yasl_shutdown();return 0; } |
