-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoolkit_test.go
64 lines (50 loc) · 1.53 KB
/
toolkit_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
package maa
import (
"testing"
"github.com/stretchr/testify/require"
)
func createToolkit(t *testing.T) *Toolkit {
toolkit := NewToolkit()
require.NotNil(t, toolkit)
return toolkit
}
func TestNewToolkit(t *testing.T) {
createToolkit(t)
}
func TestToolkit_ConfigInitOption(t *testing.T) {
toolkit := createToolkit(t)
got := toolkit.ConfigInitOption("./test", "{}")
require.True(t, got)
}
func TestToolkit_FindAdbDevices(t *testing.T) {
toolkit := createToolkit(t)
adbDevices := toolkit.FindAdbDevices()
require.NotNil(t, adbDevices)
}
func TestToolkit_FindDesktopWindows(t *testing.T) {
toolkit := createToolkit(t)
desktopWindows := toolkit.FindDesktopWindows()
require.NotNil(t, desktopWindows)
}
type testToolKitRec struct{}
func (t *testToolKitRec) Run(_ *Context, _ *CustomRecognitionArg) (*CustomRecognitionResult, bool) {
return &CustomRecognitionResult{}, true
}
func TestToolkit_RegisterPICustomRecognition(t *testing.T) {
toolkit := createToolkit(t)
toolkit.RegisterPICustomRecognition(0, "TestRec", &testToolKitRec{})
}
type testToolkitAct struct{}
func (t testToolkitAct) Run(_ *Context, _ *CustomActionArg) bool {
return true
}
func TestToolkit_RegisterPICustomAction(t *testing.T) {
toolkit := createToolkit(t)
toolkit.RegisterPICustomAction(0, "TestAct", &testToolkitAct{})
}
func TestToolkit_ClearPICustom(t *testing.T) {
toolkit := createToolkit(t)
toolkit.RegisterPICustomRecognition(0, "TestRec", &testToolKitRec{})
toolkit.RegisterPICustomAction(0, "TestAct", &testToolkitAct{})
toolkit.ClearPICustom(0)
}