Group inline links and list items into browse lines
This commit is contained in:
1 parent
3dbd7f2554
commit
d01965c00d
16 files changed
+309
-15
No files matched your search
@@ -163,16 +163,16 @@ func TestReadAllFragmentLinesAndRemainder(t *testing.T) {
|
||||
t.Fatalf("read all: %+v", result)
|
||||
}
|
||||
for index, want := range []string{"ne two.", "Three four.", "Next paragraph"} {
|
||||
if got := result.ReadAllLines[index].Contents[0].Text; got != want {
|
||||
if got := visual_line_test_text(result.ReadAllLines[index]); got != want {
|
||||
t.Fatalf("line %d: %q, want %q", index, got, want)
|
||||
}
|
||||
}
|
||||
// Say All flattens the fragments into one text value, but must retain
|
||||
// Say All retains the fragments and must retain
|
||||
// every original source and ancestry for Remote's privacy decision.
|
||||
contexts := result.ReadAllLines[0].SourceContexts
|
||||
if len(contexts) != 2 || len(contexts[0]) < 2 || len(contexts[1]) < 2 ||
|
||||
contexts[0][0].ID() != webID("/one") || contexts[1][0].ID() != webID("/two") || contexts[1][1].ID() != webID("/span") {
|
||||
t.Fatal("flattened Say All line lost fragment ancestry")
|
||||
t.Fatal("Say All line lost fragment ancestry")
|
||||
}
|
||||
if cursor.places[0].offset != 1 {
|
||||
t.Fatal("assembly moved the user's cursor")
|
||||
@@ -290,3 +290,65 @@ func TestDocumentFragmentLineAcrossWrappedObject(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func visual_line_test_text(line atspi.DocumentLine) string {
|
||||
var text strings.Builder
|
||||
for _, part := range line.Contents {
|
||||
text.WriteString(part.Separator)
|
||||
text.WriteString(part.Text)
|
||||
}
|
||||
return text.String()
|
||||
}
|
||||
|
||||
func TestDocumentSameRowLinksAndListItems(t *testing.T) {
|
||||
for _, role := range []string{"link", "list item"} {
|
||||
t.Run(role, func(t *testing.T) {
|
||||
cursor, reader := fragment_cursor(t, "list")
|
||||
doc, _ := cursor.tree.Document(t.Context(), cursor.places[0].object)
|
||||
var nodes []atspi.TreeNode
|
||||
for _, node := range doc.Nodes {
|
||||
if node.Reference.ID() == webID("/one") || node.Reference.ID() == webID("/two") || node.Reference.ID() == webID("/three") || node.Reference.ID() == webID("/four") {
|
||||
node.Snapshot.Role = role
|
||||
}
|
||||
nodes = append(nodes, atspi.TreeNode{Snapshot: node.Snapshot, Children: node.Children})
|
||||
}
|
||||
if err := cursor.tree.Replace(webID("/doc"), nodes); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, step := range []struct {
|
||||
command DocumentCaretCommand
|
||||
want string
|
||||
}{
|
||||
{CaretDocumentStart, "One two."}, {CaretNextLine, "Three four."},
|
||||
{CaretPreviousLine, "One two."}, {CaretLineEnd, "."}, {CaretNextLine, "Three four."},
|
||||
} {
|
||||
move, err := cursor.MoveCaret(t.Context(), reader, step.command)
|
||||
if err != nil || move.Text != step.want {
|
||||
t.Fatalf("%s: %q, %v; want %q", step.command, move.Text, err, step.want)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDocumentGridListItemsStaySeparate(t *testing.T) {
|
||||
cursor, reader := fragment_cursor(t, "list")
|
||||
doc, _ := cursor.tree.Document(t.Context(), cursor.places[0].object)
|
||||
var nodes []atspi.TreeNode
|
||||
for _, node := range doc.Nodes {
|
||||
if node.Snapshot.Role == "list" {
|
||||
node.Snapshot.Display = "grid"
|
||||
}
|
||||
if node.Reference.ID() == webID("/one") {
|
||||
node.Snapshot.Role = "list item"
|
||||
}
|
||||
nodes = append(nodes, atspi.TreeNode{Snapshot: node.Snapshot, Children: node.Children})
|
||||
}
|
||||
if err := cursor.tree.Replace(webID("/doc"), nodes); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
move, err := cursor.MoveCaret(t.Context(), reader, CaretDocumentStart)
|
||||
if err != nil || strings.TrimSpace(move.Text) != "One" {
|
||||
t.Fatalf("grid boundary: %+v, %v", move, err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user