27 lines
942 B
Go
27 lines
942 B
Go
// Copyright (c) 2026 Storm Dragon
|
|
// Authors: Storm Dragon, Angus Kola
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package atspi
|
|
|
|
import "testing"
|
|
|
|
func TestDocumentRoutingSelectionCollapseEcho(t *testing.T) {
|
|
for _, test := range []struct {
|
|
offset, start, end int
|
|
want uint8
|
|
}{
|
|
{0, 0, 0, 8}, // Selection removal temporarily collapses at zero.
|
|
{1, 0, 0, 4}, // Requested route completes at one.
|
|
{2, 0, 0, 0}, // An unrelated native movement is not an echo.
|
|
{0, 0, 1, 0}, // A fresh native selection must never be swallowed.
|
|
{1, 0, 1, 0},
|
|
} {
|
|
event := NewEvent(CaretEvent, Snapshot{TextCaretKnown: true, SelectionStart: test.start, SelectionEnd: test.end})
|
|
event.Detail1 = test.offset
|
|
if got := documentNavigationEchoBit(event, 1, map[int]bool{0: true, 1: true}); got != test.want {
|
|
t.Fatalf("offset %d, selection %d:%d: bit %d, want %d", test.offset, test.start, test.end, got, test.want)
|
|
}
|
|
}
|
|
}
|