mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
test(ioscompanion): cover pasteboard grant on launch, drop warm-up tests
This commit is contained in:
1 parent
a0cc3b5d05
commit
8b7a51c5b5
2 files changed
+26
-27
No files matched your search
@@ -109,6 +109,7 @@ func newTestDriver(companion transport.Companion) *Driver {
|
|||||||
}
|
}
|
||||||
d.resetContainer = func(context.Context) error { return nil }
|
d.resetContainer = func(context.Context) error { return nil }
|
||||||
d.reinstallApp = func(context.Context) error { return nil }
|
d.reinstallApp = func(context.Context) error { return nil }
|
||||||
|
d.grantPaste = func(context.Context) error { return nil }
|
||||||
return d
|
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) {
|
func TestLaunchClearStateReinstallsWithAppPath(t *testing.T) {
|
||||||
companion := &fakeCompanion{accessibilityJSON: "[]"}
|
companion := &fakeCompanion{accessibilityJSON: "[]"}
|
||||||
d := newTestDriver(companion)
|
d := newTestDriver(companion)
|
||||||
|
|||||||
@@ -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) {
|
func TestUsesPasteboard(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
text string
|
text string
|
||||||
|
|||||||
Reference in new issue
Block a user