返回 DeepSeek-Reasonix
host_shell_update_test.go
根目录 / desktop / host_shell_update_test.go
1 package main
2
3 import (
4 "os"
5 "testing"
6 )
7
8 func TestUpdateHandoffOwnerPIDWaitsForShellParentInHostMode(t *testing.T) {
9 app := &App{}
10 if got := app.updateHandoffOwnerPID(); got != os.Getpid() {
11 t.Fatalf("Wails owner pid = %d, want %d", got, os.Getpid())
12 }
13 app.hostShell = &hostShellBridge{app: app}
14 if got := app.updateHandoffOwnerPID(); got != os.Getppid() {
15 t.Fatalf("host-mode owner pid = %d, want parent %d", got, os.Getppid())
16 }
17 }
18
19 func TestHostUpdateHandoffQuitsWithoutSchedulingASecondRestart(t *testing.T) {
20 app, _, shell := newHostShellBridgeForTest(t, nil)
21 app.relaunchDesktop(false)
22 calls := shell.methods()
23 if len(calls) != 1 || calls[0] != "host/app.quit" {
24 t.Fatalf("helper-owned restart asked shell to %v", calls)
25 }
26 app.relaunchDesktop(true)
27 calls = shell.methods()
28 if len(calls) != 2 || calls[1] != "host/app.relaunch" {
29 t.Fatalf("shell-owned restart asked shell to %v", calls)
30 }
31 }
32
33 func TestWindowsUpdateWaitsForTheShellInsteadOfItsService(t *testing.T) {
34 original := os.Args
35 t.Cleanup(func() { os.Args = original })
36 os.Args = []string{"reasonix-desktop", "--host-rpc"}
37 if got := windowsUpdateOwnerPID(); got != os.Getppid() {
38 t.Fatalf("host PID=%d want %d", got, os.Getppid())
39 }
40 os.Args = []string{"reasonix-desktop"}
41 if got := windowsUpdateOwnerPID(); got != os.Getpid() {
42 t.Fatalf("legacy PID=%d want %d", got, os.Getpid())
43 }
44 }
45
45 lines GO