go-mobile-automation/apis/service_test.go
2024-10-21 16:51:04 +08:00

58 lines
1.1 KiB
Go

package apis
import (
"fmt"
"testing"
openatxclientgo "code.xbase.vip/biao/go-mobile-automation"
)
func TestServiceRunning(t *testing.T) {
o, err := openatxclientgo.NewHostOperation("c574dd45")
if err != nil {
t.Error("error connect to device")
return
}
s := NewService(SERVICE_UIAUTOMATOR, o.Req)
running, err := s.Running()
if err != nil {
t.Error("error running")
return
}
if running {
fmt.Println("uiautomator is running")
} else {
fmt.Println("uiautomator is not running")
}
}
func TestServiceStop(t *testing.T) {
o, err := openatxclientgo.NewHostOperation("c574dd45")
if err != nil {
t.Error("error connect to device")
return
}
s := NewService(SERVICE_UIAUTOMATOR, o.Req)
info, err := s.Stop()
if err != nil {
t.Error("error stop")
return
}
fmt.Println(*info)
}
func TestServiceStart(t *testing.T) {
o, err := openatxclientgo.NewHostOperation("c574dd45")
if err != nil {
t.Error("error connect to device")
return
}
s := NewService(SERVICE_UIAUTOMATOR, o.Req)
info, err := s.Start()
if err != nil {
t.Error("error start")
return
}
fmt.Println(*info)
}