-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_test.go
More file actions
87 lines (74 loc) · 1.78 KB
/
Copy pathexample_test.go
File metadata and controls
87 lines (74 loc) · 1.78 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package devicebase_test
import (
"fmt"
"os"
devicebase "github.com/devicebase/go-devicebase"
)
func ExampleNewClient() {
client := devicebase.NewClient(
devicebase.WithAPIKey("your-api-key"),
devicebase.WithSerial("device-serial-number"),
)
_ = client
}
func ExampleClient_GetDeviceInfo() {
client := devicebase.NewClient(
devicebase.WithAPIKey(os.Getenv("DEVICEBASE_API_KEY")),
devicebase.WithSerial("device123"),
devicebase.WithBaseURL("https://api.devicebase.cn"),
)
info, err := client.GetDeviceInfo()
if err != nil {
fmt.Println("error:", err)
return
}
fmt.Println("device:", info.Serial)
}
func ExampleClient_tap() {
client := devicebase.NewClient(
devicebase.WithAPIKey("your-api-key"),
devicebase.WithSerial("device123"),
)
result, err := client.Tap(100, 200)
if err != nil {
fmt.Println("error:", err)
return
}
fmt.Println("success:", result.Success)
}
func ExampleClient_launchApp() {
client := devicebase.NewClient(
devicebase.WithAPIKey("your-api-key"),
devicebase.WithSerial("device123"),
)
result, err := client.LaunchApp("com.tencent.mm")
if err != nil {
fmt.Println("error:", err)
return
}
fmt.Println("success:", result.Success)
}
func ExampleClient_swipe() {
client := devicebase.NewClient(
devicebase.WithAPIKey("your-api-key"),
devicebase.WithSerial("device123"),
)
result, err := client.Swipe(0, 500, 500, 500)
if err != nil {
fmt.Println("error:", err)
return
}
fmt.Println("success:", result.Success)
}
func ExampleClient_getScreenshot() {
client := devicebase.NewClient(
devicebase.WithAPIKey("your-api-key"),
devicebase.WithSerial("device123"),
)
screenshot, err := client.GetScreenshot()
if err != nil {
fmt.Println("error:", err)
return
}
fmt.Printf("screenshot size: %d bytes\n", len(screenshot))
}