forked from electricbubble/gidevice
-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
instruments_test.go
94 lines (76 loc) · 2.09 KB
/
instruments_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
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
88
89
90
91
92
93
94
package giDevice
import (
"testing"
)
var instrumentsSrv Instruments
var bundleID = "com.apple.Preferences"
func setupInstrumentsSrv(t *testing.T) {
setupLockdownSrv(t)
var err error
if lockdownSrv, err = dev.lockdownService(); err != nil {
t.Fatal(err)
}
if instrumentsSrv, err = lockdownSrv.InstrumentsService(); err != nil {
t.Fatal(err)
}
}
func Test_instruments_AppLaunch(t *testing.T) {
setupInstrumentsSrv(t)
bundleID = "com.DataMesh.CheckList"
// pid, err := dev.AppLaunch(bundleID)
pid, err := instrumentsSrv.AppLaunch(bundleID)
// pid, err := instrumentsSrv.AppLaunch(bundleID, WithKillExisting(true))
// pid, err := instrumentsSrv.AppLaunch(bundleID, WithKillExisting(true), WithArguments([]interface{}{"-AppleLanguages", "(Russian)"}))
if err != nil {
t.Fatal(err)
}
t.Log(pid)
}
func Test_instruments_AppKill(t *testing.T) {
setupInstrumentsSrv(t)
pid, err := instrumentsSrv.AppLaunch(bundleID)
if err != nil {
t.Fatal(err)
}
t.Log(pid)
// if err = dev.AppKill(pid); err != nil {
if err = instrumentsSrv.AppKill(pid); err != nil {
t.Fatal(err)
}
}
func Test_instruments_AppRunningProcesses(t *testing.T) {
setupInstrumentsSrv(t)
// processes, err := dev.AppRunningProcesses()
processes, err := instrumentsSrv.AppRunningProcesses()
if err != nil {
t.Fatal(err)
}
for _, p := range processes {
t.Log(p.IsApplication, "\t", p.Pid, "\t", p.Name, "\t", p.RealAppName, "\t", p.StartDate)
}
}
func Test_instruments_AppList(t *testing.T) {
setupInstrumentsSrv(t)
// apps, err := dev.AppList()
apps, err := instrumentsSrv.AppList()
if err != nil {
t.Fatal(err)
}
for _, app := range apps {
t.Logf("%v\t%v\t%v\t%v\t%v\n", app.Type, app.DisplayName, app.ExecutableName, app.AppExtensionUUIDs, app.BundlePath)
}
}
func Test_instruments_DeviceInfo(t *testing.T) {
setupInstrumentsSrv(t)
devInfo, err := instrumentsSrv.DeviceInfo()
if err != nil {
t.Fatal(err)
}
t.Log(devInfo.Description)
t.Log(devInfo.DisplayName)
t.Log(devInfo.Identifier)
t.Log(devInfo.Version)
t.Log(devInfo.ProductType)
t.Log(devInfo.ProductVersion)
t.Log(devInfo.XRDeviceClassName)
}