Skip to content

Commit

Permalink
[test] add test for known colors in markup renderer
Browse files Browse the repository at this point in the history
This adds the missing color names to the detection.
  • Loading branch information
toaster committed Jun 8, 2024
1 parent 4d089da commit 762e2bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/markup_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,17 +406,21 @@ func knownColor(c color.Color) string {
nrgbaColor(theme.ForegroundColor()): "foreground",
nrgbaColor(theme.Color(theme.ColorNameHeaderBackground)): "headerBackground",
nrgbaColor(theme.HoverColor()): "hover",
nrgbaColor(theme.Color(theme.ColorNameHyperlink)): "hyperlink",
nrgbaColor(theme.InputBackgroundColor()): "inputBackground",
nrgbaColor(theme.InputBorderColor()): "inputBorder",
nrgbaColor(theme.MenuBackgroundColor()): "menuBackground",
nrgbaColor(theme.Color(theme.ColorNameOnPrimary)): "onPrimary",
nrgbaColor(theme.OverlayBackgroundColor()): "overlayBackground",
nrgbaColor(theme.PlaceHolderColor()): "placeholder",
nrgbaColor(theme.Color(theme.ColorNamePressed)): "pressed",
nrgbaColor(theme.PrimaryColor()): "primary",
nrgbaColor(theme.ScrollBarColor()): "scrollbar",
nrgbaColor(theme.SelectionColor()): "selection",
nrgbaColor(theme.Color(theme.ColorNameSeparator)): "separator",
nrgbaColor(theme.Color(theme.ColorNameSuccess)): "success",
nrgbaColor(theme.ShadowColor()): "shadow",
nrgbaColor(theme.Color(theme.ColorNameWarning)): "warning",
}[nrgbaColor(c)]
}

Expand Down
6 changes: 6 additions & 0 deletions test/markup_renderer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ import (
"fyne.io/fyne/v2/widget"
)

func Test_knownColor(t *testing.T) {
for _, name := range knownColorNames {
assert.NotEmpty(t, knownColor(theme.Color(name)), "color name %s is not known", name)
}
}

func Test_snapshot(t *testing.T) {
// content elements
for name, tt := range map[string]struct {
Expand Down

0 comments on commit 762e2bc

Please sign in to comment.