Skip to content

Commit

Permalink
[test] canvas has reduced interactive area on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
toaster committed May 27, 2024
1 parent 583a46e commit cc695c1
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 4 deletions.
4 changes: 0 additions & 4 deletions test/canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,6 @@ func (c *canvas) Focused() fyne.Focusable {
return c.focusManager().Focused()
}

func (c *canvas) InteractiveArea() (fyne.Position, fyne.Size) {
return fyne.Position{}, c.Size()
}

func (c *canvas) OnTypedKey() func(*fyne.KeyEvent) {
c.propertyLock.RLock()
defer c.propertyLock.RUnlock()
Expand Down
9 changes: 9 additions & 0 deletions test/canvas_desktop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build !mobile

package test

import "fyne.io/fyne/v2"

func (c *canvas) InteractiveArea() (fyne.Position, fyne.Size) {
return fyne.Position{}, c.Size()
}
19 changes: 19 additions & 0 deletions test/canvas_desktop_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//go:build !mobile

package test

import (
"testing"

"github.com/stretchr/testify/assert"

"fyne.io/fyne/v2"
)

func Test_canvas_InteractiveArea(t *testing.T) {
c := NewCanvas()
c.Resize(fyne.NewSize(600, 400))
pos, size := c.InteractiveArea()
assert.Equal(t, fyne.NewPos(0, 0), pos)
assert.Equal(t, fyne.NewSize(600, 400), size)
}
9 changes: 9 additions & 0 deletions test/canvas_mobile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build mobile

package test

import "fyne.io/fyne/v2"

func (c *canvas) InteractiveArea() (fyne.Position, fyne.Size) {
return fyne.NewPos(17, 42), c.Size().SubtractWidthHeight(88, 66)
}
19 changes: 19 additions & 0 deletions test/canvas_mobile_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//go:build mobile

package test

import (
"testing"

"github.com/stretchr/testify/assert"

"fyne.io/fyne/v2"
)

func Test_canvas_InteractiveArea(t *testing.T) {
c := NewCanvas()
c.Resize(fyne.NewSize(600, 400))
pos, size := c.InteractiveArea()
assert.Equal(t, fyne.NewPos(17, 42), pos)
assert.Equal(t, fyne.NewSize(512, 334), size)
}

0 comments on commit cc695c1

Please sign in to comment.