-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiv_test.go
More file actions
53 lines (42 loc) · 861 Bytes
/
Copy pathiv_test.go
File metadata and controls
53 lines (42 loc) · 861 Bytes
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
package iv_test
import (
"bytes"
"context"
_ "embed"
"fmt"
"image/jpeg"
"os"
"runtime"
"testing"
"time"
"github.com/gen2brain/iv"
)
//go:embed testdata/test.jpg
var data []byte
func init() {
runtime.LockOSThread()
}
func TestMain(m *testing.M) {
code := m.Run()
// Window smoke test on the main goroutine; opt-in via IV_TEST_WINDOW, needs a display.
if os.Getenv("IV_TEST_WINDOW") != "" {
if err := showWindow(); err != nil {
fmt.Fprintln(os.Stderr, err)
}
}
os.Exit(code)
}
func showWindow() error {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
img, err := jpeg.Decode(bytes.NewReader(data))
if err != nil {
return err
}
view, err := iv.New(iv.Options{Width: 700, Height: 700})
if err != nil {
return err
}
defer view.Close()
return view.Display(ctx, img, "test.jpg")
}