test: migrate examples to XXXX-category-name layout + split expected streams
Rename all example tests/companions to the XXXX-category-test-name scheme (per-category 100-blocks: basic 0010, types 0100, ... errors 1000, diagnostics 1100, ffi 1200, ffi-objc 1300, ffi-jni 1400, vectors 1500, platform 1600). Companions and dir/C fixtures move in lockstep with their parent test; #import/#source/#include paths rewritten to match. Expected output now lives in examples/expected/ (a sibling dir of the tests) split into three streams per the new convention: <name>.exit / <name>.stdout / <name>.stderr (+ optional <name>.ir) run_examples.sh rewritten: scans examples/ and issues/ for an expected/<name>.exit marker, captures stdout and stderr separately (no more 2>&1), compares each stream + exit + optional IR snapshot. Behavior validated unchanged: every renamed test reproduces its prior merged output + exit (diffs limited to file paths/basenames embedded in diagnostics + traces, which correctly reflect the new names). Suite: 292 passed, 0 failed. 50-smoke.sx split + issue relocation + docs follow in subsequent commits.
This commit is contained in:
96
examples/1610-platform-uikit-platform.sx
Normal file
96
examples/1610-platform-uikit-platform.sx
Normal file
@@ -0,0 +1,96 @@
|
||||
// UIKitPlatform end-to-end smoke: boots the AppDelegate, installs an
|
||||
// SxGLView with a CAEAGLLayer + GLES3 context + CADisplayLink, polls
|
||||
// UITouch events into ui.Event, and on every vsync clears the screen
|
||||
// to a color that advances on each tap. Each tap also toggles the
|
||||
// on-screen keyboard so safe_insets.bottom can be observed growing /
|
||||
// shrinking under it.
|
||||
//
|
||||
// To visualize the safe-area / keyboard inset, the frame draws a red
|
||||
// bar at the bottom whose height equals `safe_insets.bottom`. The
|
||||
// platform interpolates `keyboard_height` over the keyboard's own
|
||||
// animation duration, so the bar slides in lockstep with iOS's
|
||||
// keyboard.
|
||||
//
|
||||
// Build + run:
|
||||
// sx build --target ios-sim examples/66-uikit-platform.sx \
|
||||
// -o /tmp/SxUIKitBoot --bundle /tmp/SxUIKitBoot.app \
|
||||
// --bundle-id co.swipelab.sxuikit -F ~/Library/Frameworks
|
||||
// xcrun simctl install booted /tmp/SxUIKitBoot.app
|
||||
// xcrun simctl launch booted co.swipelab.sxuikit
|
||||
|
||||
#import "modules/std.sx";
|
||||
#import "modules/std/uikit.sx";
|
||||
#framework "OpenGLES";
|
||||
#framework "QuartzCore";
|
||||
#import "modules/opengl.sx";
|
||||
#import "modules/ui/types.sx";
|
||||
#import "modules/ui/events.sx";
|
||||
#import "modules/platform/uikit.sx";
|
||||
|
||||
GL_SCISSOR_TEST :u32: 0x0C11;
|
||||
glEnable_ : (u32) -> void = ---;
|
||||
glDisable_ : (u32) -> void = ---;
|
||||
glScissor_ : (s32, s32, s32, s32) -> void = ---;
|
||||
|
||||
g_color_index : s64 = 0;
|
||||
g_keyboard_up : bool = false;
|
||||
g_loaded : bool = false;
|
||||
|
||||
tap_frame :: () {
|
||||
fc := g_uikit_plat.begin_frame();
|
||||
|
||||
if !g_loaded {
|
||||
// Cache the GL fn-ptrs we use beyond what modules/opengl.sx loads.
|
||||
glEnable_ = xx ios_gl_proc("glEnable".ptr);
|
||||
glDisable_ = xx ios_gl_proc("glDisable".ptr);
|
||||
glScissor_ = xx ios_gl_proc("glScissor".ptr);
|
||||
g_loaded = true;
|
||||
}
|
||||
|
||||
events := g_uikit_plat.poll_events();
|
||||
i : s64 = 0;
|
||||
while i < events.len {
|
||||
ev := events.ptr[i];
|
||||
if ev == {
|
||||
case .mouse_down: {
|
||||
g_color_index += 1;
|
||||
if g_keyboard_up {
|
||||
g_uikit_plat.hide_keyboard();
|
||||
g_keyboard_up = false;
|
||||
} else {
|
||||
g_uikit_plat.show_keyboard();
|
||||
g_keyboard_up = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
phase := g_color_index % 3;
|
||||
r : f32 = if phase == 0 then 0.8 else 0.1;
|
||||
g : f32 = if phase == 1 then 0.8 else 0.1;
|
||||
b : f32 = if phase == 2 then 0.8 else 0.1;
|
||||
|
||||
glViewport(0, 0, fc.pixel_w, fc.pixel_h);
|
||||
glClearColor(r, g, b, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// Bottom bar = the interpolated safe-area bottom inset.
|
||||
insets := g_uikit_plat.safe_insets();
|
||||
bar_h_px : s32 = xx (insets.bottom * fc.dpi_scale);
|
||||
if bar_h_px > 0 {
|
||||
glEnable_(GL_SCISSOR_TEST);
|
||||
glScissor_(0, 0, fc.pixel_w, bar_h_px);
|
||||
glClearColor(0.95, 0.25, 0.25, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glDisable_(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
g_uikit_plat.end_frame();
|
||||
}
|
||||
|
||||
main :: () -> void {
|
||||
plat : *UIKitPlatform = xx malloc(size_of(UIKitPlatform));
|
||||
plat.init("SxUIKitPlatform", 0, 0);
|
||||
plat.run_frame_loop(closure(tap_frame));
|
||||
}
|
||||
Reference in New Issue
Block a user