Cthulhu is no longer a fork. Now it is a screen reader written in Golang.
This commit is contained in:
1 parent
a998fe67de
commit
069fc674dc
708 files changed
+112482
-532
No files matched your search
@@ -0,0 +1,81 @@
|
||||
// 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/config"
|
||||
)
|
||||
|
||||
func TestCharacterAttributeColorSettingChangesSpokenValues(t *testing.T) {
|
||||
attributes := map[string]string{
|
||||
"family-name": "Liberation Sans, Sans",
|
||||
"weight": "700",
|
||||
"underline": "none",
|
||||
"fg-color": "rgb(65535, 0, 0)",
|
||||
"bg-color": "#0000ff",
|
||||
"text-spelling": "spelling",
|
||||
}
|
||||
named := strings.Join(spokenCharacterAttributes(attributes, true), ", ")
|
||||
for _, want := range []string{"font family: Liberation Sans", "bold", "misspelled", "foreground color: red", "background color: blue"} {
|
||||
if !strings.Contains(named, want) {
|
||||
t.Errorf("named attributes %q missing %q", named, want)
|
||||
}
|
||||
}
|
||||
if strings.Contains(named, "underline") {
|
||||
t.Errorf("default underline was spoken: %q", named)
|
||||
}
|
||||
numeric := strings.Join(spokenCharacterAttributes(attributes, false), ", ")
|
||||
for _, want := range []string{"foreground color: 255 0 0", "background color: 0 0 255"} {
|
||||
if !strings.Contains(numeric, want) {
|
||||
t.Errorf("numeric attributes %q missing %q", numeric, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfiguredCharacterAttributesRespectSelectionAndOrder(t *testing.T) {
|
||||
settings := config.DefaultTextAttributes()
|
||||
for index := range settings.Choices {
|
||||
settings.Choices[index].Speak = false
|
||||
}
|
||||
settings.Choices[0], settings.Choices[2] = settings.Choices[2], settings.Choices[0]
|
||||
settings.Choices[0].Speak, settings.Choices[2].Speak = true, true
|
||||
got := strings.Join(spokenCharacterAttributes(map[string]string{"size": "14", "weight": "700", "underline": "single"}, true, settings), ", ")
|
||||
if got != "bold, font size: 14" {
|
||||
t.Fatalf("attributes = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSpellingAttributeUsesProviderInvalidValue(t *testing.T) {
|
||||
settings := config.DefaultTextAttributes()
|
||||
for index := range settings.Choices {
|
||||
settings.Choices[index].Speak = settings.Choices[index].Key == "text-spelling"
|
||||
}
|
||||
got := strings.Join(spokenCharacterAttributes(map[string]string{"invalid": "spelling"}, true, settings), ", ")
|
||||
if got != "misspelled" {
|
||||
t.Fatalf("spelling attribute = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCharacterAttributeColorParsingAndFallback(t *testing.T) {
|
||||
for _, probe := range []struct {
|
||||
input, want string
|
||||
}{
|
||||
{"#f00", "red"},
|
||||
{"rgb(255, 0, 0)", "red"},
|
||||
{"rgb(65535, 0, 0)", "red"},
|
||||
{"#fefefe", "white"},
|
||||
} {
|
||||
got, ok := describeAttributeColor(probe.input, true)
|
||||
if !ok || got != probe.want {
|
||||
t.Errorf("%q: %q, %v; want %q", probe.input, got, ok, probe.want)
|
||||
}
|
||||
}
|
||||
if got := strings.Join(spokenCharacterAttributes(map[string]string{"fg-color": "transparent"}, true), ", "); got != "foreground color: transparent" {
|
||||
t.Errorf("unsupported provider color changed: %q", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user