summaryrefslogtreecommitdiff
path: root/tests/cocoa
diff options
context:
space:
mode:
authorBerke Güzel <berke.guzel@gdh.digital>2026-10-14 09:38:31 +0300
committerBerke Güzel <berke.guzel@gdh.digital>2026-10-14 09:38:31 +0300
commit5ef6ca21ab9e1cf4f69254234d190a634b777d52 (patch)
tree974d3797a6d9487e54a811e224bf78a3f52dda85 /tests/cocoa
parent563b23a33726289387193b85d90fb569631ee05f (diff)
Remove deprecated Cocoa OpenGL and private compatibility APIs
Diffstat (limited to 'tests/cocoa')
-rw-r--r--tests/cocoa/display.m13
-rw-r--r--tests/cocoa/test_cursor.m2
-rw-r--r--tests/cocoa/test_keyboard.m9
-rw-r--r--tests/cocoa/test_native.c3
-rw-r--r--tests/cocoa/test_ownership.m22
-rw-r--r--tests/cocoa/test_tablet.m4
6 files changed, 29 insertions, 24 deletions
diff --git a/tests/cocoa/display.m b/tests/cocoa/display.m
new file mode 100644
index 0000000..0b2d9d8
--- /dev/null
+++ b/tests/cocoa/display.m
@@ -0,0 +1,13 @@
+#import <AppKit/AppKit.h>
+#include "common/private_native.h"
+
+@interface NSView (YaslTestDisplayLink)
+- (void)displayLinkFired:(id)link;
+@end
+
+/* Exercise the native CPU presenter without depending on the host's cadence. */
+void yasl_test_frame_tick(struct yasl_surface *surface)
+{
+ NSWindow *window = (NSWindow *)yasl_private_surface_get_native_handle(surface);
+ [window.contentView displayLinkFired:nil];
+}
diff --git a/tests/cocoa/test_cursor.m b/tests/cocoa/test_cursor.m
index 4c961df..b50ab55 100644
--- a/tests/cocoa/test_cursor.m
+++ b/tests/cocoa/test_cursor.m
@@ -39,7 +39,7 @@ int main(void)
assert([NSCursor currentCursor] == hidden);
struct yasl_private_event event;
bool moved = false;
- while (yasl_private_surface_poll_event(surface, &event))
+ while (yasl_private_display_poll_event(yasl_private_surface_display(surface), &event))
if (event.type == YASL_PRIVATE_EVENT_POINTER_MOTION)
moved = true;
assert(moved);
diff --git a/tests/cocoa/test_keyboard.m b/tests/cocoa/test_keyboard.m
index a41011c..a457a74 100644
--- a/tests/cocoa/test_keyboard.m
+++ b/tests/cocoa/test_keyboard.m
@@ -35,7 +35,7 @@
static struct yasl_private_event next(struct yasl_surface *surface, enum yasl_private_event_type type)
{
struct yasl_private_event event;
- assert(yasl_private_surface_poll_event(surface, &event));
+ assert(yasl_private_display_poll_event(yasl_private_surface_display(surface), &event));
assert(event.type == type && event.surface == surface);
return event;
}
@@ -43,7 +43,7 @@ static struct yasl_private_event next(struct yasl_surface *surface, enum yasl_pr
static void empty(struct yasl_surface *surface)
{
struct yasl_private_event event;
- assert(!yasl_private_surface_poll_event(surface, &event));
+ assert(!yasl_private_display_poll_event(yasl_private_surface_display(surface), &event));
}
int main(void)
@@ -65,7 +65,7 @@ int main(void)
NSWindow *window = (NSWindow *)yasl_private_surface_get_native_handle(surface);
NSView<NSTextInputClient> *view = (id)window.contentView;
struct yasl_private_event event;
- while (yasl_private_surface_poll_event(surface, &event)) {}
+ while (yasl_private_display_poll_event(yasl_private_surface_display(surface), &event)) {}
InputSample *sample = [InputSample new];
NSEvent *native = (NSEvent *)sample;
@@ -100,6 +100,8 @@ int main(void)
[view setMarkedText:@"é" selectedRange:NSMakeRange(1, 0)
replacementRange:NSMakeRange(1, 2)];
assert(strcmp(yasl_private_surface_ime_preedit(surface), "é") == 0);
+ event = next(surface, YASL_PRIVATE_EVENT_COMPOSITION);
+ assert(event.composition.active && !strcmp(event.composition.data, "é"));
empty(surface);
[view insertText:@"😀é" replacementRange:NSMakeRange(NSNotFound, 0)];
event = next(surface, YASL_PRIVATE_EVENT_TEXT_EDIT);
@@ -107,6 +109,7 @@ int main(void)
assert(event.text_edit.begin == 1 && event.text_edit.end == 5);
assert(event.text_edit.revision == 7 && event.text_edit.generation == 3);
assert(!yasl_private_surface_ime_preedit(surface));
+ assert(!next(surface, YASL_PRIVATE_EVENT_COMPOSITION).composition.active);
empty(surface);
/* Exercise the keyDown -> interpretKeyEvents -> insertText route with
diff --git a/tests/cocoa/test_native.c b/tests/cocoa/test_native.c
index 9b8f8fa..d26a89d 100644
--- a/tests/cocoa/test_native.c
+++ b/tests/cocoa/test_native.c
@@ -49,8 +49,9 @@ static void test_window(enum yasl_private_backend request, bool null_spec)
assert(state.display);
assert(yasl_private_display_backend(state.display) == YASL_PRIVATE_BACKEND_COCOA);
struct yasl_private_window_cbs callbacks = {.draw = draw};
+ /* Check real Metal draw/ownership without waiting for a display-link tick. */
struct yasl_private_window_spec surface = {
- .title = "Native backend test", .size = {160, 100},
+ .title = "Native backend test", .size = {160, 100}, .tearing = true,
.cbs = &callbacks, .ud = &state,
};
state.surface = yasl_private_surface_create_toplevel(state.display, &surface);
diff --git a/tests/cocoa/test_ownership.m b/tests/cocoa/test_ownership.m
index 4efd164..10aae99 100644
--- a/tests/cocoa/test_ownership.m
+++ b/tests/cocoa/test_ownership.m
@@ -3,6 +3,7 @@
#include "common/backend.h"
#import <AppKit/AppKit.h>
#import <Metal/Metal.h>
+#import <QuartzCore/QuartzCore.h>
#include "common/types.h"
#include <assert.h>
#include <errno.h>
@@ -41,16 +42,8 @@ int main(void)
assert(!hidden.isVisible && hidden.styleMask == NSWindowStyleMaskBorderless);
yasl_private_surface_destroy(gpu);
- struct yasl_surface *gl = d->ops->surface_create_gl(d, &gpu_spec, NULL, NULL);
- if (gl) {
- assert(gl->presenter == YASL_PRIVATE_PRESENTER_GL);
- assert(d->ops->gl_make_current(d, gl));
- assert(d->ops->gl_get_proc_address(d, "glClear") != NULL);
- assert(d->ops->gl_swap_interval(d, gl, 1));
- assert(d->ops->gl_swap_buffers(d, gl));
- assert(d->ops->gl_make_current(d, NULL));
- d->ops->surface_destroy(gl);
- }
+ assert(!d->ops->surface_create_gl && !d->ops->gl_make_current &&
+ !d->ops->gl_get_proc_address && !d->ops->gl_swap_interval && !d->ops->gl_swap_buffers);
assert(yasl_private_surface_set_size(s, (struct yasl_private_vector2i){180, 110}));
assert(yasl_private_surface_set_fullscreen(s, false));
@@ -58,7 +51,7 @@ int main(void)
assert(!yasl_private_surface_set_size(s, (struct yasl_private_vector2i){0, 100}));
assert(errno == EINVAL);
struct yasl_private_popup_spec popup_spec = {
- .positioner_explicit = true,
+
.anchor_edges = 4, .gravity = 3, .constraints = 63,
.size = {80, 40}, .anchor = {10, 10, 2, 2},
};
@@ -117,7 +110,7 @@ int main(void)
}
const char *last = event.paste.data;
assert(!yasl_private_display_poll_event(d, &event));
- @autoreleasepool { yasl_private_display_copy(d, YASL_PRIVATE_CLIPBOARD, "new selection"); }
+ @autoreleasepool { yasl_private_clipboard_set(d, YASL_PRIVATE_CLIPBOARD, "new selection"); }
assert(strcmp(last, "paste-599") == 0);
assert(!yasl_private_clipboard_set(d, YASL_PRIVATE_CLIPBOARD, "\xc3"));
assert(errno == EILSEQ);
@@ -131,11 +124,6 @@ int main(void)
assert(unavailable_id && yasl_private_display_poll_event(d, &event));
assert(event.type == YASL_PRIVATE_EVENT_PASTE && event.paste.request_id == unavailable_id);
assert(event.paste.status == YASL_PRIVATE_TRANSFER_UNAVAILABLE && !event.paste.len);
- yasl_private_display_copy(d, YASL_PRIVATE_CLIPBOARD, "legacy paste");
- yasl_private_display_paste(d, YASL_PRIVATE_CLIPBOARD, s);
- assert(yasl_private_display_poll_event(d, &event));
- assert(event.type == YASL_PRIVATE_EVENT_PASTE && event.paste.request_id == 0);
- assert(event.paste.status == YASL_PRIVATE_TRANSFER_OK && strcmp(event.text.data, "legacy paste") == 0);
yasl_private_surface_destroy(s);
yasl_private_display_close(d);
return 0;
diff --git a/tests/cocoa/test_tablet.m b/tests/cocoa/test_tablet.m
index 8eb63d5..5cd7375 100644
--- a/tests/cocoa/test_tablet.m
+++ b/tests/cocoa/test_tablet.m
@@ -46,7 +46,7 @@
static struct yasl_private_event next(struct yasl_surface *surface, enum yasl_private_event_type type)
{
struct yasl_private_event event;
- assert(yasl_private_surface_poll_event(surface, &event));
+ assert(yasl_private_display_poll_event(yasl_private_surface_display(surface), &event));
assert(event.type == type);
return event;
}
@@ -62,7 +62,7 @@ int main(void)
NSWindow *window = (NSWindow *)yasl_private_surface_get_native_handle(surface);
NSView *view = window.contentView;
struct yasl_private_event event;
- while (yasl_private_surface_poll_event(surface, &event)) {}
+ while (yasl_private_display_poll_event(yasl_private_surface_display(surface), &event)) {}
TabletSample *sample = [TabletSample new];
NSEvent *native = (NSEvent *)sample;
sample.type = NSEventTypeTabletProximity;