Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ because it turns other people's test suites red.

### Changed

- **The list of formats is grouped by kind and can be filtered.** The open
list stands under headings - Archives, Documents, Pictures, Sound, Text and
data - each saying how many formats are under it, and a box at its top
narrows it to the formats whose name holds what is typed, or whose kind
has a word that starts with it (`gz` finds `targz`, `pict` every picture,
`data` every text and data format). The letters that
matched are drawn in bold, the arrows step over the headings, and typing
at the shut `Format` menu opens the list with those letters in the box, so
`jxl` typed there ends on `jxl`. The shut menu draws the kind of the format
it holds, and archives are drawn as a folder rather than as three bars that
looked like text. The command line lists the formats in one alphabetical
order as before.
Comment thread
coderabbitai[bot] marked this conversation as resolved.

- **The window lays its forms out in columns.** A field now takes as many
columns of the form as its value needs and no more, so `Format`, `Size`,
`How many files` and `Damage` stand in one row instead of one under another,
Expand Down
45 changes: 36 additions & 9 deletions internal/guard/dropdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"testing"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/test"

"github.com/donislawdev/TestingFilesGenerator/internal/format"
"github.com/donislawdev/TestingFilesGenerator/internal/gui/parts"
Expand All @@ -24,11 +26,10 @@ import (
// starting with it, collapsed or expanded - and NN/g lists typing a letter
// among the things a dropdown has to support.
func TestALetterTypedAtTheShutListMovesToThatValue(t *testing.T) {
_, content := screenOnACanvas(t)
menu := chooserUnder(t, content, text.FieldFormat())
menu, _ := aMenuWithoutAFilter(t)

// csv is where a fresh screen starts, so p has to reach pdf and png rather
// than the first value in the list.
// csv is where it starts, so p has to reach pdf and png rather than the
// first value in the list.
menu.TypedRune('p')
if menu.Selected != "pdf" {
t.Errorf("p was typed at a list showing csv and it holds %q, where pdf is the first value starting with p", menu.Selected)
Expand All @@ -46,7 +47,7 @@ func TestALetterTypedAtTheShutListMovesToThatValue(t *testing.T) {
// clearing it.
menu.TypedRune('q')
if menu.Selected != "png" {
t.Errorf("a letter no format starts with changed the value to %q", menu.Selected)
t.Errorf("a letter no value starts with changed the value to %q", menu.Selected)
}
}

Expand All @@ -56,8 +57,7 @@ func TestALetterTypedAtTheShutListMovesToThatValue(t *testing.T) {
// nothing is settled until Enter, which is what the ARIA practices ask for and
// what stops a held key from committing a value nobody looked at.
func TestALetterTypedAtTheOpenListMovesTheKeyboard(t *testing.T) {
_, content := screenOnACanvas(t)
menu := chooserUnder(t, content, text.FieldFormat())
menu, _ := aMenuWithoutAFilter(t)
menu.Tapped(&fyne.PointEvent{})

list := menu.Opened()
Expand All @@ -76,6 +76,31 @@ func TestALetterTypedAtTheOpenListMovesTheKeyboard(t *testing.T) {
}
}

// aMenuWithoutAFilter is a menu of a few values sharing first letters, in a
// window, showing csv.
//
// A menu of its own rather than the format menu on a screen, since
// 2026-09-23: the list of formats has a filter now, and a letter typed at it
// goes into the filter (formatlist_test.go). Every other menu in the window
// keeps the jump these two guards are about - and a subset of the formats is
// exactly a menu without one, which this asserts rather than assumes.
func aMenuWithoutAFilter(t *testing.T) (*parts.Chooser, fyne.Window) {
t.Helper()
app := test.NewApp()
app.Settings().SetTheme(parts.Theme())
t.Cleanup(func() { test.NewApp() })

menu := parts.NewChooser([]string{"csv", "pdf", "png", "txt", "wav"}, nil)
if menu.Filtered {
t.Fatal("a menu of five values opens with a filter, so these guards would be asking about the filter")
}
menu.SetSelected("csv")
w := test.NewWindow(container.NewVBox(menu))
t.Cleanup(w.Close)
w.Resize(fyne.NewSize(400, 600))
return menu, w
}

// A press opens the list without painting the keyboard's place in it.
//
// The same rule as everywhere else in this window, and it needs saying here
Expand Down Expand Up @@ -154,11 +179,13 @@ func formatListRowsShownIn(t *testing.T, height float32) float32 {
menu := chooserUnder(t, content, text.FieldFormat())
menu.Tapped(&fyne.PointEvent{})
pop := popUpIn(canvas.Overlays().Top())
if pop == nil {
if pop == nil || menu.Opened() == nil {
t.Fatalf("the press opened no list on the canvas %.0f px tall", height)
}
// The filter box at the top is not a row, so the rows are what is under
// it. Since 2026-09-23 - see parts.RoomForList for the head.
tall := pop.Size().Height
shown := tall / row
shown := (tall - menu.Opened().HeadHeight()) / row
if tall > height/2+0.5 {
t.Errorf("the open list is %.0f px tall in a window %.0f px tall, which is more than half of it.\n"+
"Reason: an open list that covers the form takes the context away from the person reading it.\n"+
Expand Down
10 changes: 10 additions & 0 deletions internal/guard/filekindicon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,19 @@ func TestTheFormatMenuDrawsThePictureOfEachKind(t *testing.T) {
if len(rows) == 0 {
t.Fatal("the list that dropped down is drawing no rows")
}
values := 0
for _, row := range rows {
// A heading names a kind and draws no picture of one, on purpose -
// see TestTheFormatListStandsUnderAHeadingForEachKind.
if row.Heading() {
continue
}
values++
if row.Kind() == nil {
t.Errorf("the row for %q draws no picture, so the kinds stop at the table", row.Label())
}
}
if values == 0 {
t.Fatal("the list drew headings and no value, so no picture was asked about")
}
}
Loading
Loading