Skip to content

Commit

Permalink
move from testCanvas to software canvas, fix a bunch of tests, break …
Browse files Browse the repository at this point in the history
…a few more
  • Loading branch information
chabad360 committed May 9, 2024
1 parent 3c3393a commit 2c1642f
Show file tree
Hide file tree
Showing 84 changed files with 1,166 additions and 1,627 deletions.
9 changes: 4 additions & 5 deletions app/app_software.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ import (
"image"

"fyne.io/fyne/v2"
software2 "fyne.io/fyne/v2/internal/driver/software"
"fyne.io/fyne/v2/internal/painter/software"
"fyne.io/fyne/v2/test"
"fyne.io/fyne/v2/internal/driver/software"
painter "fyne.io/fyne/v2/internal/painter/software"
)

// NewWithID returns a new app instance using the test (headless) driver.
// The ID string should be globally unique to this app.
func NewWithID(id string) fyne.App {
return newAppWithDriver(test.NewDriverWithPainter(software.NewPainter()), id)
return newAppWithDriver(software.NewDriverWithPainter(painter.NewPainter()), id)
}

// NewWithSoftwareDriver returns a new app instance using the Software (custom) driver.
// The ID string should be globally unique to this app.
func NewWithSoftwareDriver(id string, painter func(image.Image, []image.Rectangle), events chan any) fyne.App {
return newAppWithDriver(software2.NewDriver(painter, events), id)
return newAppWithDriver(software.NewDriver(painter, events), id)
}
5 changes: 2 additions & 3 deletions canvas/rectangle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/internal/cache"
"fyne.io/fyne/v2/internal/driver/software"
canvas2 "fyne.io/fyne/v2/internal/driver/software"
painter "fyne.io/fyne/v2/internal/painter/software"
"fyne.io/fyne/v2/test"

Expand Down Expand Up @@ -39,8 +39,7 @@ func TestRectangle_Radius(t *testing.T) {
rect.Resize(fyne.NewSize(50, 50))
test.AssertObjectRendersToMarkup(t, "rounded_rect.xml", rect)

c := software.NewCanvasWithPainter(painter.NewPainter())
c.Initialize(c, nil)
c := canvas2.NewCanvasWithPainter(painter.NewPainter())
c.SetContent(rect)
c.Resize(fyne.NewSize(60, 60))
test.AssertRendersToImage(t, "rounded_rect_stroke.png", c)
Expand Down
4 changes: 2 additions & 2 deletions container/apptabs_desktop_flakey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestAppTabs_ApplyTheme(t *testing.T) {
test.NewApp()
defer test.NewApp()

w := test.NewWindow(
w := software.NewWindow(
container.NewAppTabs(&container.TabItem{Text: "Test", Content: widget.NewLabel("Text")}),
)
defer w.Close()
Expand All @@ -36,7 +36,7 @@ func TestAppTabs_ChangeItemContent(t *testing.T) {
item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
tabs := container.NewAppTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand Down
15 changes: 8 additions & 7 deletions container/apptabs_desktop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/internal/driver/software"
"fyne.io/fyne/v2/test"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
Expand All @@ -23,7 +24,7 @@ func TestAppTabs_ChangeItemIcon(t *testing.T) {
item1 := &container.TabItem{Icon: theme.CancelIcon(), Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Icon: theme.ConfirmIcon(), Content: widget.NewLabel("Text2")}
tabs := container.NewAppTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand All @@ -47,7 +48,7 @@ func TestAppTabs_ChangeItemText(t *testing.T) {
item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
tabs := container.NewAppTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand All @@ -70,7 +71,7 @@ func TestAppTabs_DynamicTabs(t *testing.T) {

item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text 1")}
tabs := container.NewAppTabs(item1)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(300, 150))
Expand Down Expand Up @@ -123,7 +124,7 @@ func TestAppTabs_HoverButtons(t *testing.T) {
item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
tabs := container.NewAppTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand Down Expand Up @@ -151,7 +152,7 @@ func TestAppTabs_Layout(t *testing.T) {
test.NewApp()
defer test.NewApp()

w := test.NewWindow(nil)
w := software.NewWindow(nil)
defer w.Close()
w.SetPadded(false)
c := w.Canvas()
Expand Down Expand Up @@ -255,7 +256,7 @@ func TestAppTabs_SetTabLocation(t *testing.T) {
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text 2")}
item3 := &container.TabItem{Text: "Test3", Content: widget.NewLabel("Text 3")}
tabs := container.NewAppTabs(item1, item2, item3)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
c := w.Canvas()
Expand Down Expand Up @@ -288,7 +289,7 @@ func TestAppTabs_Tapped(t *testing.T) {
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text 2")}
item3 := &container.TabItem{Text: "Test3", Content: widget.NewLabel("Text 3")}
tabs := container.NewAppTabs(item1, item2, item3)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(200, 100))
Expand Down
4 changes: 2 additions & 2 deletions container/apptabs_mobile_flakey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestAppTabs_ApplyTheme(t *testing.T) {
test.NewApp()
defer test.NewApp()

w := test.NewWindow(
w := software.NewWindow(
container.NewAppTabs(&container.TabItem{Text: "Test", Content: widget.NewLabel("Text")}),
)
defer w.Close()
Expand All @@ -36,7 +36,7 @@ func TestAppTabs_ChangeItemContent(t *testing.T) {
item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
tabs := container.NewAppTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand Down
14 changes: 7 additions & 7 deletions container/apptabs_mobile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestAppTabs_ChangeItemIcon(t *testing.T) {
item1 := &container.TabItem{Icon: theme.CancelIcon(), Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Icon: theme.ConfirmIcon(), Content: widget.NewLabel("Text2")}
tabs := container.NewAppTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)

Check failure on line 27 in container/apptabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.19.x)

undefined: software

Check failure on line 27 in container/apptabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.21.x)

undefined: software
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand All @@ -48,7 +48,7 @@ func TestAppTabs_ChangeItemText(t *testing.T) {
item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
tabs := container.NewAppTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)

Check failure on line 51 in container/apptabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.19.x)

undefined: software

Check failure on line 51 in container/apptabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.21.x)

undefined: software
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand All @@ -71,7 +71,7 @@ func TestAppTabs_DynamicTabs(t *testing.T) {

item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text 1")}
tabs := container.NewAppTabs(item1)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)

Check failure on line 74 in container/apptabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.19.x)

undefined: software

Check failure on line 74 in container/apptabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.21.x)

undefined: software
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(300, 150))
Expand Down Expand Up @@ -125,7 +125,7 @@ func TestAppTabs_HoverButtons(t *testing.T) {
item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
tabs := container.NewAppTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)

Check failure on line 128 in container/apptabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.19.x)

undefined: software

Check failure on line 128 in container/apptabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.21.x)

undefined: software
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand All @@ -147,7 +147,7 @@ func TestAppTabs_Layout(t *testing.T) {
test.NewApp()
defer test.NewApp()

w := test.NewWindow(nil)
w := software.NewWindow(nil)

Check failure on line 150 in container/apptabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.19.x)

undefined: software

Check failure on line 150 in container/apptabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.21.x)

undefined: software
defer w.Close()
w.SetPadded(false)
c := w.Canvas()
Expand Down Expand Up @@ -251,7 +251,7 @@ func TestAppTabs_SetTabLocation(t *testing.T) {
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text 2")}
item3 := &container.TabItem{Text: "Test3", Content: widget.NewLabel("Text 3")}
tabs := container.NewAppTabs(item1, item2, item3)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)

Check failure on line 254 in container/apptabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.19.x)

undefined: software

Check failure on line 254 in container/apptabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.21.x)

undefined: software
defer w.Close()
w.SetPadded(false)
c := w.Canvas()
Expand Down Expand Up @@ -284,7 +284,7 @@ func TestAppTabs_Tapped(t *testing.T) {
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text 2")}
item3 := &container.TabItem{Text: "Test3", Content: widget.NewLabel("Text 3")}
tabs := container.NewAppTabs(item1, item2, item3)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)

Check failure on line 287 in container/apptabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.19.x)

undefined: software

Check failure on line 287 in container/apptabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.21.x)

undefined: software
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(200, 100))
Expand Down
19 changes: 10 additions & 9 deletions container/doctabs_desktop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/internal/driver/software"
"fyne.io/fyne/v2/test"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
Expand All @@ -20,7 +21,7 @@ func TestDocTabs_ApplyTheme(t *testing.T) {
test.NewApp()
defer test.NewApp()

w := test.NewWindow(
w := software.NewWindow(
container.NewDocTabs(&container.TabItem{Text: "Test", Content: widget.NewLabel("Text")}),
)
defer w.Close()
Expand All @@ -41,7 +42,7 @@ func TestDocTabs_ChangeItemContent(t *testing.T) {
item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
tabs := container.NewDocTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand All @@ -65,7 +66,7 @@ func TestDocTabs_ChangeItemIcon(t *testing.T) {
item1 := &container.TabItem{Icon: theme.CancelIcon(), Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Icon: theme.ConfirmIcon(), Content: widget.NewLabel("Text2")}
tabs := container.NewDocTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand All @@ -89,7 +90,7 @@ func TestDocTabs_ChangeItemText(t *testing.T) {
item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
tabs := container.NewDocTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand Down Expand Up @@ -118,7 +119,7 @@ func TestDocTabs_DynamicTabs(t *testing.T) {

item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text 1")}
tabs := container.NewDocTabs(item1)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(300, 150))
Expand Down Expand Up @@ -174,7 +175,7 @@ func TestDocTabs_HoverButtons(t *testing.T) {
tabs.CreateTab = func() *container.TabItem {
return &container.TabItem{Text: "Another", Content: widget.NewLabel("Another Tab")}
}
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand Down Expand Up @@ -205,7 +206,7 @@ func TestDocTabs_Layout(t *testing.T) {
test.NewApp()
defer test.NewApp()

w := test.NewWindow(nil)
w := software.NewWindow(nil)
defer w.Close()
w.SetPadded(false)
c := w.Canvas()
Expand Down Expand Up @@ -309,7 +310,7 @@ func TestDocTabs_SetTabLocation(t *testing.T) {
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text 2")}
item3 := &container.TabItem{Text: "Test3", Content: widget.NewLabel("Text 3")}
tabs := container.NewDocTabs(item1, item2, item3)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
c := w.Canvas()
Expand Down Expand Up @@ -345,7 +346,7 @@ func TestDocTabs_Tapped(t *testing.T) {
tabs.CreateTab = func() *container.TabItem {
return &container.TabItem{Text: "Another", Content: widget.NewLabel("Another Tab")}
}
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(300, 100))
Expand Down
18 changes: 9 additions & 9 deletions container/doctabs_mobile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestDocTabs_ApplyTheme(t *testing.T) {
test.NewApp()
defer test.NewApp()

w := test.NewWindow(
w := software.NewWindow(

Check failure on line 24 in container/doctabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.19.x)

undefined: software

Check failure on line 24 in container/doctabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.21.x)

undefined: software
container.NewDocTabs(&container.TabItem{Text: "Test", Content: widget.NewLabel("Text")}),
)
defer w.Close()
Expand All @@ -42,7 +42,7 @@ func TestDocTabs_ChangeItemContent(t *testing.T) {
item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
tabs := container.NewDocTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)

Check failure on line 45 in container/doctabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.19.x)

undefined: software

Check failure on line 45 in container/doctabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.21.x)

undefined: software
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand All @@ -66,7 +66,7 @@ func TestDocTabs_ChangeItemIcon(t *testing.T) {
item1 := &container.TabItem{Icon: theme.CancelIcon(), Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Icon: theme.ConfirmIcon(), Content: widget.NewLabel("Text2")}
tabs := container.NewDocTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)

Check failure on line 69 in container/doctabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.19.x)

undefined: software

Check failure on line 69 in container/doctabs_mobile_test.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.21.x)

undefined: software
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand All @@ -90,7 +90,7 @@ func TestDocTabs_ChangeItemText(t *testing.T) {
item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
tabs := container.NewDocTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand All @@ -113,7 +113,7 @@ func TestDocTabs_DynamicTabs(t *testing.T) {

item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text 1")}
tabs := container.NewDocTabs(item1)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(300, 150))
Expand Down Expand Up @@ -167,7 +167,7 @@ func TestDocTabs_HoverButtons(t *testing.T) {
item1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Text1")}
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text2")}
tabs := container.NewDocTabs(item1, item2)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(150, 150))
Expand Down Expand Up @@ -198,7 +198,7 @@ func TestDocTabs_Layout(t *testing.T) {
test.NewApp()
defer test.NewApp()

w := test.NewWindow(nil)
w := software.NewWindow(nil)
defer w.Close()
w.SetPadded(false)
c := w.Canvas()
Expand Down Expand Up @@ -303,7 +303,7 @@ func TestDocTabs_SetTabLocation(t *testing.T) {
item2 := &container.TabItem{Text: "Test2", Content: widget.NewLabel("Text 2")}
item3 := &container.TabItem{Text: "Test3", Content: widget.NewLabel("Text 3")}
tabs := container.NewDocTabs(item1, item2, item3)
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
c := w.Canvas()
Expand Down Expand Up @@ -339,7 +339,7 @@ func TestDocTabs_Tapped(t *testing.T) {
tabs.CreateTab = func() *container.TabItem {
return &container.TabItem{Text: "Another", Content: widget.NewLabel("Another Tab")}
}
w := test.NewWindow(tabs)
w := software.NewWindow(tabs)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(380, 100))
Expand Down
Loading

0 comments on commit 2c1642f

Please sign in to comment.