zenity/file_test.go

58 lines
1.2 KiB
Go
Raw Normal View History

2019-12-29 20:00:50 -05:00
package zenity
2019-12-11 05:29:31 -05:00
import "testing"
2019-12-28 10:34:38 -05:00
const defaultPath = ""
2019-12-29 20:00:50 -05:00
func TestSelectFile(t *testing.T) {
2020-01-02 20:44:23 -05:00
res, err := SelectFile(Filename(defaultPath), FileFilters{
2019-12-11 05:29:31 -05:00
{"Go files", []string{".go"}},
{"Web files", []string{".html", ".js", ".css"}},
2019-12-13 21:16:06 -05:00
{"Image files", []string{".png", ".gif", ".ico", ".jpg", ".webp"}},
2020-01-02 20:44:23 -05:00
}.New())
2019-12-11 05:29:31 -05:00
if err != nil {
t.Error(err)
} else {
2019-12-13 21:16:06 -05:00
t.Logf("%#v", res)
2019-12-11 05:29:31 -05:00
}
}
2019-12-29 20:00:50 -05:00
func TestSelectFileMutiple(t *testing.T) {
2020-01-02 20:44:23 -05:00
res, err := SelectFileMutiple(Filename(defaultPath), FileFilters{
2019-12-11 05:29:31 -05:00
{"Go files", []string{".go"}},
{"Web files", []string{".html", ".js", ".css"}},
2019-12-13 21:16:06 -05:00
{"Image files", []string{".png", ".gif", ".ico", ".jpg", ".webp"}},
2020-01-02 20:44:23 -05:00
}.New())
2019-12-11 05:29:31 -05:00
if err != nil {
t.Error(err)
} else {
2019-12-13 21:16:06 -05:00
t.Logf("%#v", res)
2019-12-11 05:29:31 -05:00
}
}
2019-12-29 20:00:50 -05:00
func TestSelectFileSave(t *testing.T) {
2020-01-02 20:44:23 -05:00
res, err := SelectFileSave(Filename(defaultPath), ConfirmOverwrite, FileFilters{
2019-12-11 05:29:31 -05:00
{"Go files", []string{".go"}},
{"Web files", []string{".html", ".js", ".css"}},
2019-12-13 21:16:06 -05:00
{"Image files", []string{".png", ".gif", ".ico", ".jpg", ".webp"}},
2020-01-02 20:44:23 -05:00
}.New())
2019-12-11 05:29:31 -05:00
if err != nil {
t.Error(err)
} else {
2019-12-13 21:16:06 -05:00
t.Logf("%#v", res)
2019-12-11 05:29:31 -05:00
}
}
2019-12-29 20:00:50 -05:00
func TestSelectDirectory(t *testing.T) {
2020-01-02 20:44:23 -05:00
res, err := SelectDirectory(Filename(defaultPath))
2019-12-11 05:29:31 -05:00
if err != nil {
t.Error(err)
} else {
2019-12-13 21:16:06 -05:00
t.Logf("%#v", res)
2019-12-11 05:29:31 -05:00
}
}