Files
cthulhu/internal/app/mouse_review_test.go

48 lines
1.8 KiB
Go

// Copyright (c) 2026 Storm Dragon
// Authors: Storm Dragon, Angus Kola
// SPDX-License-Identifier: GPL-3.0-or-later
package app
import (
"strings"
"testing"
"git.stormux.org/storm/cthulhu/internal/atspi"
"git.stormux.org/storm/cthulhu/internal/config"
)
func TestMouseReviewChangesObjectLineAndWordWithoutMovingFocus(t *testing.T) {
settings := config.DefaultSettings()
point := atspi.PointReview{Snapshot: atspi.Snapshot{BusName: ":1.9", Path: "/entry", Name: "Search", Role: "entry"},
Window: atspi.ObjectID{BusName: ":1.9", Path: "/window"}, Word: "first", Line: "first second", LineStart: 0}
var state mouseReviewState
if got := state.text(point, settings); got != "" {
t.Fatalf("initial pointer spoke %q", got)
}
point.Word = "second"
if got := state.text(point, settings); got != "second" {
t.Fatalf("new word = %q", got)
}
if got := state.text(point, settings); got != "" {
t.Fatalf("duplicate word = %q", got)
}
point.Line, point.LineStart, point.Word = "next line", 12, "next"
if got := state.text(point, settings); got != "next line" {
t.Fatalf("new line = %q", got)
}
point.Snapshot.Path, point.Snapshot.Name, point.Snapshot.Role = "/button", "Save", "push button"
point.Word, point.Line = "", ""
if got := state.text(point, settings); !strings.Contains(got, "Save") || !strings.Contains(got, "button") {
t.Fatalf("new object = %q", got)
}
point.Snapshot.Path, point.Snapshot.Name, point.Snapshot.Role = "/password", "Password", "password text"
point.Word, point.Line = "secret", "secret"
if got := state.text(point, settings); strings.Contains(got, "secret") {
t.Fatalf("password leaked: %q", got)
}
state.clearItem(state.position)
if got := state.text(point, settings); !strings.Contains(got, "Password") {
t.Fatalf("object re-entry = %q", got)
}
}