This repository has been archived by the owner on Jun 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
/
file_test.go
54 lines (46 loc) · 1.14 KB
/
file_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package dlgs
import (
"runtime"
"testing"
)
func TestFileDir(t *testing.T) {
out, ret, err := File("Choose directory", "", true)
if err != nil {
t.Error(err)
}
if verboseTests {
println("out:", out, "ret:", ret)
}
}
func TestFile(t *testing.T) {
var filter string
switch runtime.GOOS {
case "linux":
filter = "Images (*.jpeg,*.png,*.gif) | *.jpg *.jpeg *.png *.gif"
case "windows":
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms646839.aspx
filter = "Images (*.jpeg,*.png,*.gif)\x00*.jpg;*.jpeg;*.png;*.gif\x00All Files (*.*)\x00*.*\x00\x00"
case "darwin":
// https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html
filter = "public.image"
}
out, ret, err := File("Select file", filter, false)
if err != nil {
t.Error(err)
}
if verboseTests {
println("out:", out, "ret:", ret)
}
}
func TestFileMulti(t *testing.T) {
out, ret, err := FileMulti("Select files", "")
if err != nil {
t.Error(err)
}
if verboseTests {
if len(out) > 0 {
println("out length:", len(out), "out[0]:", out[0])
}
println("ret:", ret)
}
}