mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
test(ioscompanion): cover atomic erase, single chord, unverifiable field
This commit is contained in:
1 parent
432154ee02
commit
0e6f3e7a7a
1 file changed
+35
-5
@@ -285,9 +285,9 @@ func TestInputTextPasteLandsImmediately(t *testing.T) {
|
|||||||
func TestInputTextPasteDismissesDialogThenLands(t *testing.T) {
|
func TestInputTextPasteDismissesDialogThenLands(t *testing.T) {
|
||||||
dialog := string(loadDialogDump(t))
|
dialog := string(loadDialogDump(t))
|
||||||
landed := `[{"type":"TextField","AXUniqueId":"TxnNoteField","AXValue":"Café ☕ 😀"}]`
|
landed := `[{"type":"TextField","AXUniqueId":"TxnNoteField","AXValue":"Café ☕ 😀"}]`
|
||||||
// Quick post-chord check and post-sleep check both see the dialog, the
|
// First check sees the dialog (which swallowed the initial chord); the
|
||||||
// retried chord's quick check sees the landed value.
|
// check after the retried chord sees the landed value.
|
||||||
fake := &fakeRunner{dumps: [][]byte{[]byte(dialog), []byte(dialog), []byte(landed)}}
|
fake := &fakeRunner{dumps: [][]byte{[]byte(dialog), []byte(landed)}}
|
||||||
field := fieldTarget{identifier: "TxnNoteField", centerX: 195, centerY: 222}
|
field := fieldTarget{identifier: "TxnNoteField", centerX: 195, centerY: 222}
|
||||||
if err := inputText(context.Background(), fake, "Café ☕ 😀", field); err != nil {
|
if err := inputText(context.Background(), fake, "Café ☕ 😀", field); err != nil {
|
||||||
t.Fatalf("inputText: %v", err)
|
t.Fatalf("inputText: %v", err)
|
||||||
@@ -310,9 +310,39 @@ func TestInputTextPasteFailsAfterAllAttempts(t *testing.T) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("expected error after exhausting attempts")
|
t.Fatal("expected error after exhausting attempts")
|
||||||
}
|
}
|
||||||
if len(fake.hidStreams) != pasteAttempts {
|
// The chord is sent exactly once: with no dialog on screen, re-sending it
|
||||||
t.Fatalf("expected %d paste chords, got %d", pasteAttempts, len(fake.hidStreams))
|
// on a slow render would paste the text twice.
|
||||||
|
if len(fake.hidStreams) != 1 {
|
||||||
|
t.Fatalf("expected exactly one paste chord, got %d", len(fake.hidStreams))
|
||||||
}
|
}
|
||||||
|
if fake.sleepCount != pasteAttempts {
|
||||||
|
t.Fatalf("expected %d settle sleeps, got %d", pasteAttempts, fake.sleepCount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInputTextPasteUnverifiableFieldSingleChord(t *testing.T) {
|
||||||
|
// No field identifier resolved: one chord, no dialog, success after the
|
||||||
|
// settle without endless retries.
|
||||||
|
noField := `[{"type":"StaticText","AXLabel":"whatever"}]`
|
||||||
|
fake := &fakeRunner{dumps: [][]byte{[]byte(noField)}}
|
||||||
|
if err := inputText(context.Background(), fake, "😀", fieldTarget{}); err != nil {
|
||||||
|
t.Fatalf("inputText: %v", err)
|
||||||
|
}
|
||||||
|
if len(fake.hidStreams) != 1 {
|
||||||
|
t.Fatalf("expected exactly one paste chord, got %d", len(fake.hidStreams))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestEraseTextLargeCountClearsAtomically(t *testing.T) {
|
||||||
|
fake := &fakeRunner{}
|
||||||
|
if err := eraseText(context.Background(), fake, 40); err != nil {
|
||||||
|
t.Fatalf("eraseText: %v", err)
|
||||||
|
}
|
||||||
|
if len(fake.hidStreams) != 1 {
|
||||||
|
t.Fatalf("expected one stream, got %d", len(fake.hidStreams))
|
||||||
|
}
|
||||||
|
want := append(selectAllChordEvents(), keyPressEvents(backspaces(1))...)
|
||||||
|
eventsEqual(t, fake.hidStreams[0], want)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEraseTextSendsBackspaces(t *testing.T) {
|
func TestEraseTextSendsBackspaces(t *testing.T) {
|
||||||
|
|||||||
Reference in new issue
Block a user