Skip to content

Commit

Permalink
update resource names in button and check internal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Jan 24, 2024
1 parent b949478 commit 45bca5d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions widget/button_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package widget
import (
"fmt"
"image/color"
"strings"
"testing"

"fyne.io/fyne/v2"
Expand Down Expand Up @@ -78,7 +79,7 @@ func TestButton_DisabledIcon(t *testing.T) {
assert.Equal(t, render.icon.Resource.Name(), theme.CancelIcon().Name())

button.Disable()
assert.Equal(t, render.icon.Resource.Name(), fmt.Sprintf("disabled_%v", theme.CancelIcon().Name()))
assert.True(t, strings.HasPrefix(render.icon.Resource.Name(), "disabled_"))

button.Enable()
assert.Equal(t, render.icon.Resource.Name(), theme.CancelIcon().Name())
Expand All @@ -91,7 +92,7 @@ func TestButton_DisabledIconChangeUsingSetIcon(t *testing.T) {

// assert we are using the disabled original icon
button.Disable()
assert.Equal(t, render.icon.Resource.Name(), fmt.Sprintf("disabled_%v", theme.CancelIcon().Name()))
assert.True(t, strings.HasPrefix(render.icon.Resource.Name(), "disabled_"))

// re-enable, then change the icon
button.Enable()
Expand All @@ -100,8 +101,7 @@ func TestButton_DisabledIconChangeUsingSetIcon(t *testing.T) {

// assert we are using the disabled new icon
button.Disable()
assert.Equal(t, render.icon.Resource.Name(), fmt.Sprintf("disabled_%v", theme.SearchIcon().Name()))

assert.True(t, strings.HasPrefix(render.icon.Resource.Name(), "disabled_"))
}

func TestButton_DisabledIconChangedDirectly(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions widget/check_internal_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package widget

import (
"fmt"
"image/color"
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -47,19 +47,19 @@ func TestCheck_DisabledWhenChecked(t *testing.T) {
check.SetChecked(true)
render := test.WidgetRenderer(check).(*checkRenderer)

assert.Equal(t, fmt.Sprintf("primary_%v", theme.CheckButtonCheckedIcon().Name()), render.icon.Resource.Name())
assert.True(t, strings.HasPrefix(render.icon.Resource.Name(), "primary_"))

check.Disable()
assert.Equal(t, fmt.Sprintf("disabled_%v", theme.CheckButtonCheckedIcon().Name()), render.icon.Resource.Name())
assert.True(t, strings.HasPrefix(render.icon.Resource.Name(), "disabled_"))
}

func TestCheck_DisabledWhenUnchecked(t *testing.T) {
check := NewCheck("Hi", nil)
render := test.WidgetRenderer(check).(*checkRenderer)
assert.Equal(t, fmt.Sprintf("inputBorder_%v", theme.CheckButtonIcon().Name()), render.icon.Resource.Name())
assert.True(t, strings.HasPrefix(render.icon.Resource.Name(), "inputBorder_"))

check.Disable()
assert.Equal(t, fmt.Sprintf("disabled_%v", theme.CheckButtonIcon().Name()), render.icon.Resource.Name())
assert.True(t, strings.HasPrefix(render.icon.Resource.Name(), "disabled_"))
}

func TestCheckIsDisabledByDefault(t *testing.T) {
Expand Down

0 comments on commit 45bca5d

Please sign in to comment.