Files
MyGoNavi/internal/nativewindow/runtime_script_test.go
Syngnat 3f4b247faa feat(native-window): 完善原生独立窗口与跨屏拖拽
- 支持全部工作台标签与 AI 对话在多显示器中原生独立展示
- 修复拖拽指针捕获,恢复关闭、右键菜单和跨窗口释放识别
- 拆分子窗启动入口并按需加载语言与工作台内容
- 内容与 Monaco 完成可见绘制后再提交迁移,消除白屏和加载闪烁
- 加固结果编辑、宿主同步及关闭、超时和焦点竞态
2026-07-17 16:06:24 +08:00

67 lines
2.0 KiB
Go

package nativewindow
import (
"strings"
"testing"
)
func TestBridgeWindowIDUsesChildIdentity(t *testing.T) {
bridge := newBridge(ChildOptions{ID: "workbench:query-1"})
if got := bridge.WindowID(); got != "workbench:query-1" {
t.Fatalf("WindowID() = %q, want %q", got, "workbench:query-1")
}
}
func TestRuntimeCommandsDoNotReloadBootstrapForWindowIdentity(t *testing.T) {
script := detachedRuntimeBridgeScript()
if !strings.Contains(script, "bridge.WindowID()") {
t.Fatal("runtime bridge does not read the lightweight window identity")
}
if strings.Contains(script, "detached.loadBootstrap().then(function (bootstrap)") {
t.Fatal("runtime command routing still reloads the full bootstrap payload")
}
}
func TestRuntimeExposesParentWindowManagerInsideDetachedChildren(t *testing.T) {
script := detachedRuntimeBridgeScript()
for _, expected := range []string{
"Manager: parentWindowManager",
"bridge.OpenWindow(request || {})",
"bridge.FocusWindow",
"bridge.CloseWindow",
} {
if !strings.Contains(script, expected) {
t.Fatalf("runtime bridge is missing %q", expected)
}
}
}
func TestRuntimeRoutesParentCloseThroughGracefulFrontendEvent(t *testing.T) {
script := detachedRuntimeBridgeScript()
for _, expected := range []string{
GracefulCloseRequestEventName,
"requestGracefulClose(command.reason)",
"window.dispatchEvent(new CustomEvent",
} {
if !strings.Contains(script, expected) {
t.Fatalf("runtime bridge is missing graceful close marker %q", expected)
}
}
if strings.Contains(script, "control.Close();") {
t.Fatal("parent close command still quits before the frontend can flush state")
}
}
func TestRuntimeExposesTwoPhaseChildPresentation(t *testing.T) {
script := detachedRuntimeBridgeScript()
for _, expected := range []string{
"present: function ()",
"control.Present()",
"native window present control is unavailable",
} {
if !strings.Contains(script, expected) {
t.Fatalf("runtime bridge is missing presentation marker %q", expected)
}
}
}