summaryrefslogtreecommitdiff
path: root/tests/test_lifecycle.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-14 13:56:48 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-14 13:56:48 +0300
commit87279f6903343e621c0446b20d1e7d6a495f1125 (patch)
tree999b5fb5fb76702efb02f856f082147304f0859b /tests/test_lifecycle.c
parent1ab3e5a123109704789c2768e11a4f9af515821d (diff)
Simplify the public API into one dense header
yasl.h now holds everything except Vulkan: 45 functions instead of 62, and three installed headers instead of ten. - One constructor: yasl_surface_create takes CPU, GL or NATIVE, with zero-initialized GL options meaning 3.2 core, RGBA8, D24S8. - Events carry action, mods, x, y and text at the top level; pen positions are now logical like pointer positions. - yasl_cpu_pixels/yasl_cpu_present draw into one persistent canvas, cutting three full-frame copies per frame. - yasl_surface_get_info, yasl_surface_request, YASL_CURSOR_LOCKED, yasl_surface_set_text_input, yasl_surface_begin_move_resize and yasl_surface_get_native replace groups of narrower calls. - Interactive calls drop the decorative trigger event argument. - yasl_wait_event returns 0 only on timeout or yasl_wake, the refresh callback runs only in native modal loops, focus loss sends INPUT_RESET, and a lost event no longer fails every later wait. - Unsupported operations and bad arguments report ENOTSUP and EINVAL instead of EIO; the keycodes header no longer needs C23. - The shared library gets a versioned SONAME and version macros. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/test_lifecycle.c')
-rw-r--r--tests/test_lifecycle.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/tests/test_lifecycle.c b/tests/test_lifecycle.c
index 08213b0..41dafe6 100644
--- a/tests/test_lifecycle.c
+++ b/tests/test_lifecycle.c
@@ -1,9 +1,6 @@
#include <yasl/yasl.h>
-#include <yasl/cpu.h>
-#include <yasl/gl.h>
-#include <yasl/metal.h>
-#include <yasl/desktop.h>
#include <assert.h>
+#include <string.h>
int main(void)
{
assert(yasl_shutdown() == 0);
@@ -11,27 +8,34 @@ int main(void)
yasl_event event = {.type = YASL_EVENT_QUIT};
assert(yasl_wait_event(&event, 0) == -ENODEV && event.type == YASL_EVENT_NONE);
assert(yasl_wait_event(NULL, 0) == -EINVAL);
- assert(yasl_init(&(struct yasl_options){.backend = (enum yasl_backend)999}) == -EINVAL);
+ assert(yasl_init((enum yasl_backend)999, NULL) == -EINVAL);
+ assert(yasl_get_backend() == YASL_BACKEND_AUTO && yasl_get_features() == 0);
assert(!yasl_surface_create(NULL) && errno == EINVAL);
struct yasl_surface_options options = {.width = 0, .height = 64};
assert(!yasl_surface_create(&options) && errno == EINVAL);
options.width = 64;
- options.flags = 16;
- assert(!yasl_surface_create(&options) && errno == EINVAL);
- options.flags = 0;
options.type = (enum yasl_surface_type)99;
assert(!yasl_surface_create(&options) && errno == EINVAL);
- struct yasl_cpu_buffer buffer = {.width = 9};
- assert(yasl_cpu_acquire(NULL, &buffer) == -ENODEV && !buffer.pixels && !buffer.width);
- assert(yasl_cpu_acquire(NULL, NULL) == -EINVAL);
- CAMetalLayer *layer = NULL;
- assert(yasl_metal_get_layer(NULL, &layer) == -ENODEV && !layer);
+ options.type = YASL_SURFACE_GL;
+ options.gl.major = 9;
+ assert(!yasl_surface_create(&options) && errno == EINVAL);
+ int w = 9, h = 9;
+ assert(!yasl_cpu_pixels(NULL, &w, &h) && errno == ENODEV && w == 0 && h == 0);
+ assert(yasl_cpu_present(NULL) == -ENODEV);
+ assert(!yasl_metal_get_layer(NULL) && errno == ENODEV);
+ struct yasl_native native = {.x11_window = 7};
+ assert(yasl_surface_get_native(NULL, &native) == -ENODEV && native.x11_window == 0);
assert(yasl_surface_destroy(NULL) == 0);
assert(yasl_time_ns() > 0);
- int w = 9, h = 9;
- yasl_surface_get_size(NULL, &w, &h);
- assert(w == 0 && h == 0);
- assert(yasl_get_executable_path(NULL, 0) > 0);
+ struct yasl_surface_info info = yasl_surface_get_info(NULL);
+ assert(info.width == 0 && info.pixel_height == 0 && info.scale == 1.0);
+ assert(yasl_gl_make_current(NULL) == 0);
+ assert(yasl_get_double_click_ms() == 400);
+ assert(yasl_get_system_string(YASL_EXECUTABLE_PATH, NULL, 0) > 0);
+ char locale[64];
+ size_t n = yasl_get_system_string(YASL_LOCALE, locale, sizeof(locale));
+ assert(n > 0 && n < sizeof(locale) && !strpbrk(locale, ".@"));
+ assert(yasl_get_system_string((enum yasl_system_string)9, locale, sizeof(locale)) == 0 && errno == EINVAL);
assert(yasl_shutdown() == 0);
return 0;
}