forked from fyne-io/fyne
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request fyne-io#1920 from zdima/zdima-patch-1
The onConfirm callback should be called only when user click on 'Ok' of a EntryDialog dialog.
- Loading branch information
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package dialog | ||
|
||
import ( | ||
"testing" | ||
|
||
"fyne.io/fyne/v2/test" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestEntryDialog_Confirm(t *testing.T) { | ||
value := "" | ||
ed := NewEntryDialog("Test", "message", func(v string) { | ||
value = v | ||
}, test.NewWindow(nil)) | ||
ed.Show() | ||
test.Type(ed.entry, "123") | ||
test.Tap(ed.confirm) | ||
|
||
assert.Equal(t, value, "123", "Control form should be confirmed with no validation") | ||
} | ||
|
||
func TestEntryDialog_Dismiss(t *testing.T) { | ||
value := "123" | ||
ed := NewEntryDialog("Test", "message", func(v string) { | ||
value = v | ||
}, test.NewWindow(nil)) | ||
ed.Show() | ||
test.Type(ed.entry, "XYZ") | ||
test.Tap(ed.cancel) | ||
|
||
assert.Equal(t, value, "123", "Control form should not change value on dismiss") | ||
} |