mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 15:45:38 +00:00
52ccc183b5
The previous change fixed a regression where minimum constraints larger than 0 would not affect the button. This change moves the minimum constraints one level lower so the content widget will see them as well. The wrapping layout.Center ensures that any misbehaving widgets still end up centered. Add a test to lock in the new behaviour and the previous fix. Signed-off-by: Elias Naur <mail@eliasnaur.com>
26 lines
558 B
Go
26 lines
558 B
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
package material
|
|
|
|
import (
|
|
"image"
|
|
"testing"
|
|
|
|
"gioui.org/layout"
|
|
"gioui.org/widget"
|
|
)
|
|
|
|
func TestButtonLayout(t *testing.T) {
|
|
var gtx layout.Context
|
|
gtx.Reset(nil, image.Point{X: 100, Y: 100})
|
|
|
|
ButtonLayout{}.Layout(>x, new(widget.Button), func() {
|
|
if got, exp := gtx.Constraints.Width.Min, 100; got != exp {
|
|
t.Errorf("minimum width is %d, expected %d", got, exp)
|
|
}
|
|
if got, exp := gtx.Constraints.Height.Min, 100; got != exp {
|
|
t.Errorf("minimum width is %d, expected %d", got, exp)
|
|
}
|
|
})
|
|
}
|