Skip to content

Commit

Permalink
Merge pull request fyne-io#4531 from Jacalz/deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz authored Jan 9, 2024
2 parents 057726e + 751df8c commit 8d62571
Show file tree
Hide file tree
Showing 33 changed files with 96 additions and 75 deletions.
7 changes: 4 additions & 3 deletions app/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"testing"

"fyne.io/fyne/v2"
"github.com/stretchr/testify/assert"

"fyne.io/fyne/v2/internal/build"
internalTest "fyne.io/fyne/v2/internal/test"
"fyne.io/fyne/v2/test"
"fyne.io/fyne/v2/theme"

"github.com/stretchr/testify/assert"
)

func TestSettingsBuildType(t *testing.T) {
Expand Down Expand Up @@ -100,7 +101,7 @@ func TestCustomTheme(t *testing.T) {
fyne.Theme
}
set := &settings{}
ctheme := &customTheme{theme.LightTheme()}
ctheme := &customTheme{internalTest.LightTheme(theme.DefaultTheme())}
set.SetTheme(ctheme)

set.setupTheme()
Expand Down
2 changes: 1 addition & 1 deletion cmd/fyne/internal/commands/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func openOutputFile(filePath string, noheader bool) (file *os.File, close func()
}

func sanitiseName(file, prefix string) string {
titled := strings.Title(file)
titled := strings.Title(file) //lint:ignore SA1019 This is fine for our use case.
name := filenameRegex.ReplaceAllString(titled, "")

return prefix + name
Expand Down
2 changes: 1 addition & 1 deletion cmd/fyne/internal/mobile/build_androidapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func goAndroidBuild(pkg *packages.Package, bundleID string, androidArchs []strin
buf.WriteString(`<?xml version="1.0" encoding="utf-8"?>`)
err := templates.ManifestAndroid.Execute(buf, manifestTmplData{
JavaPkgPath: bundleID,
Name: strings.Title(appName),
Name: strings.Title(appName), //lint:ignore SA1019 This is fine for our use case.
Debug: !buildRelease,
LibName: libName,
Version: version,
Expand Down
2 changes: 1 addition & 1 deletion cmd/fyne/internal/mobile/build_iosapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func goIOSBuild(pkg *packages.Package, bundleID string, archs []string,
infoplist := new(bytes.Buffer)
if err := infoplistTmpl.Execute(infoplist, infoplistTmplData{
BundleID: bundleID,
Name: strings.Title(appName),
Name: strings.Title(appName), //lint:ignore SA1019 This is fine for our use case.
Version: version,
Build: build,
Legacy: len(allArchs["ios"]) > 2,
Expand Down
2 changes: 1 addition & 1 deletion cmd/fyne/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func main() {
commands.Build(),

// Deprecated: Use "go mod vendor" instead.
commands.Vendor(),
commands.Vendor(), //lint:ignore SA1019 This whole tool is deprecated.
},
}

Expand Down
3 changes: 1 addition & 2 deletions cmd/fyne_demo/tutorials/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/cmd/fyne_demo/data"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)

Expand Down Expand Up @@ -115,7 +114,7 @@ func makeInnerWindowTab(_ fyne.Window) fyne.CanvasObject {
widget.NewButton("Tap Me", func() {
label.SetText("Tapped")
})))
win1.Icon = theme.FyneLogo()
win1.Icon = data.FyneLogo

win2 := container.NewInnerWindow("Inner2", widget.NewLabel("Win 2"))

Expand Down
2 changes: 1 addition & 1 deletion cmd/fyne_demo/tutorials/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (customTheme) Color(c fyne.ThemeColorName, _ fyne.ThemeVariant) color.Color
}

func (customTheme) Font(style fyne.TextStyle) fyne.Resource {
return theme.DarkTheme().Font(style)
return theme.DefaultTheme().Font(style)
}

func (customTheme) Icon(n fyne.ThemeIconName) fyne.Resource {
Expand Down
4 changes: 3 additions & 1 deletion container/apptabs_mobile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
internalTest "fyne.io/fyne/v2/internal/test"
"fyne.io/fyne/v2/test"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -160,7 +162,7 @@ func TestAppTabs_DynamicTabs(t *testing.T) {
func TestAppTabs_HoverButtons(t *testing.T) {
test.NewApp()
defer test.NewApp()
test.ApplyTheme(t, theme.LightTheme())
test.ApplyTheme(t, internalTest.LightTheme(theme.DefaultTheme()))

item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
Expand Down
4 changes: 3 additions & 1 deletion container/doctabs_mobile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
internalTest "fyne.io/fyne/v2/internal/test"
"fyne.io/fyne/v2/test"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -160,7 +162,7 @@ func TestDocTabs_DynamicTabs(t *testing.T) {
func TestDocTabs_HoverButtons(t *testing.T) {
test.NewApp()
defer test.NewApp()
test.ApplyTheme(t, theme.LightTheme())
test.ApplyTheme(t, internalTest.LightTheme(theme.DefaultTheme()))

item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
Expand Down
4 changes: 3 additions & 1 deletion dialog/form_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import (
"testing"

"fyne.io/fyne/v2"
internalTest "fyne.io/fyne/v2/internal/test"
"fyne.io/fyne/v2/test"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -87,7 +89,7 @@ func TestFormDialog_Hints(t *testing.T) {

test.NewApp()
defer test.NewApp()
test.ApplyTheme(t, theme.LightTheme())
test.ApplyTheme(t, internalTest.LightTheme(theme.DefaultTheme()))
w := test.NewWindow(nil)
w.SetFullScreen(true)

Expand Down
20 changes: 11 additions & 9 deletions driver/software/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,34 @@ import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
internalTest "fyne.io/fyne/v2/internal/test"
"fyne.io/fyne/v2/test"

"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)

func TestRender(t *testing.T) {
obj := widget.NewLabel("Hi")
test.AssertImageMatches(t, "label_dark.png", Render(obj, theme.DarkTheme()))
test.AssertImageMatches(t, "label_light.png", Render(obj, theme.LightTheme()))
test.AssertImageMatches(t, "label_dark.png", Render(obj, internalTest.DarkTheme(theme.DefaultTheme())))
test.AssertImageMatches(t, "label_light.png", Render(obj, internalTest.LightTheme(theme.DefaultTheme())))
}

func TestRender_State(t *testing.T) {
obj := widget.NewButtonWithIcon("Cancel", theme.CancelIcon(), func() {})
test.AssertImageMatches(t, "button.png", Render(obj, theme.DarkTheme()))
test.AssertImageMatches(t, "button.png", Render(obj, internalTest.DarkTheme(theme.DefaultTheme())))

obj.Importance = widget.HighImportance
obj.Refresh()
test.AssertImageMatches(t, "button_important.png", Render(obj, theme.DarkTheme()))
test.AssertImageMatches(t, "button_important.png", Render(obj, internalTest.DarkTheme(theme.DefaultTheme())))
}

func TestRender_Focus(t *testing.T) {
obj := widget.NewEntry()
test.AssertImageMatches(t, "entry.png", Render(obj, theme.DarkTheme()))
test.AssertImageMatches(t, "entry.png", Render(obj, internalTest.DarkTheme(theme.DefaultTheme())))

obj.FocusGained()
test.AssertImageMatches(t, "entry_focus.png", Render(obj, theme.DarkTheme()))
test.AssertImageMatches(t, "entry_focus.png", Render(obj, internalTest.DarkTheme(theme.DefaultTheme())))
}

func TestRenderCanvas(t *testing.T) {
Expand All @@ -46,9 +48,9 @@ func TestRenderCanvas(t *testing.T) {
c.SetContent(obj)

if fyne.CurrentDevice().IsMobile() {
test.AssertImageMatches(t, "canvas_mobile.png", RenderCanvas(c, theme.LightTheme()))
test.AssertImageMatches(t, "canvas_mobile.png", RenderCanvas(c, internalTest.LightTheme(theme.DefaultTheme())))
} else {
test.AssertImageMatches(t, "canvas.png", RenderCanvas(c, theme.LightTheme()))
test.AssertImageMatches(t, "canvas.png", RenderCanvas(c, internalTest.LightTheme(theme.DefaultTheme())))
}
}

Expand All @@ -61,5 +63,5 @@ func TestRender_ImageSize(t *testing.T) {

c := container.NewStack(image, bg)

test.AssertImageMatches(t, "image_size.png", Render(c, theme.LightTheme()))
test.AssertImageMatches(t, "image_size.png", Render(c, internalTest.LightTheme(theme.DefaultTheme())))
}
3 changes: 2 additions & 1 deletion internal/driver/glfw/canvas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
internalTest "fyne.io/fyne/v2/internal/test"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"

Expand Down Expand Up @@ -509,7 +510,7 @@ func TestGlCanvas_Scale(t *testing.T) {
}

func TestGlCanvas_SetContent(t *testing.T) {
fyne.CurrentApp().Settings().SetTheme(theme.DarkTheme())
fyne.CurrentApp().Settings().SetTheme(internalTest.DarkTheme(theme.DefaultTheme()))
var menuHeight float32
if hasNativeMenu() {
menuHeight = 0
Expand Down
7 changes: 4 additions & 3 deletions internal/driver/glfw/window_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/driver/desktop"
"fyne.io/fyne/v2/internal/scale"
internalTest "fyne.io/fyne/v2/internal/test"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/test"
"fyne.io/fyne/v2/theme"
Expand Down Expand Up @@ -305,7 +306,7 @@ func TestWindow_HandleHoverable(t *testing.T) {

func TestWindow_HandleOutsideHoverableObject(t *testing.T) {
w := createWindow("Test").(*window)
test.ApplyTheme(t, theme.DarkTheme())
test.ApplyTheme(t, internalTest.DarkTheme(theme.DefaultTheme()))
l := widget.NewList(
func() int { return 2 },
func() fyne.CanvasObject { return widget.NewEntry() },
Expand Down Expand Up @@ -1152,7 +1153,7 @@ func TestWindow_TappedSecondary_OnPrimaryOnlyTarget(t *testing.T) {

func TestWindow_TappedIgnoresScrollerClip(t *testing.T) {
w := createWindow("Test").(*window)
fyne.CurrentApp().Settings().SetTheme(theme.DarkTheme())
fyne.CurrentApp().Settings().SetTheme(internalTest.DarkTheme(theme.DefaultTheme()))
rect := canvas.NewRectangle(color.White)
rect.SetMinSize(fyne.NewSize(100, 100))
tapped := false
Expand Down Expand Up @@ -1435,7 +1436,7 @@ func TestWindow_SetPadded(t *testing.T) {
} else {
menuHeight = canvas.NewText("", color.Black).MinSize().Height + theme.Padding()*2
}
fyne.CurrentApp().Settings().SetTheme(theme.DarkTheme())
fyne.CurrentApp().Settings().SetTheme(internalTest.DarkTheme(theme.DefaultTheme()))
tests := []struct {
name string
padding bool
Expand Down
2 changes: 1 addition & 1 deletion staticcheck.conf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
checks = ["inherit", "-SA1019", "ST1003", "ST1016", "ST1020", "ST1021", "ST1022"]
checks = ["inherit", "ST1003", "ST1016", "ST1020", "ST1021", "ST1022"]
2 changes: 1 addition & 1 deletion test/markup_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ func knownResource(rsc fyne.Resource) string {
theme.FolderIcon(): "folderIcon",
theme.FolderNewIcon(): "folderNewIcon",
theme.FolderOpenIcon(): "folderOpenIcon",
theme.FyneLogo(): "fyneLogo",
theme.FyneLogo(): "fyneLogo", //lint:ignore SA1019 This needs to stay until the API is removed.
theme.HelpIcon(): "helpIcon",
theme.HistoryIcon(): "historyIcon",
theme.HomeIcon(): "homeIcon",
Expand Down
3 changes: 2 additions & 1 deletion test/testapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fyne.io/fyne/v2/internal/app"
"fyne.io/fyne/v2/internal/cache"
"fyne.io/fyne/v2/internal/painter"
"fyne.io/fyne/v2/internal/test"
"fyne.io/fyne/v2/theme"
)

Expand Down Expand Up @@ -216,7 +217,7 @@ func (s *testSettings) Theme() fyne.Theme {
defer s.propertyLock.RUnlock()

if s.theme == nil {
return theme.DarkTheme()
return test.DarkTheme(theme.DefaultTheme())
}

return s.theme
Expand Down
5 changes: 3 additions & 2 deletions tools/playground/playground.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/driver/software"
"fyne.io/fyne/v2/internal/test"
"fyne.io/fyne/v2/theme"
)

Expand All @@ -27,7 +28,7 @@ func imageToPlayground(img image.Image) {

// RenderCanvas takes a canvas and converts it into an inline image for showing in the playground
func RenderCanvas(c fyne.Canvas) {
imageToPlayground(software.RenderCanvas(c, theme.DarkTheme()))
imageToPlayground(software.RenderCanvas(c, test.DarkTheme(theme.DefaultTheme())))
}

// RenderWindow takes a window and converts it's canvas into an inline image for showing in the playground
Expand All @@ -37,5 +38,5 @@ func RenderWindow(w fyne.Window) {

// Render takes a canvasobject and converts it into an inline image for showing in the playground
func Render(obj fyne.CanvasObject) {
imageToPlayground(software.Render(obj, theme.DarkTheme()))
imageToPlayground(software.Render(obj, test.DarkTheme(theme.DefaultTheme())))
}
7 changes: 4 additions & 3 deletions widget/button_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/driver/desktop"
internalTest "fyne.io/fyne/v2/internal/test"
"fyne.io/fyne/v2/test"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
Expand Down Expand Up @@ -67,7 +68,7 @@ func TestButton_Tapped(t *testing.T) {
func TestButton_Disable(t *testing.T) {
test.NewApp()
defer test.NewApp()
test.ApplyTheme(t, theme.LightTheme())
test.ApplyTheme(t, internalTest.LightTheme(theme.DefaultTheme()))

tapped := false
button := widget.NewButtonWithIcon("Test", theme.HomeIcon(), func() {
Expand Down Expand Up @@ -138,7 +139,7 @@ func TestButton_LowImportance(t *testing.T) {
func TestButton_Hover(t *testing.T) {
test.NewApp()
defer test.NewApp()
test.ApplyTheme(t, theme.LightTheme())
test.ApplyTheme(t, internalTest.LightTheme(theme.DefaultTheme()))

b := widget.NewButtonWithIcon("Test", theme.HomeIcon(), func() {})
w := test.NewWindow(b)
Expand Down Expand Up @@ -324,7 +325,7 @@ func TestButtonCompatImportance(t *testing.T) {
func TestButtonSuccess(t *testing.T) {
test.NewApp()
defer test.NewApp()
test.ApplyTheme(t, theme.LightTheme())
test.ApplyTheme(t, internalTest.LightTheme(theme.DefaultTheme()))

b := widget.NewButtonWithIcon("Test", theme.HomeIcon(), func() {})
w := test.NewWindow(b)
Expand Down
12 changes: 6 additions & 6 deletions widget/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ type Entry struct {

// NewEntry creates a new single line entry widget.
func NewEntry() *Entry {
e := &Entry{Wrapping: fyne.TextTruncate}
e := &Entry{Wrapping: fyne.TextWrap(fyne.TextTruncateClip)}
e.ExtendBaseWidget(e)
return e
}
Expand All @@ -126,14 +126,14 @@ func NewEntryWithData(data binding.String) *Entry {

// NewMultiLineEntry creates a new entry that allows multiple lines
func NewMultiLineEntry() *Entry {
e := &Entry{MultiLine: true, Wrapping: fyne.TextTruncate}
e := &Entry{MultiLine: true, Wrapping: fyne.TextWrap(fyne.TextTruncateClip)}
e.ExtendBaseWidget(e)
return e
}

// NewPasswordEntry creates a new entry password widget
func NewPasswordEntry() *Entry {
e := &Entry{Password: true, Wrapping: fyne.TextTruncate}
e := &Entry{Password: true, Wrapping: fyne.TextWrap(fyne.TextTruncateClip)}
e.ExtendBaseWidget(e)
e.ActionItem = newPasswordRevealer(e)
return e
Expand Down Expand Up @@ -1356,13 +1356,13 @@ func (e *Entry) textProvider() *RichText {

// textWrap calculates the wrapping that we should apply.
func (e *Entry) textWrap() fyne.TextWrap {
if e.Wrapping == fyne.TextTruncate { // this is now the default - but we scroll around this large content
if e.Wrapping == fyne.TextWrap(fyne.TextTruncateClip) { // this is now the default - but we scroll around this large content
return fyne.TextWrapOff
}

if !e.MultiLine && (e.Wrapping == fyne.TextWrapBreak || e.Wrapping == fyne.TextWrapWord) {
fyne.LogError("Entry cannot wrap single line", nil)
e.Wrapping = fyne.TextTruncate
e.Wrapping = fyne.TextWrap(fyne.TextTruncateClip)
return fyne.TextWrapOff
}
return e.Wrapping
Expand Down Expand Up @@ -2026,7 +2026,7 @@ func (r *entryContentRenderer) updateScrollDirections() {
switch r.content.entry.Wrapping {
case fyne.TextWrapOff:
r.content.scroll.Direction = r.content.entry.Scroll
case fyne.TextTruncate: // this is now the default - but we scroll
case fyne.TextWrap(fyne.TextTruncateClip): // this is now the default - but we scroll
r.content.scroll.Direction = widget.ScrollBoth
default: // fyne.TextWrapBreak, fyne.TextWrapWord
r.content.scroll.Direction = widget.ScrollVerticalOnly
Expand Down
Loading

0 comments on commit 8d62571

Please sign in to comment.