Share native current-line speech with Remote
This commit is contained in:
1 parent
103fbfd81a
commit
ee3d91af23
11 files changed
+289
-16
No files matched your search
@@ -69,6 +69,7 @@ func TestRemoteCurrentLineSourcePrivacy(t *testing.T) {
|
||||
SourceContexts: [][]atspi.Snapshot{ancestors, neighbor}}
|
||||
case "native":
|
||||
result.CurrentLineBrowse = false
|
||||
result.DocumentCaretContext = nil
|
||||
case "failure":
|
||||
result.Err = errors.New("fixture unavailable")
|
||||
}
|
||||
@@ -132,3 +133,91 @@ func TestRemoteCurrentLineResolvedOutput(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func native_current_line_result() review.Result {
|
||||
source := atspi.Snapshot{BusName: ":1.42", Path: "/focus", Role: "text"}
|
||||
return review.Result{DocumentCaretText: "Native colour.", DocumentPosition: review.DocumentPosition{Snapshot: source},
|
||||
DocumentCaretContext: []atspi.Snapshot{source, {BusName: source.BusName, Path: "/window", Role: "frame"},
|
||||
{BusName: source.BusName, Path: "/app", Role: "application"}}}
|
||||
}
|
||||
|
||||
func TestRemoteNativeCurrentLineSourcePrivacy(t *testing.T) {
|
||||
for _, privacy := range []string{"ordinary", "password", "ancestor", "unknown", "invalid", "defunct", "missing", "truncated", "mismatched", "foreign", "failure"} {
|
||||
t.Run(privacy, func(t *testing.T) {
|
||||
result := native_current_line_result()
|
||||
switch privacy {
|
||||
case "password":
|
||||
result.DocumentPosition.Snapshot.Role = "password text"
|
||||
case "ancestor":
|
||||
result.DocumentCaretContext[1].Role = "password text"
|
||||
case "unknown":
|
||||
result.DocumentCaretContext[1].Role = "unknown"
|
||||
case "invalid":
|
||||
result.DocumentCaretContext[1].Role = "invalid"
|
||||
case "defunct":
|
||||
result.DocumentCaretContext[1].Defunct = true
|
||||
case "missing":
|
||||
result.DocumentCaretContext = nil
|
||||
case "truncated":
|
||||
result.DocumentCaretContext = result.DocumentCaretContext[:2]
|
||||
case "mismatched":
|
||||
result.DocumentCaretContext[0].Path = "/other"
|
||||
case "foreign":
|
||||
result.DocumentPosition.Snapshot.Path = "/other"
|
||||
result.DocumentCaretContext[0].Path = "/other"
|
||||
case "failure":
|
||||
result.Err = errors.New("fixture unavailable")
|
||||
}
|
||||
request := current_line_observation_request(t, result)
|
||||
if exportable_speech(request) != (privacy == "ordinary") {
|
||||
t.Fatalf("native source %s produced exportable=%v", privacy, exportable_speech(request))
|
||||
}
|
||||
if privacy != "failure" && request.Text != result.DocumentCaretText {
|
||||
t.Fatal("privacy classification changed local native reading")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoteNativeCurrentLineResolvedOutput(t *testing.T) {
|
||||
worker, session, _, _ := observation_fixture(t)
|
||||
worker.textTransform = func(text string) string { return strings.ReplaceAll(text, "colour", "color") }
|
||||
for _, probe := range []struct {
|
||||
style review.FlatSpeech
|
||||
text string
|
||||
want []string
|
||||
characters bool
|
||||
}{
|
||||
{review.FlatSpeak, "Native colour.", []string{"Native color."}, false},
|
||||
{review.FlatSpell, "book", []string{"b", "o", "o", "k"}, true},
|
||||
{review.FlatPhonetic, "book", []string{"bravo", "oscar", "oscar", "kilo"}, false},
|
||||
{review.FlatSpeak, "\n", []string{"blank"}, false},
|
||||
} {
|
||||
result := native_current_line_result()
|
||||
result.FlatSpeech, result.DocumentCaretText = probe.style, probe.text
|
||||
for _, private := range []bool{false, true} {
|
||||
if private {
|
||||
result.DocumentCaretContext[1].Role = "password text"
|
||||
}
|
||||
if err := worker.EnqueueAndWait(t.Context(), current_line_observation_request(t, result)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, want := range probe.want {
|
||||
if !private {
|
||||
value := observed_speech(t, session)
|
||||
if value.Kind != "speak" || len(value.Parts) != 2 || value.Parts[0].Text != want ||
|
||||
value.Parts[0].Characters != probe.characters || !value.Parts[1].End {
|
||||
t.Fatal("native report lost resolved output or spelling boundaries", value)
|
||||
}
|
||||
}
|
||||
if got := <-worker.speaker.(*observationSpeaker).spoken; got != want {
|
||||
t.Fatalf("native local reading %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
worker.InterruptForUser()
|
||||
if value := observed_speech(t, session); value.Kind != "cancel" {
|
||||
t.Fatal("private native output reached the child", value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user