forked from SonicCloudOrg/sonic-gidevice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
springboard_test.go
53 lines (46 loc) · 971 Bytes
/
springboard_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
package giDevice
import (
"fmt"
"image"
"image/jpeg"
"image/png"
"os"
"testing"
)
var springBoardSrv SpringBoard
func setupSpringBoardSrv(t *testing.T) {
setupLockdownSrv(t)
var err error
if lockdownSrv, err = dev.lockdownService(); err != nil {
t.Fatal(err)
}
if springBoardSrv, err = lockdownSrv.SpringBoardService(); err != nil {
t.Fatal(err)
}
}
func Test_springBoard_GetIcon(t *testing.T) {
setupSpringBoardSrv(t)
raw, _ := springBoardSrv.GetIconPNGData("com.tencent.xin")
img, format, err := image.Decode(raw)
if err != nil {
t.Fatal(err)
}
file, err := os.Create("./abc." + format)
if err != nil {
t.Fatal(err)
}
defer func() { _ = file.Close() }()
switch format {
case "png":
err = png.Encode(file, img)
case "jpeg":
err = jpeg.Encode(file, img, nil)
}
if err != nil {
t.Fatal(err)
}
}
func Test_springBoard_GetOrient(t *testing.T) {
setupSpringBoardSrv(t)
fmt.Println(springBoardSrv.GetInterfaceOrientation())
}