zenity/dialog/dialog_test.go

58 lines
1.1 KiB
Go
Raw Normal View History

2019-12-11 05:29:31 -05:00
package dialog
import "testing"
2019-12-28 10:34:38 -05:00
const defaultPath = ""
2019-12-11 05:29:31 -05:00
func TestOpenFile(t *testing.T) {
2019-12-28 10:34:38 -05:00
res, err := OpenFile("", defaultPath, []FileFilter{
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"}},
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
}
}
func TestOpenFiles(t *testing.T) {
2019-12-28 10:34:38 -05:00
res, err := OpenFiles("", defaultPath, []FileFilter{
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"}},
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
}
}
func TestSaveFile(t *testing.T) {
2019-12-28 10:34:38 -05:00
res, err := SaveFile("", defaultPath, true, []FileFilter{
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"}},
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
}
}
func TestPickFolder(t *testing.T) {
2019-12-28 10:34:38 -05:00
res, err := PickFolder("", 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
}
}