Skip to content

Commit

Permalink
make tests for SetColumns
Browse files Browse the repository at this point in the history
  • Loading branch information
BieHDC committed Dec 28, 2024
1 parent 4a7afdd commit afb7e94
Show file tree
Hide file tree
Showing 49 changed files with 7,741 additions and 0 deletions.
109 changes: 109 additions & 0 deletions widget/check_group_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package widget_test

import (
"fmt"
"testing"

"fyne.io/fyne/v2"
Expand Down Expand Up @@ -217,3 +218,111 @@ func TestCheckGroup_ManipulateOptions(t *testing.T) {
assert.Equal(t, 1, len(check.Options))
assert.Equal(t, 0, len(check.Selected))
}

func TestCheckGroup_LayoutColumns(t *testing.T) {
lotsofoptions := []string{}
for i := 0; i < 50; i++ {
lotsofoptions = append(lotsofoptions, fmt.Sprintf("Test %d", i))
}

testmap := map[string]struct {
disabled bool
horizontal bool
options []string
selected []string
}{
"single": {
options: []string{"Test"},
},
"single_disabled": {
disabled: true,
options: []string{"Test"},
},
"single_horizontal": {
horizontal: true,
options: []string{"Test"},
},
"single_horizontal_disabled": {
disabled: true,
horizontal: true,
options: []string{"Test"},
},
"single_selected": {
options: []string{"Test"},
selected: []string{"Test"},
},
"single_selected_disabled": {
disabled: true,
options: []string{"Test"},
selected: []string{"Test"},
},
"single_selected_horizontal": {
horizontal: true,
options: []string{"Test"},
selected: []string{"Test"},
},
"single_selected_horizontal_disabled": {
disabled: true,
horizontal: true,
options: []string{"Test"},
selected: []string{"Test"},
},
"multiple": {
options: lotsofoptions,
},
"multiple_disabled": {
disabled: true,
options: lotsofoptions,
},
"multiple_horizontal": {
horizontal: true,
options: lotsofoptions,
},
"multiple_horizontal_disabled": {
disabled: true,
horizontal: true,
options: lotsofoptions,
},
"multiple_selected": {
options: lotsofoptions,
selected: []string{lotsofoptions[0], lotsofoptions[5]},
},
"multiple_selected_disabled": {
disabled: true,
options: lotsofoptions,
selected: []string{lotsofoptions[0], lotsofoptions[5]},
},
"multiple_selected_horizontal": {
horizontal: true,
options: lotsofoptions,
selected: []string{lotsofoptions[0], lotsofoptions[5]},
},
"multiple_selected_horizontal_disabled": {
disabled: true,
horizontal: true,
options: lotsofoptions,
selected: []string{lotsofoptions[0], lotsofoptions[5]},
},
}

for _, i := range []int{-2, 2, 5} {
for name, tt := range testmap {
t.Run(name, func(t *testing.T) {
check := &widget.CheckGroup{
Horizontal: tt.horizontal,
Options: tt.options,
Selected: tt.selected,
}
check.SetColumns(i)
if tt.disabled {
check.Disable()
}

window := test.NewTempWindow(t, check)
window.Resize(check.MinSize().Max(fyne.NewSize(1500, 1500)))

test.AssertRendersToMarkup(t, fmt.Sprintf("check_group/layout_columns_%d_%s.xml", i, name), window.Canvas())
})
}
}
}
306 changes: 306 additions & 0 deletions widget/testdata/check_group/layout_columns_-2_multiple.xml

Large diffs are not rendered by default.

306 changes: 306 additions & 0 deletions widget/testdata/check_group/layout_columns_-2_multiple_disabled.xml

Large diffs are not rendered by default.

306 changes: 306 additions & 0 deletions widget/testdata/check_group/layout_columns_-2_multiple_horizontal.xml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

306 changes: 306 additions & 0 deletions widget/testdata/check_group/layout_columns_-2_multiple_selected.xml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions widget/testdata/check_group/layout_columns_-2_single.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<canvas padded size="1500x1500">
<content>
<widget pos="4,4" size="1492x1492" type="*widget.CheckGroup">
<widget size="1492x1492" type="*widget.Check">
<circle pos="2,732" size="28x28"/>
<image pos="6,736" rsc="checkButtonFillIcon" size="iconInlineSize" themed="inputBackground"/>
<image pos="6,736" rsc="checkButtonIcon" size="iconInlineSize" themed="inputBorder"/>
<text pos="32,0" size="1460x1492">Test</text>
</widget>
</widget>
</content>
</canvas>
12 changes: 12 additions & 0 deletions widget/testdata/check_group/layout_columns_-2_single_disabled.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<canvas padded size="1500x1500">
<content>
<widget pos="4,4" size="1492x1492" type="*widget.CheckGroup">
<widget size="1492x1492" type="*widget.Check">
<circle pos="2,732" size="28x28"/>
<image pos="6,736" rsc="checkButtonFillIcon" size="iconInlineSize" themed="background"/>
<image pos="6,736" rsc="checkButtonIcon" size="iconInlineSize" themed="disabled"/>
<text color="disabled" pos="32,0" size="1460x1492">Test</text>
</widget>
</widget>
</content>
</canvas>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<canvas padded size="1500x1500">
<content>
<widget pos="4,4" size="1492x1492" type="*widget.CheckGroup">
<widget size="1492x1492" type="*widget.Check">
<circle pos="2,732" size="28x28"/>
<image pos="6,736" rsc="checkButtonFillIcon" size="iconInlineSize" themed="inputBackground"/>
<image pos="6,736" rsc="checkButtonIcon" size="iconInlineSize" themed="inputBorder"/>
<text pos="32,0" size="1460x1492">Test</text>
</widget>
</widget>
</content>
</canvas>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<canvas padded size="1500x1500">
<content>
<widget pos="4,4" size="1492x1492" type="*widget.CheckGroup">
<widget size="1492x1492" type="*widget.Check">
<circle pos="2,732" size="28x28"/>
<image pos="6,736" rsc="checkButtonFillIcon" size="iconInlineSize" themed="background"/>
<image pos="6,736" rsc="checkButtonIcon" size="iconInlineSize" themed="disabled"/>
<text color="disabled" pos="32,0" size="1460x1492">Test</text>
</widget>
</widget>
</content>
</canvas>
12 changes: 12 additions & 0 deletions widget/testdata/check_group/layout_columns_-2_single_selected.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<canvas padded size="1500x1500">
<content>
<widget pos="4,4" size="1492x1492" type="*widget.CheckGroup">
<widget size="1492x1492" type="*widget.Check">
<circle pos="2,732" size="28x28"/>
<image pos="6,736" rsc="checkButtonFillIcon" size="iconInlineSize" themed="background"/>
<image pos="6,736" rsc="checkButtonCheckedIcon" size="iconInlineSize" themed="primary"/>
<text pos="32,0" size="1460x1492">Test</text>
</widget>
</widget>
</content>
</canvas>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<canvas padded size="1500x1500">
<content>
<widget pos="4,4" size="1492x1492" type="*widget.CheckGroup">
<widget size="1492x1492" type="*widget.Check">
<circle pos="2,732" size="28x28"/>
<image pos="6,736" rsc="checkButtonFillIcon" size="iconInlineSize" themed="background"/>
<image pos="6,736" rsc="checkButtonCheckedIcon" size="iconInlineSize" themed="disabled"/>
<text color="disabled" pos="32,0" size="1460x1492">Test</text>
</widget>
</widget>
</content>
</canvas>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<canvas padded size="1500x1500">
<content>
<widget pos="4,4" size="1492x1492" type="*widget.CheckGroup">
<widget size="1492x1492" type="*widget.Check">
<circle pos="2,732" size="28x28"/>
<image pos="6,736" rsc="checkButtonFillIcon" size="iconInlineSize" themed="background"/>
<image pos="6,736" rsc="checkButtonCheckedIcon" size="iconInlineSize" themed="primary"/>
<text pos="32,0" size="1460x1492">Test</text>
</widget>
</widget>
</content>
</canvas>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<canvas padded size="1500x1500">
<content>
<widget pos="4,4" size="1492x1492" type="*widget.CheckGroup">
<widget size="1492x1492" type="*widget.Check">
<circle pos="2,732" size="28x28"/>
<image pos="6,736" rsc="checkButtonFillIcon" size="iconInlineSize" themed="background"/>
<image pos="6,736" rsc="checkButtonCheckedIcon" size="iconInlineSize" themed="disabled"/>
<text color="disabled" pos="32,0" size="1460x1492">Test</text>
</widget>
</widget>
</content>
</canvas>
Loading

0 comments on commit afb7e94

Please sign in to comment.