@native-sdk/cli 0.5.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/app.zig +41 -1
- package/build.zig +264 -3
- package/native-sdk.d.ts +17 -1
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/rt/rt.zig +138 -3
- package/packages/core/sdk/core.ts +225 -3
- package/packages/core/sdk/events.ts +39 -2
- package/packages/core/src/checker.ts +1 -1
- package/packages/core/src/emitter.ts +2625 -262
- package/packages/core/src/infer.ts +53 -7
- package/skill-data/automation/SKILL.md +7 -4
- package/skill-data/core/references/app-model-runtime.md +3 -0
- package/skill-data/native-ui/SKILL.md +4 -2
- package/skill-data/ts-core/SKILL.md +9 -1
- package/src/app_runner/root.zig +106 -1
- package/src/app_runner/ts_core_main.zig +4 -0
- package/src/automation/protocol.zig +20 -1
- package/src/embed/host.zig +27 -0
- package/src/embed/tests.zig +187 -0
- package/src/embed/ui_host.zig +4 -0
- package/src/platform/linux/gtk_host.c +112 -3
- package/src/platform/linux/root.zig +71 -0
- package/src/platform/macos/appkit_host.h +59 -2
- package/src/platform/macos/appkit_host.m +663 -34
- package/src/platform/macos/cef_host.mm +262 -10
- package/src/platform/macos/root.zig +126 -4
- package/src/platform/null_platform.zig +298 -5
- package/src/platform/null_platform_tests.zig +39 -0
- package/src/platform/root.zig +36 -0
- package/src/platform/types.zig +247 -8
- package/src/platform/windows/root.zig +134 -0
- package/src/platform/windows/webview2_host.cpp +152 -40
- package/src/primitives/app_manifest/comptime_scene.zig +5 -0
- package/src/primitives/app_manifest/root.zig +1 -0
- package/src/primitives/app_manifest/types.zig +32 -0
- package/src/primitives/canvas/chart.zig +7 -7
- package/src/primitives/canvas/chart_tests.zig +66 -0
- package/src/primitives/canvas/commands.zig +48 -0
- package/src/primitives/canvas/events.zig +161 -0
- package/src/primitives/canvas/font_ttf.zig +155 -8
- package/src/primitives/canvas/font_ttf_tests.zig +686 -0
- package/src/primitives/canvas/reference.zig +67 -8
- package/src/primitives/canvas/render_fingerprints.zig +8 -0
- package/src/primitives/canvas/root.zig +25 -0
- package/src/primitives/canvas/tests.zig +1 -0
- package/src/primitives/canvas/ui.zig +46 -9
- package/src/primitives/canvas/ui_markup.zig +82 -34
- package/src/primitives/canvas/ui_markup_binary.zig +4 -1
- package/src/primitives/canvas/ui_markup_binary_tests.zig +25 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +63 -11
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +88 -0
- package/src/primitives/canvas/ui_markup_contract.zig +10 -1
- package/src/primitives/canvas/ui_markup_contract_tests.zig +50 -0
- package/src/primitives/canvas/ui_markup_huge_document_tests.zig +154 -0
- package/src/primitives/canvas/ui_markup_tests.zig +55 -9
- package/src/primitives/canvas/ui_markup_view.zig +81 -14
- package/src/primitives/canvas/ui_markup_view_tests.zig +219 -7
- package/src/primitives/canvas/ui_schema.zig +29 -0
- package/src/primitives/canvas/ui_schema_tests.zig +11 -11
- package/src/primitives/canvas/ui_tests.zig +31 -0
- package/src/primitives/canvas/vector.zig +258 -141
- package/src/primitives/canvas/widget_access.zig +1 -1
- package/src/primitives/canvas/widget_builtin_tests.zig +129 -0
- package/src/primitives/canvas/widget_layout.zig +9 -4
- package/src/primitives/canvas/widget_render.zig +78 -40
- package/src/primitives/canvas/widget_render_controls.zig +15 -4
- package/src/primitives/canvas/widget_semantics.zig +6 -1
- package/src/primitives/canvas/widget_semantics_tests.zig +168 -0
- package/src/primitives/canvas/widget_text_input.zig +118 -10
- package/src/primitives/canvas/widgets.zig +16 -0
- package/src/root.zig +12 -0
- package/src/runtime/api.zig +15 -0
- package/src/runtime/automation_commands.zig +33 -0
- package/src/runtime/automation_widget_dispatch.zig +64 -0
- package/src/runtime/bridge_payload.zig +7 -0
- package/src/runtime/bridge_responses.zig +5 -0
- package/src/runtime/builtin_bridge.zig +9 -4
- package/src/runtime/canvas_font_tests.zig +711 -5
- package/src/runtime/canvas_fonts.zig +120 -25
- package/src/runtime/canvas_frame_helpers.zig +15 -0
- package/src/runtime/canvas_image_tests.zig +221 -0
- package/src/runtime/canvas_images.zig +78 -19
- package/src/runtime/canvas_limits.zig +44 -8
- package/src/runtime/canvas_widget_clipboard_tests.zig +123 -0
- package/src/runtime/canvas_widget_context_menu_tests.zig +55 -0
- package/src/runtime/canvas_widget_events.zig +24 -4
- package/src/runtime/canvas_widget_runtime.zig +24 -7
- package/src/runtime/canvas_widget_state.zig +6 -1
- package/src/runtime/canvas_widget_text_tests.zig +277 -0
- package/src/runtime/core.zig +148 -9
- package/src/runtime/effects.zig +1664 -43
- package/src/runtime/effects_fetch_tests.zig +89 -1
- package/src/runtime/effects_file_tests.zig +41 -1
- package/src/runtime/effects_image_tests.zig +1304 -0
- package/src/runtime/effects_tests.zig +153 -0
- package/src/runtime/flow.zig +44 -0
- package/src/runtime/gpu_surface_events.zig +7 -0
- package/src/runtime/media_surface.zig +726 -0
- package/src/runtime/media_surface_tests.zig +1476 -0
- package/src/runtime/root.zig +20 -0
- package/src/runtime/session_blobs.zig +689 -0
- package/src/runtime/session_journal.zig +111 -20
- package/src/runtime/session_record.zig +27 -2
- package/src/runtime/session_replay.zig +168 -16
- package/src/runtime/session_tests.zig +2118 -4
- package/src/runtime/shell_layout.zig +7 -0
- package/src/runtime/testdata/fonts/NotoSansSC-Receipt.ttf +0 -0
- package/src/runtime/testdata/fonts/OFL.txt +93 -0
- package/src/runtime/tests.zig +3 -0
- package/src/runtime/ts_core_host.zig +439 -4
- package/src/runtime/ts_core_host_tests.zig +41 -0
- package/src/runtime/ts_ui_app.zig +63 -0
- package/src/runtime/ui_app.zig +169 -6
- package/src/runtime/ui_app_tests.zig +334 -0
- package/src/runtime/ui_app_window_tests.zig +468 -0
- package/src/runtime/window_command_bridge_tests.zig +117 -0
- package/src/runtime/window_storage.zig +32 -0
- package/src/runtime/window_views.zig +61 -1
- package/src/tooling/manifest.zig +75 -0
- package/src/tooling/raw_manifest.zig +2 -0
- package/src/tooling/templates.zig +219 -1
|
@@ -594,6 +594,8 @@ const VerbMsg = union(enum) {
|
|
|
594
594
|
minimize_settings,
|
|
595
595
|
minimize_main,
|
|
596
596
|
close_settings,
|
|
597
|
+
show_settings,
|
|
598
|
+
quit,
|
|
597
599
|
settings_closed,
|
|
598
600
|
};
|
|
599
601
|
|
|
@@ -606,6 +608,8 @@ fn verbUpdate(model: *VerbModel, msg: VerbMsg, fx: *VerbApp.Effects) void {
|
|
|
606
608
|
// The imperative close, for the seam test — a real app's
|
|
607
609
|
// model-declared window usually closes declaratively instead.
|
|
608
610
|
.close_settings => fx.closeWindow(settings_window_label),
|
|
611
|
+
.show_settings => fx.showWindow(settings_window_label),
|
|
612
|
+
.quit => fx.quitApp(),
|
|
609
613
|
.settings_closed => model.settings_open = false,
|
|
610
614
|
}
|
|
611
615
|
}
|
|
@@ -692,6 +696,14 @@ test "window-action effects resolve labels to live windows and drive the real ve
|
|
|
692
696
|
if (info.id == settings_id) try std.testing.expect(info.open);
|
|
693
697
|
}
|
|
694
698
|
|
|
699
|
+
// Show by label is the counterpart verb: it reaches the platform's
|
|
700
|
+
// show (the minimized window comes back with focus) and the mirror
|
|
701
|
+
// counts it.
|
|
702
|
+
try app_state.dispatch(&harness.runtime, 1, .show_settings);
|
|
703
|
+
try std.testing.expectEqual(@as(u32, 1), harness.null_platform.showCountForWindow(settings_id));
|
|
704
|
+
try std.testing.expectEqual(@as(u32, 1), app_state.effects.windowActionState().show_count);
|
|
705
|
+
try std.testing.expectEqualStrings(settings_window_label, app_state.effects.windowActionState().lastLabel());
|
|
706
|
+
|
|
695
707
|
// The main window resolves by label too (the runtime adopted the
|
|
696
708
|
// host-reported startup window above). The fake host never created
|
|
697
709
|
// a native window for it — live hosts own the startup window — so
|
|
@@ -714,4 +726,460 @@ test "window-action effects resolve labels to live windows and drive the real ve
|
|
|
714
726
|
// main window still answers after the secondary's churn.
|
|
715
727
|
try app_state.dispatch(&harness.runtime, 1, .minimize_main);
|
|
716
728
|
try std.testing.expectEqual(@as(u32, 3), app_state.effects.windowActionState().minimize_count);
|
|
729
|
+
|
|
730
|
+
// quitApp asks the platform for the graceful terminate (the modeled
|
|
731
|
+
// host records the request; a real host QUEUES the stop so
|
|
732
|
+
// app_shutdown emits on the next loop turn, after this dispatch
|
|
733
|
+
// has returned) and the mirror counts it.
|
|
734
|
+
try app_state.dispatch(&harness.runtime, 1, .quit);
|
|
735
|
+
try std.testing.expectEqual(@as(u32, 1), app_state.effects.windowActionState().quit_count);
|
|
736
|
+
try std.testing.expectEqual(@as(u32, 1), harness.null_platform.quit_request_count);
|
|
737
|
+
// The host's queued shutdown echo delivers the exactly-once stop
|
|
738
|
+
// hook — the same path a last-window close takes. Draining it here
|
|
739
|
+
// IS the next loop turn, and it drains exactly once.
|
|
740
|
+
const shutdown_event = harness.null_platform.takeQueuedQuit() orelse return error.TestUnexpectedResult;
|
|
741
|
+
try std.testing.expect(harness.null_platform.takeQueuedQuit() == null);
|
|
742
|
+
try harness.runtime.dispatchPlatformEvent(app, shutdown_event);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
test "the .hide close then showWindow round-trip: tray Open brings the hidden window back" {
|
|
746
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
747
|
+
defer harness.destroy(std.testing.allocator);
|
|
748
|
+
harness.null_platform.gpu_surfaces = true;
|
|
749
|
+
const app_state = try VerbApp.create(std.heap.page_allocator, .{
|
|
750
|
+
.name = "ui-app-hide-show-loop",
|
|
751
|
+
.scene = panel_scene,
|
|
752
|
+
.canvas_label = canvas_label,
|
|
753
|
+
.update_fx = verbUpdate,
|
|
754
|
+
.view = verbView,
|
|
755
|
+
.windows_fn = verbWindows,
|
|
756
|
+
.window_view = verbWindowView,
|
|
757
|
+
});
|
|
758
|
+
defer app_state.destroy();
|
|
759
|
+
const app = app_state.app();
|
|
760
|
+
try harness.start(app);
|
|
761
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
762
|
+
.label = canvas_label,
|
|
763
|
+
.size = geometry.SizeF.init(400, 300),
|
|
764
|
+
.scale_factor = 2,
|
|
765
|
+
.frame_index = 1,
|
|
766
|
+
.timestamp_ns = 1_000_000,
|
|
767
|
+
.nonblank = true,
|
|
768
|
+
} });
|
|
769
|
+
var buffer: [support.platform.max_windows]support.platform.WindowInfo = undefined;
|
|
770
|
+
var settings_id: support.platform.WindowId = 0;
|
|
771
|
+
for (harness.runtime.listWindows(&buffer)) |info| {
|
|
772
|
+
if (std.mem.eql(u8, info.label, settings_window_label)) settings_id = info.id;
|
|
773
|
+
}
|
|
774
|
+
try std.testing.expect(settings_id != 0);
|
|
775
|
+
|
|
776
|
+
// Give the live window the .hide policy at the platform (the seam a
|
|
777
|
+
// manifest declaration rides) and close it as the user: hidden, not
|
|
778
|
+
// gone.
|
|
779
|
+
for (harness.null_platform.windows[0..harness.null_platform.window_count], 0..) |window, index| {
|
|
780
|
+
if (window.id == settings_id) harness.null_platform.window_close_policy[index] = .hide;
|
|
781
|
+
}
|
|
782
|
+
const hide_event = harness.null_platform.userCloseWindow(settings_id).?;
|
|
783
|
+
try harness.runtime.dispatchPlatformEvent(app, hide_event);
|
|
784
|
+
for (harness.runtime.listWindows(&buffer)) |info| {
|
|
785
|
+
if (info.id == settings_id) try std.testing.expect(info.hidden);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// The tray "Open" consequence: the model returns the show verb, the
|
|
789
|
+
// label resolves against the still-open hidden window, and the
|
|
790
|
+
// platform + runtime state both flip back.
|
|
791
|
+
try app_state.dispatch(&harness.runtime, 1, .show_settings);
|
|
792
|
+
try std.testing.expectEqual(@as(u32, 1), harness.null_platform.showCountForWindow(settings_id));
|
|
793
|
+
for (harness.runtime.listWindows(&buffer)) |info| {
|
|
794
|
+
if (info.id == settings_id) try std.testing.expect(!info.hidden);
|
|
795
|
+
}
|
|
796
|
+
for (harness.null_platform.windows[0..harness.null_platform.window_count]) |window| {
|
|
797
|
+
if (window.id == settings_id) {
|
|
798
|
+
try std.testing.expect(!window.hidden);
|
|
799
|
+
try std.testing.expect(window.focused);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
// ------------------------------------- close_policy (.quit | .hide)
|
|
805
|
+
|
|
806
|
+
test "close_policy .hide: the user close hides the window, nothing tears down, and the reopen re-shows it" {
|
|
807
|
+
const fixture = try Fixture.create();
|
|
808
|
+
defer fixture.destroy();
|
|
809
|
+
|
|
810
|
+
// A menu-bar-shaped window through the REAL create seam (the same
|
|
811
|
+
// `ShellWindow` path a manifest-declared window rides): the
|
|
812
|
+
// declared policy must survive to the platform.
|
|
813
|
+
const info = try fixture.harness.runtime.createSourcelessShellWindow(.{
|
|
814
|
+
.label = "player",
|
|
815
|
+
.title = "Player",
|
|
816
|
+
.width = 400,
|
|
817
|
+
.height = 300,
|
|
818
|
+
.close_policy = .hide,
|
|
819
|
+
});
|
|
820
|
+
try std.testing.expectEqual(support.platform.WindowClosePolicy.hide, fixture.harness.null_platform.closePolicyForWindow(info.id).?);
|
|
821
|
+
|
|
822
|
+
// The user clicks the red button: the modeled close delegate hides
|
|
823
|
+
// instead of closing — the window stays in the host's records
|
|
824
|
+
// (open = true), only the hidden flag flips, and because open never
|
|
825
|
+
// transitioned, NO window_closed app event (and so no on_close Msg)
|
|
826
|
+
// fires.
|
|
827
|
+
const hide_event = fixture.harness.null_platform.userCloseWindow(info.id).?;
|
|
828
|
+
try std.testing.expect(hide_event.window_frame_changed.open);
|
|
829
|
+
try std.testing.expect(hide_event.window_frame_changed.hidden);
|
|
830
|
+
try fixture.harness.runtime.dispatchPlatformEvent(fixture.app, hide_event);
|
|
831
|
+
try std.testing.expectEqual(@as(u32, 0), fixture.app_state.model.user_closes);
|
|
832
|
+
var buffer: [support.platform.max_windows]support.platform.WindowInfo = undefined;
|
|
833
|
+
for (fixture.harness.runtime.listWindows(&buffer)) |window| {
|
|
834
|
+
if (window.id != info.id) continue;
|
|
835
|
+
try std.testing.expect(window.open);
|
|
836
|
+
try std.testing.expect(window.hidden);
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
// The Dock-icon reopen: every policy-hidden window re-shows and the
|
|
840
|
+
// hidden flag clears through the same journaled frame channel.
|
|
841
|
+
var reopen_buffer: [support.platform.max_windows]support.platform.Event = undefined;
|
|
842
|
+
const reopen_events = fixture.harness.null_platform.userReopenApp(&reopen_buffer);
|
|
843
|
+
try std.testing.expectEqual(@as(usize, 1), reopen_events.len);
|
|
844
|
+
try std.testing.expect(!reopen_events[0].window_frame_changed.hidden);
|
|
845
|
+
for (reopen_events) |event| try fixture.harness.runtime.dispatchPlatformEvent(fixture.app, event);
|
|
846
|
+
for (fixture.harness.runtime.listWindows(&buffer)) |window| {
|
|
847
|
+
if (window.id != info.id) continue;
|
|
848
|
+
try std.testing.expect(window.open);
|
|
849
|
+
try std.testing.expect(!window.hidden);
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
// A reopen with nothing hidden is honestly empty — the host's
|
|
853
|
+
// default reopen behavior stays in charge.
|
|
854
|
+
try std.testing.expectEqual(@as(usize, 0), fixture.harness.null_platform.userReopenApp(&reopen_buffer).len);
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
test "an app-driven close of a policy-hidden window clears hidden with open, and rolls it back on platform failure" {
|
|
858
|
+
const fixture = try Fixture.create();
|
|
859
|
+
defer fixture.destroy();
|
|
860
|
+
|
|
861
|
+
// A menu-bar-shaped window through the REAL create seam, hidden by
|
|
862
|
+
// its .hide close policy (the user clicked the red button).
|
|
863
|
+
const info = try fixture.harness.runtime.createSourcelessShellWindow(.{
|
|
864
|
+
.label = "player",
|
|
865
|
+
.title = "Player",
|
|
866
|
+
.width = 400,
|
|
867
|
+
.height = 300,
|
|
868
|
+
.close_policy = .hide,
|
|
869
|
+
});
|
|
870
|
+
const hide_event = fixture.harness.null_platform.userCloseWindow(info.id).?;
|
|
871
|
+
try fixture.harness.runtime.dispatchPlatformEvent(fixture.app, hide_event);
|
|
872
|
+
var buffer: [support.platform.max_windows]support.platform.WindowInfo = undefined;
|
|
873
|
+
for (fixture.harness.runtime.listWindows(&buffer)) |window| {
|
|
874
|
+
if (window.id != info.id) continue;
|
|
875
|
+
try std.testing.expect(window.open);
|
|
876
|
+
try std.testing.expect(window.hidden);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
// The platform refuses the close: EVERY optimistically flipped flag
|
|
880
|
+
// rolls back — the window is still open, still policy-hidden.
|
|
881
|
+
fixture.harness.null_platform.fail_next_close_window = true;
|
|
882
|
+
try std.testing.expectError(error.CloseFailed, fixture.harness.runtime.closeWindow(info.id));
|
|
883
|
+
for (fixture.harness.runtime.listWindows(&buffer)) |window| {
|
|
884
|
+
if (window.id != info.id) continue;
|
|
885
|
+
try std.testing.expect(window.open);
|
|
886
|
+
try std.testing.expect(window.hidden);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
// The app closes its hidden window for real: a closed window is not
|
|
890
|
+
// "hidden", it is gone — the runtime table (the JS bridge's window
|
|
891
|
+
// list) must read {open=false, hidden=false}, never a closed window
|
|
892
|
+
// still flying the hidden flag.
|
|
893
|
+
try fixture.harness.runtime.closeWindow(info.id);
|
|
894
|
+
var found = false;
|
|
895
|
+
for (fixture.harness.runtime.listWindows(&buffer)) |window| {
|
|
896
|
+
if (window.id != info.id) continue;
|
|
897
|
+
found = true;
|
|
898
|
+
try std.testing.expect(!window.open);
|
|
899
|
+
try std.testing.expect(!window.hidden);
|
|
900
|
+
try std.testing.expect(!window.focused);
|
|
901
|
+
}
|
|
902
|
+
try std.testing.expect(found);
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
test "showWindow activates: the shown window takes key in the runtime table, and a refused show moves nothing" {
|
|
906
|
+
const fixture = try Fixture.create();
|
|
907
|
+
defer fixture.destroy();
|
|
908
|
+
|
|
909
|
+
// A policy-hidden window (the user's close under .hide).
|
|
910
|
+
const info = try fixture.harness.runtime.createSourcelessShellWindow(.{
|
|
911
|
+
.label = "player",
|
|
912
|
+
.title = "Player",
|
|
913
|
+
.width = 400,
|
|
914
|
+
.height = 300,
|
|
915
|
+
.close_policy = .hide,
|
|
916
|
+
});
|
|
917
|
+
const hide_event = fixture.harness.null_platform.userCloseWindow(info.id).?;
|
|
918
|
+
try fixture.harness.runtime.dispatchPlatformEvent(fixture.app, hide_event);
|
|
919
|
+
|
|
920
|
+
// The show verb's contract is show AND activate — every host's show
|
|
921
|
+
// path makes the window key. After a successful platform show, the
|
|
922
|
+
// runtime table (what listWindows and the JS bridge serve) must
|
|
923
|
+
// read the shown window focused and every other window unfocused,
|
|
924
|
+
// not a frontmost window still reported keyless.
|
|
925
|
+
try fixture.harness.runtime.showWindow(info.id);
|
|
926
|
+
var buffer: [support.platform.max_windows]support.platform.WindowInfo = undefined;
|
|
927
|
+
var found = false;
|
|
928
|
+
for (fixture.harness.runtime.listWindows(&buffer)) |window| {
|
|
929
|
+
if (window.id == info.id) {
|
|
930
|
+
found = true;
|
|
931
|
+
try std.testing.expect(!window.hidden);
|
|
932
|
+
try std.testing.expect(window.focused);
|
|
933
|
+
} else {
|
|
934
|
+
try std.testing.expect(!window.focused);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
try std.testing.expect(found);
|
|
938
|
+
|
|
939
|
+
// Hide again, then refuse the show at the platform: hidden rolls
|
|
940
|
+
// back and focus does not move — a refused show must never report
|
|
941
|
+
// a focused window that never came back to the glass.
|
|
942
|
+
const rehide_event = fixture.harness.null_platform.userCloseWindow(info.id).?;
|
|
943
|
+
try fixture.harness.runtime.dispatchPlatformEvent(fixture.app, rehide_event);
|
|
944
|
+
fixture.harness.null_platform.fail_next_show_window = true;
|
|
945
|
+
try std.testing.expectError(error.ShowFailed, fixture.harness.runtime.showWindow(info.id));
|
|
946
|
+
for (fixture.harness.runtime.listWindows(&buffer)) |window| {
|
|
947
|
+
if (window.id != info.id) continue;
|
|
948
|
+
try std.testing.expect(window.hidden);
|
|
949
|
+
try std.testing.expect(!window.focused);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
test "the window verbs refuse a retained closed slot: show, focus, and minimize answer WindowNotFound with no platform call" {
|
|
954
|
+
const fixture = try Fixture.create();
|
|
955
|
+
defer fixture.destroy();
|
|
956
|
+
|
|
957
|
+
// A closed window keeps its table slot (the id and label release
|
|
958
|
+
// lazily, at the next create), so resolving the id is not liveness.
|
|
959
|
+
// Without the open gate the null platform accepts the verbs and
|
|
960
|
+
// reports {open:false, focused:true}, and the CEF host — which
|
|
961
|
+
// retains browser-bearing windows past their close — would visibly
|
|
962
|
+
// re-order the closed window onto the glass. The runtime gate holds
|
|
963
|
+
// independent of host timing.
|
|
964
|
+
const info = try fixture.harness.runtime.createSourcelessShellWindow(.{
|
|
965
|
+
.label = "player",
|
|
966
|
+
.title = "Player",
|
|
967
|
+
.width = 400,
|
|
968
|
+
.height = 300,
|
|
969
|
+
.close_policy = .hide,
|
|
970
|
+
});
|
|
971
|
+
try fixture.harness.runtime.closeWindow(info.id);
|
|
972
|
+
|
|
973
|
+
// show: the dead-slot answer, and the platform recorder never moves.
|
|
974
|
+
try std.testing.expectError(error.WindowNotFound, fixture.harness.runtime.showWindow(info.id));
|
|
975
|
+
try std.testing.expectEqual(@as(u32, 0), fixture.harness.null_platform.showCountForWindow(info.id));
|
|
976
|
+
|
|
977
|
+
// focus resolves by id too, and close cleared `hidden` with `open`,
|
|
978
|
+
// so without its own gate it skips the hidden-routing and reaches
|
|
979
|
+
// the platform's focus verb directly.
|
|
980
|
+
try std.testing.expectError(error.WindowNotFound, fixture.harness.runtime.focusWindow(info.id));
|
|
981
|
+
try std.testing.expectEqual(@as(u32, 0), fixture.harness.null_platform.showCountForWindow(info.id));
|
|
982
|
+
|
|
983
|
+
// The minimize twin (the CEF host would genie the retained closed
|
|
984
|
+
// window into the Dock).
|
|
985
|
+
try std.testing.expectError(error.WindowNotFound, fixture.harness.runtime.minimizeWindow(info.id));
|
|
986
|
+
try std.testing.expectEqual(@as(u32, 0), fixture.harness.null_platform.minimizeCountForWindow(info.id));
|
|
987
|
+
|
|
988
|
+
// Nothing resurrected: the runtime table and the platform mirror
|
|
989
|
+
// both still read the window closed, unfocused, un-hidden.
|
|
990
|
+
var buffer: [support.platform.max_windows]support.platform.WindowInfo = undefined;
|
|
991
|
+
var found = false;
|
|
992
|
+
for (fixture.harness.runtime.listWindows(&buffer)) |window| {
|
|
993
|
+
if (window.id != info.id) continue;
|
|
994
|
+
found = true;
|
|
995
|
+
try std.testing.expect(!window.open);
|
|
996
|
+
try std.testing.expect(!window.focused);
|
|
997
|
+
try std.testing.expect(!window.hidden);
|
|
998
|
+
}
|
|
999
|
+
try std.testing.expect(found);
|
|
1000
|
+
for (fixture.harness.null_platform.windows[0..fixture.harness.null_platform.window_count]) |window| {
|
|
1001
|
+
if (window.id != info.id) continue;
|
|
1002
|
+
try std.testing.expect(!window.open);
|
|
1003
|
+
try std.testing.expect(!window.focused);
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
test "the modeled host mirrors the app close of a hidden window, and the reopen never resurrects a closed one" {
|
|
1008
|
+
const fixture = try Fixture.create();
|
|
1009
|
+
defer fixture.destroy();
|
|
1010
|
+
|
|
1011
|
+
// A menu-bar-shaped window, policy-hidden by the user's close.
|
|
1012
|
+
const info = try fixture.harness.runtime.createSourcelessShellWindow(.{
|
|
1013
|
+
.label = "player",
|
|
1014
|
+
.title = "Player",
|
|
1015
|
+
.width = 400,
|
|
1016
|
+
.height = 300,
|
|
1017
|
+
.close_policy = .hide,
|
|
1018
|
+
});
|
|
1019
|
+
const hide_event = fixture.harness.null_platform.userCloseWindow(info.id).?;
|
|
1020
|
+
try fixture.harness.runtime.dispatchPlatformEvent(fixture.app, hide_event);
|
|
1021
|
+
|
|
1022
|
+
// The app closes the hidden window through the runtime. The modeled
|
|
1023
|
+
// host's mirror must read closed AND un-hidden — the same
|
|
1024
|
+
// hidden-clears-with-open rule the real hosts' close paths carry
|
|
1025
|
+
// (set cleanup before the open=false emit) and the runtime table
|
|
1026
|
+
// already pins for its own flags.
|
|
1027
|
+
try fixture.harness.runtime.closeWindow(info.id);
|
|
1028
|
+
for (fixture.harness.null_platform.windows[0..fixture.harness.null_platform.window_count]) |window| {
|
|
1029
|
+
if (window.id != info.id) continue;
|
|
1030
|
+
try std.testing.expect(!window.open);
|
|
1031
|
+
try std.testing.expect(!window.hidden);
|
|
1032
|
+
try std.testing.expect(!window.focused);
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
// The Dock reopen after the close: NO frame event for the closed
|
|
1036
|
+
// window — nothing hidden-and-open remains to re-show.
|
|
1037
|
+
var reopen_buffer: [support.platform.max_windows]support.platform.Event = undefined;
|
|
1038
|
+
try std.testing.expectEqual(@as(usize, 0), fixture.harness.null_platform.userReopenApp(&reopen_buffer).len);
|
|
1039
|
+
|
|
1040
|
+
// The reopen's liveness check must hold on its own, not lean on the
|
|
1041
|
+
// close mirror's hidden clear: model a host whose close path forgot
|
|
1042
|
+
// that cleanup by forcing the stale flag onto the closed slot — the
|
|
1043
|
+
// reopen still refuses to resurrect (hidden alone is not liveness).
|
|
1044
|
+
for (fixture.harness.null_platform.windows[0..fixture.harness.null_platform.window_count]) |*window| {
|
|
1045
|
+
if (window.id == info.id) window.hidden = true;
|
|
1046
|
+
}
|
|
1047
|
+
try std.testing.expectEqual(@as(usize, 0), fixture.harness.null_platform.userReopenApp(&reopen_buffer).len);
|
|
1048
|
+
|
|
1049
|
+
// No events dispatched, so the runtime table is untouched: the
|
|
1050
|
+
// window stays closed, un-hidden, never re-focused.
|
|
1051
|
+
var buffer: [support.platform.max_windows]support.platform.WindowInfo = undefined;
|
|
1052
|
+
var found = false;
|
|
1053
|
+
for (fixture.harness.runtime.listWindows(&buffer)) |window| {
|
|
1054
|
+
if (window.id != info.id) continue;
|
|
1055
|
+
found = true;
|
|
1056
|
+
try std.testing.expect(!window.open);
|
|
1057
|
+
try std.testing.expect(!window.hidden);
|
|
1058
|
+
try std.testing.expect(!window.focused);
|
|
1059
|
+
}
|
|
1060
|
+
try std.testing.expect(found);
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
test "focus-while-hidden routes through the show verb: hidden clears before the window takes key" {
|
|
1064
|
+
const fixture = try Fixture.create();
|
|
1065
|
+
defer fixture.destroy();
|
|
1066
|
+
|
|
1067
|
+
const info = try fixture.harness.runtime.createSourcelessShellWindow(.{
|
|
1068
|
+
.label = "player",
|
|
1069
|
+
.title = "Player",
|
|
1070
|
+
.width = 400,
|
|
1071
|
+
.height = 300,
|
|
1072
|
+
.close_policy = .hide,
|
|
1073
|
+
});
|
|
1074
|
+
|
|
1075
|
+
// The user close hides the window (policy .hide) and the runtime
|
|
1076
|
+
// adopts the hidden state off the journaled frame channel.
|
|
1077
|
+
const hide_event = fixture.harness.null_platform.userCloseWindow(info.id).?;
|
|
1078
|
+
try fixture.harness.runtime.dispatchPlatformEvent(fixture.app, hide_event);
|
|
1079
|
+
var buffer: [support.platform.max_windows]support.platform.WindowInfo = undefined;
|
|
1080
|
+
for (fixture.harness.runtime.listWindows(&buffer)) |window| {
|
|
1081
|
+
if (window.id == info.id) try std.testing.expect(window.hidden);
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
// Focusing the hidden window must drive the platform's SHOW verb
|
|
1085
|
+
// (the path that clears the hosts' policy-hidden bookkeeping and
|
|
1086
|
+
// emits consistent state), not just its focus verb: the hidden
|
|
1087
|
+
// flag clears, focus lands, and the show count pins the routing —
|
|
1088
|
+
// a focusWindow that skips the show seam leaves this count at 0
|
|
1089
|
+
// and the window reported hidden while standing on the glass.
|
|
1090
|
+
try fixture.harness.runtime.focusWindow(info.id);
|
|
1091
|
+
try std.testing.expectEqual(@as(u32, 1), fixture.harness.null_platform.showCountForWindow(info.id));
|
|
1092
|
+
for (fixture.harness.runtime.listWindows(&buffer)) |window| {
|
|
1093
|
+
if (window.id != info.id) continue;
|
|
1094
|
+
try std.testing.expect(window.open);
|
|
1095
|
+
try std.testing.expect(!window.hidden);
|
|
1096
|
+
try std.testing.expect(window.focused);
|
|
1097
|
+
}
|
|
1098
|
+
// The platform mirror agrees on both flags.
|
|
1099
|
+
for (fixture.harness.null_platform.windows[0..fixture.harness.null_platform.window_count]) |window| {
|
|
1100
|
+
if (window.id != info.id) continue;
|
|
1101
|
+
try std.testing.expect(!window.hidden);
|
|
1102
|
+
try std.testing.expect(window.focused);
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
// A visible window's focus stays a plain focus: no second show.
|
|
1106
|
+
try fixture.harness.runtime.focusWindow(info.id);
|
|
1107
|
+
try std.testing.expectEqual(@as(u32, 1), fixture.harness.null_platform.showCountForWindow(info.id));
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
test "close_policy default stays .quit: the user close still tears the window down" {
|
|
1111
|
+
const fixture = try Fixture.create();
|
|
1112
|
+
defer fixture.destroy();
|
|
1113
|
+
|
|
1114
|
+
try fixture.clickSettingsButton();
|
|
1115
|
+
const info = fixture.settingsWindowInfo() orelse return error.TestUnexpectedResult;
|
|
1116
|
+
// No declaration means .quit: the capture proves the default rode
|
|
1117
|
+
// the create seam unchanged.
|
|
1118
|
+
try std.testing.expectEqual(support.platform.WindowClosePolicy.quit, fixture.harness.null_platform.closePolicyForWindow(info.id).?);
|
|
1119
|
+
const close_event = fixture.harness.null_platform.userCloseWindow(info.id).?;
|
|
1120
|
+
try std.testing.expect(!close_event.window_frame_changed.open);
|
|
1121
|
+
try std.testing.expect(!close_event.window_frame_changed.hidden);
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
test "close_policy .hide is refused loudly at create on hosts without the affordance" {
|
|
1125
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
1126
|
+
defer harness.destroy(std.testing.allocator);
|
|
1127
|
+
// Model a GTK-shaped host: no status item, no way to bring a
|
|
1128
|
+
// hidden window back — the feature reports false and window create
|
|
1129
|
+
// refuses the declaration instead of stranding the window.
|
|
1130
|
+
harness.null_platform.window_hide_on_close = false;
|
|
1131
|
+
try std.testing.expectError(error.UnsupportedWindowClosePolicy, harness.runtime.createSourcelessShellWindow(.{
|
|
1132
|
+
.label = "tools",
|
|
1133
|
+
.title = "Tools",
|
|
1134
|
+
.width = 320,
|
|
1135
|
+
.height = 240,
|
|
1136
|
+
.close_policy = .hide,
|
|
1137
|
+
}));
|
|
1138
|
+
// The same shape under .quit (the default) creates fine.
|
|
1139
|
+
const info = try harness.runtime.createSourcelessShellWindow(.{
|
|
1140
|
+
.label = "tools",
|
|
1141
|
+
.title = "Tools",
|
|
1142
|
+
.width = 320,
|
|
1143
|
+
.height = 240,
|
|
1144
|
+
});
|
|
1145
|
+
try std.testing.expect(info.open);
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
test "close_policy .hide on a secondary startup window is refused loudly at startup load on hosts without the affordance" {
|
|
1149
|
+
const SourceApp = struct {
|
|
1150
|
+
fn app(self: *@This()) support.App {
|
|
1151
|
+
return .{ .context = self, .name = "startup-hide", .source = support.platform.WebViewSource.html("<p>Startup</p>") };
|
|
1152
|
+
}
|
|
1153
|
+
};
|
|
1154
|
+
const startup_windows = [_]support.platform.WindowOptions{
|
|
1155
|
+
.{ .id = 1, .label = "main", .title = "Main" },
|
|
1156
|
+
.{ .id = 2, .label = "panel", .title = "Panel", .close_policy = .hide },
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1159
|
+
// Model a GTK-shaped host: the feature reports false, and the
|
|
1160
|
+
// startup-window load — which creates secondary windows through
|
|
1161
|
+
// the platform services directly, not the runtime's createWindow —
|
|
1162
|
+
// must refuse the secondary window's `.hide` declaration with the
|
|
1163
|
+
// same loud error as the create seam. A silent accept here means
|
|
1164
|
+
// the host ignores the policy and the user's close really closes.
|
|
1165
|
+
{
|
|
1166
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
1167
|
+
defer harness.destroy(std.testing.allocator);
|
|
1168
|
+
harness.null_platform.window_hide_on_close = false;
|
|
1169
|
+
harness.runtime.options.platform.app_info.windows = &startup_windows;
|
|
1170
|
+
var app_state: SourceApp = .{};
|
|
1171
|
+
try std.testing.expectError(error.UnsupportedWindowClosePolicy, harness.start(app_state.app()));
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
// A host WITH the affordance loads the same declaration: both
|
|
1175
|
+
// startup windows come up.
|
|
1176
|
+
{
|
|
1177
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
1178
|
+
defer harness.destroy(std.testing.allocator);
|
|
1179
|
+
harness.runtime.options.platform.app_info.windows = &startup_windows;
|
|
1180
|
+
var app_state: SourceApp = .{};
|
|
1181
|
+
try harness.start(app_state.app());
|
|
1182
|
+
var buffer: [support.platform.max_windows]support.platform.WindowInfo = undefined;
|
|
1183
|
+
try std.testing.expectEqual(@as(usize, 2), harness.runtime.listWindows(&buffer).len);
|
|
1184
|
+
}
|
|
717
1185
|
}
|
|
@@ -153,12 +153,88 @@ test "runtime handles built-in JavaScript window bridge commands" {
|
|
|
153
153
|
} });
|
|
154
154
|
try std.testing.expect(std.mem.indexOf(u8, harness.null_platform.lastBridgeResponse(), "\"focused\":true") != null);
|
|
155
155
|
|
|
156
|
+
// The window JSON must expose alive-but-policy-hidden: open:true /
|
|
157
|
+
// focused:false alone cannot distinguish a close_policy = "hide"
|
|
158
|
+
// window from a visible unfocused one, so "hidden" rides every
|
|
159
|
+
// window response. Visible window first...
|
|
160
|
+
try std.testing.expect(std.mem.indexOf(u8, harness.null_platform.lastBridgeResponse(), "\"hidden\":false") != null);
|
|
161
|
+
// ...then the host reports the palette window policy-hidden (still
|
|
162
|
+
// open) and the bridge list reflects it.
|
|
163
|
+
try harness.runtime.dispatchPlatformEvent(app_state.app(), .{ .window_frame_changed = .{
|
|
164
|
+
.id = 2,
|
|
165
|
+
.label = "palette",
|
|
166
|
+
.title = "Palette",
|
|
167
|
+
.frame = geometry.RectF.init(0, 0, 320, 240),
|
|
168
|
+
.scale_factor = 1,
|
|
169
|
+
.open = true,
|
|
170
|
+
.focused = false,
|
|
171
|
+
.hidden = true,
|
|
172
|
+
} });
|
|
173
|
+
try harness.runtime.dispatchPlatformEvent(app_state.app(), .{ .bridge_message = .{
|
|
174
|
+
.bytes = "{\"id\":\"hidden\",\"command\":\"native-sdk.window.list\",\"payload\":null}",
|
|
175
|
+
.origin = "zero://inline",
|
|
176
|
+
.window_id = 1,
|
|
177
|
+
} });
|
|
178
|
+
try std.testing.expect(std.mem.indexOf(u8, harness.null_platform.lastBridgeResponse(), "\"hidden\":true") != null);
|
|
179
|
+
|
|
180
|
+
// Focusing the policy-hidden window rides the runtime's ONE
|
|
181
|
+
// hidden-then-focus rule: the show verb runs first (the platform
|
|
182
|
+
// mirror counts it — the seam that clears the hosts' policy-hidden
|
|
183
|
+
// bookkeeping), so the response never reports a focused window
|
|
184
|
+
// that is still hidden.
|
|
185
|
+
try harness.runtime.dispatchPlatformEvent(app_state.app(), .{ .bridge_message = .{
|
|
186
|
+
.bytes = "{\"id\":\"5\",\"command\":\"native-sdk.window.focus\",\"payload\":{\"label\":\"palette\"}}",
|
|
187
|
+
.origin = "zero://inline",
|
|
188
|
+
.window_id = 1,
|
|
189
|
+
} });
|
|
190
|
+
try std.testing.expect(std.mem.indexOf(u8, harness.null_platform.lastBridgeResponse(), "\"focused\":true") != null);
|
|
191
|
+
try std.testing.expect(std.mem.indexOf(u8, harness.null_platform.lastBridgeResponse(), "\"hidden\":false") != null);
|
|
192
|
+
try std.testing.expectEqual(@as(u32, 1), harness.null_platform.showCountForWindow(2));
|
|
193
|
+
|
|
194
|
+
// The runtime's show verb (a tray "Open", Cmd.showWindow) is show
|
|
195
|
+
// AND activate: after showing a policy-hidden window, the bridge's
|
|
196
|
+
// window JSON — served from the same runtime table — reports it
|
|
197
|
+
// focused, not merely un-hidden.
|
|
198
|
+
try harness.runtime.dispatchPlatformEvent(app_state.app(), .{ .window_frame_changed = .{
|
|
199
|
+
.id = 2,
|
|
200
|
+
.label = "palette",
|
|
201
|
+
.title = "Palette",
|
|
202
|
+
.frame = geometry.RectF.init(0, 0, 320, 240),
|
|
203
|
+
.scale_factor = 1,
|
|
204
|
+
.open = true,
|
|
205
|
+
.focused = false,
|
|
206
|
+
.hidden = true,
|
|
207
|
+
} });
|
|
208
|
+
try harness.runtime.showWindow(2);
|
|
209
|
+
try harness.runtime.dispatchPlatformEvent(app_state.app(), .{ .bridge_message = .{
|
|
210
|
+
.bytes = "{\"id\":\"shown\",\"command\":\"native-sdk.window.list\",\"payload\":null}",
|
|
211
|
+
.origin = "zero://inline",
|
|
212
|
+
.window_id = 1,
|
|
213
|
+
} });
|
|
214
|
+
try std.testing.expect(std.mem.indexOf(u8, harness.null_platform.lastBridgeResponse(), "\"label\":\"palette\",\"title\":\"Palette\",\"open\":true,\"focused\":true,\"hidden\":false") != null);
|
|
215
|
+
|
|
216
|
+
// Closing a POLICY-HIDDEN window through the bridge answers with
|
|
217
|
+
// the post-close table state: hidden clears with open (a closed
|
|
218
|
+
// window is gone, not "hidden"), so JS must never receive
|
|
219
|
+
// {open:false, hidden:true} — the shape a pre-close snapshot with
|
|
220
|
+
// hand-cleared fields would serialize.
|
|
221
|
+
try harness.runtime.dispatchPlatformEvent(app_state.app(), .{ .window_frame_changed = .{
|
|
222
|
+
.id = 2,
|
|
223
|
+
.label = "palette",
|
|
224
|
+
.title = "Palette",
|
|
225
|
+
.frame = geometry.RectF.init(0, 0, 320, 240),
|
|
226
|
+
.scale_factor = 1,
|
|
227
|
+
.open = true,
|
|
228
|
+
.focused = false,
|
|
229
|
+
.hidden = true,
|
|
230
|
+
} });
|
|
156
231
|
try harness.runtime.dispatchPlatformEvent(app_state.app(), .{ .bridge_message = .{
|
|
157
232
|
.bytes = "{\"id\":\"4\",\"command\":\"native-sdk.window.close\",\"payload\":{\"label\":\"palette\"}}",
|
|
158
233
|
.origin = "zero://inline",
|
|
159
234
|
.window_id = 1,
|
|
160
235
|
} });
|
|
161
236
|
try std.testing.expect(std.mem.indexOf(u8, harness.null_platform.lastBridgeResponse(), "\"open\":false") != null);
|
|
237
|
+
try std.testing.expect(std.mem.indexOf(u8, harness.null_platform.lastBridgeResponse(), "\"hidden\":false") != null);
|
|
162
238
|
}
|
|
163
239
|
|
|
164
240
|
test "runtime handles built-in JavaScript command bridge commands" {
|
|
@@ -383,6 +459,47 @@ test "runtime handles built-in JavaScript platform support commands" {
|
|
|
383
459
|
} });
|
|
384
460
|
try std.testing.expect(std.mem.indexOf(u8, harness.null_platform.lastBridgeResponse(), "\"result\":false") != null);
|
|
385
461
|
|
|
462
|
+
// Both spellings of window_hide_on_close answer the same seam: the null
|
|
463
|
+
// platform models full hide-on-close support by default, and flipping the
|
|
464
|
+
// seam off (the GTK model) flips both spellings together.
|
|
465
|
+
try harness.runtime.dispatchPlatformEvent(app_state.app(), .{ .bridge_message = .{
|
|
466
|
+
.bytes = "{\"id\":\"hide-snake\",\"command\":\"native-sdk.platform.supports\",\"payload\":{\"feature\":\"window_hide_on_close\"}}",
|
|
467
|
+
.origin = "zero://inline",
|
|
468
|
+
.window_id = 1,
|
|
469
|
+
} });
|
|
470
|
+
try std.testing.expect(std.mem.indexOf(u8, harness.null_platform.lastBridgeResponse(), "\"result\":true") != null);
|
|
471
|
+
|
|
472
|
+
try harness.runtime.dispatchPlatformEvent(app_state.app(), .{ .bridge_message = .{
|
|
473
|
+
.bytes = "{\"id\":\"hide-camel\",\"command\":\"native-sdk.platform.supports\",\"payload\":{\"feature\":\"windowHideOnClose\"}}",
|
|
474
|
+
.origin = "zero://inline",
|
|
475
|
+
.window_id = 1,
|
|
476
|
+
} });
|
|
477
|
+
try std.testing.expect(std.mem.indexOf(u8, harness.null_platform.lastBridgeResponse(), "\"result\":true") != null);
|
|
478
|
+
|
|
479
|
+
harness.null_platform.window_hide_on_close = false;
|
|
480
|
+
try harness.runtime.dispatchPlatformEvent(app_state.app(), .{ .bridge_message = .{
|
|
481
|
+
.bytes = "{\"id\":\"hide-snake-off\",\"command\":\"native-sdk.platform.supports\",\"payload\":{\"feature\":\"window_hide_on_close\"}}",
|
|
482
|
+
.origin = "zero://inline",
|
|
483
|
+
.window_id = 1,
|
|
484
|
+
} });
|
|
485
|
+
try std.testing.expect(std.mem.indexOf(u8, harness.null_platform.lastBridgeResponse(), "\"result\":false") != null);
|
|
486
|
+
|
|
487
|
+
try harness.runtime.dispatchPlatformEvent(app_state.app(), .{ .bridge_message = .{
|
|
488
|
+
.bytes = "{\"id\":\"hide-camel-off\",\"command\":\"native-sdk.platform.supports\",\"payload\":{\"feature\":\"windowHideOnClose\"}}",
|
|
489
|
+
.origin = "zero://inline",
|
|
490
|
+
.window_id = 1,
|
|
491
|
+
} });
|
|
492
|
+
try std.testing.expect(std.mem.indexOf(u8, harness.null_platform.lastBridgeResponse(), "\"result\":false") != null);
|
|
493
|
+
|
|
494
|
+
// Camel-cohort spot check: the backfilled audioSpectrum alias resolves to
|
|
495
|
+
// audio_spectrum, which the default null platform supports.
|
|
496
|
+
try harness.runtime.dispatchPlatformEvent(app_state.app(), .{ .bridge_message = .{
|
|
497
|
+
.bytes = "{\"id\":\"spectrum-camel\",\"command\":\"native-sdk.platform.supports\",\"payload\":{\"feature\":\"audioSpectrum\"}}",
|
|
498
|
+
.origin = "zero://inline",
|
|
499
|
+
.window_id = 1,
|
|
500
|
+
} });
|
|
501
|
+
try std.testing.expect(std.mem.indexOf(u8, harness.null_platform.lastBridgeResponse(), "\"result\":true") != null);
|
|
502
|
+
|
|
386
503
|
var chromium_platform = platform.NullPlatform.initWithEngine(.{}, .chromium);
|
|
387
504
|
harness.runtime.options.platform = chromium_platform.platform();
|
|
388
505
|
try std.testing.expect(!harness.runtime.supports(.tray));
|