Files
Storm Dragon 3dbd7f2554 Avoid repeating Mumble server labels across columns
Collapse identical full-row labels only for Mumble while preserving mixed column data and repeated values from other providers. Add Qt native coverage and document live saved-server listening confirmation.
2026-11-07 20:12:25 -05:00

48 lines
2.0 KiB
Go

// Copyright (c) 2026 Storm Dragon
// Authors: Storm Dragon, Angus Kola
// SPDX-License-Identifier: GPL-3.0-or-later
package atspi
import "testing"
func TestMumbleTableRowText(t *testing.T) {
for _, test := range []struct {
name, process, label, row, want string
columns int
gui bool
}{
{"server label", "mumble", "Server Example", "Server Example, Server Example, Server Example", "Server Example", 3, true},
{"commas and Unicode", "mumble", "Server Example, 界", "Server Example, 界, Server Example, 界, Server Example, 界", "Server Example, 界", 3, true},
{"useful equal values", "mumble", "Server Example", "Server Example, 12, 12", "Server Example, 12, 12", 3, true},
{"mixed labels", "mumble", "Server Example", "Server Example, 12, Server Example", "Server Example, 12, Server Example", 3, true},
{"unrelated provider", "other", "Same", "Same, Same, Same", "Same, Same, Same", 3, true},
{"document table", "mumble", "Same", "Same, Same, Same", "Same, Same, Same", 3, false},
{"single column", "mumble", "Server Example", "Server Example", "Server Example", 1, true},
{"empty cells", "mumble", "", "", "", 3, true},
} {
t.Run(test.name, func(t *testing.T) {
snapshot := Snapshot{ApplicationProcess: test.process, Role: "table cell", Name: test.label,
TableRowText: test.row, TableColumnCount: test.columns, GUITable: test.gui}
if got := mumbleTableRowText(snapshot); got != test.want {
t.Fatalf("row = %q, want %q", got, test.want)
}
})
}
}
func TestMumbleMessageText(t *testing.T) {
for _, test := range []struct{ input, want string }{
{"[12:34:56]", ""},
{" \ufdd0[12:34:56]\ufdef \n", ""},
{"[12:34:56] Username: hello\u2028world \ufdd0界\ufdef", "Username: hello world 界"},
{"Username: [12:34:56] hello", "Username: [12:34:56] hello"},
{"Username: hello\n\tworld", "Username: hello world"},
{" \n\ufdd0\ufdef", ""},
} {
if got := mumbleMessageText(test.input); got != test.want {
t.Errorf("cleanup %q = %q, want %q", test.input, got, test.want)
}
}
}