diff --git a/internal/driver/ioscompanion/driver_test.go b/internal/driver/ioscompanion/driver_test.go index bf9aa27..955cad4 100644 --- a/internal/driver/ioscompanion/driver_test.go +++ b/internal/driver/ioscompanion/driver_test.go @@ -109,6 +109,7 @@ func newTestDriver(companion transport.Companion) *Driver { } d.resetContainer = func(context.Context) error { return nil } d.reinstallApp = func(context.Context) error { return nil } + d.grantPaste = func(context.Context) error { return nil } return d } @@ -137,6 +138,31 @@ func TestLaunchTerminatesFirstThenLaunches(t *testing.T) { } } +func TestLaunchGrantsPasteboardBeforeLaunch(t *testing.T) { + companion := &fakeCompanion{accessibilityJSON: "[]"} + d := newTestDriver(companion) + granted := false + d.grantPaste = func(context.Context) error { granted = true; return nil } + if err := d.Launch(context.Background(), "", false, nil); err != nil { + t.Fatalf("Launch: %v", err) + } + if !granted { + t.Fatal("Launch must grant pasteboard access so unicode input skips the permission prompt") + } +} + +func TestLaunchContinuesWhenGrantFails(t *testing.T) { + companion := &fakeCompanion{accessibilityJSON: "[]"} + d := newTestDriver(companion) + d.grantPaste = func(context.Context) error { return errors.New("no privacy db") } + if err := d.Launch(context.Background(), "", false, nil); err != nil { + t.Fatalf("Launch must continue when the grant fails: %v", err) + } + if indexOf(companion.calls, "launch") < 0 { + t.Fatalf("app must still launch; got %v", companion.calls) + } +} + func TestLaunchClearStateReinstallsWithAppPath(t *testing.T) { companion := &fakeCompanion{accessibilityJSON: "[]"} d := newTestDriver(companion) diff --git a/internal/driver/ioscompanion/input_test.go b/internal/driver/ioscompanion/input_test.go index 7399c40..f8ea7b9 100644 --- a/internal/driver/ioscompanion/input_test.go +++ b/internal/driver/ioscompanion/input_test.go @@ -386,33 +386,6 @@ func TestEraseTextZeroIsNoOp(t *testing.T) { } } -func TestWarmUpPasteHandlesDialog(t *testing.T) { - dialog := string(loadDialogDump(t)) - fake := &fakeRunner{dumps: [][]byte{[]byte(dialog)}} - if err := warmUpPaste(context.Background(), fake); err != nil { - t.Fatalf("warmUpPaste: %v", err) - } - if fake.pasteboard != warmUpPrimer { - t.Fatalf("pasteboard: got %q, want %q", fake.pasteboard, warmUpPrimer) - } - // Streams: paste chord, tap allow. - if len(fake.hidStreams) != 2 { - t.Fatalf("expected 2 HID streams, got %d", len(fake.hidStreams)) - } - eventsEqual(t, fake.hidStreams[0], pasteChordEvents()) - eventsEqual(t, fake.hidStreams[1], tapEvents(280, 465)) -} - -func TestWarmUpPasteNoDialog(t *testing.T) { - fake := &fakeRunner{dumps: [][]byte{[]byte(`[]`)}} - if err := warmUpPaste(context.Background(), fake); err != nil { - t.Fatalf("warmUpPaste: %v", err) - } - if len(fake.hidStreams) != 1 { - t.Fatalf("expected only the paste chord, got %d streams", len(fake.hidStreams)) - } -} - func TestUsesPasteboard(t *testing.T) { cases := []struct { text string