From 45bca5d5078dbbb15cab11c2918afaad46b1f8ba Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Tue, 23 Jan 2024 19:11:17 -0800 Subject: [PATCH] update resource names in button and check internal tests --- widget/button_internal_test.go | 8 ++++---- widget/check_internal_test.go | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/widget/button_internal_test.go b/widget/button_internal_test.go index 4a8f97eeee..38d53f2a58 100644 --- a/widget/button_internal_test.go +++ b/widget/button_internal_test.go @@ -3,6 +3,7 @@ package widget import ( "fmt" "image/color" + "strings" "testing" "fyne.io/fyne/v2" @@ -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()) @@ -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() @@ -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) { diff --git a/widget/check_internal_test.go b/widget/check_internal_test.go index 221a95efd2..6e821ea390 100644 --- a/widget/check_internal_test.go +++ b/widget/check_internal_test.go @@ -1,8 +1,8 @@ package widget import ( - "fmt" "image/color" + "strings" "testing" "github.com/stretchr/testify/assert" @@ -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) {