fix: 支持鸿蒙

This commit is contained in:
余泓铮
2024-09-19 22:51:10 +08:00
parent ac6940b283
commit 4fb9baf5a8
4 changed files with 16 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ import (
) )
type hdcDriver struct { type hdcDriver struct {
points []ExportPoint
Driver Driver
device *ghdc.Device device *ghdc.Device
uiDriver *ghdc.UIDriver uiDriver *ghdc.UIDriver
@@ -25,10 +26,12 @@ func newHarmonyDriver(device *ghdc.Device) (driver *hdcDriver, err error) {
return nil, err return nil, err
} }
driver.uiDriver = uiDriver driver.uiDriver = uiDriver
driver.NewSession(nil)
return return
} }
func (hd *hdcDriver) NewSession(capabilities Capabilities) (SessionInfo, error) { func (hd *hdcDriver) NewSession(capabilities Capabilities) (SessionInfo, error) {
hd.Driver.session.Init()
return SessionInfo{}, errDriverNotImplemented return SessionInfo{}, errDriverNotImplemented
} }
@@ -37,7 +40,7 @@ func (hd *hdcDriver) DeleteSession() error {
} }
func (hd *hdcDriver) GetSession() *DriverSession { func (hd *hdcDriver) GetSession() *DriverSession {
return nil return &hd.Driver.session
} }
func (hd *hdcDriver) Status() (DeviceStatus, error) { func (hd *hdcDriver) Status() (DeviceStatus, error) {

View File

@@ -11,6 +11,7 @@ const (
stepTypeThinkTime StepType = "thinktime" stepTypeThinkTime StepType = "thinktime"
stepTypeWebSocket StepType = "websocket" stepTypeWebSocket StepType = "websocket"
stepTypeAndroid StepType = "android" stepTypeAndroid StepType = "android"
stepTypeHarmony StepType = "harmony"
stepTypeIOS StepType = "ios" stepTypeIOS StepType = "ios"
stepTypeShell StepType = "shell" stepTypeShell StepType = "shell"
@@ -54,6 +55,7 @@ type TStep struct {
ThinkTime *ThinkTime `json:"think_time,omitempty" yaml:"think_time,omitempty"` ThinkTime *ThinkTime `json:"think_time,omitempty" yaml:"think_time,omitempty"`
WebSocket *WebSocketAction `json:"websocket,omitempty" yaml:"websocket,omitempty"` WebSocket *WebSocketAction `json:"websocket,omitempty" yaml:"websocket,omitempty"`
Android *MobileUI `json:"android,omitempty" yaml:"android,omitempty"` Android *MobileUI `json:"android,omitempty" yaml:"android,omitempty"`
Harmony *MobileUI `json:"harmony,omitempty" yaml:"harmony,omitempty"`
IOS *MobileUI `json:"ios,omitempty" yaml:"ios,omitempty"` IOS *MobileUI `json:"ios,omitempty" yaml:"ios,omitempty"`
Shell *Shell `json:"shell,omitempty" yaml:"shell,omitempty"` Shell *Shell `json:"shell,omitempty" yaml:"shell,omitempty"`
Variables map[string]interface{} `json:"variables,omitempty" yaml:"variables,omitempty"` Variables map[string]interface{} `json:"variables,omitempty" yaml:"variables,omitempty"`

View File

@@ -398,6 +398,8 @@ func (s *StepMobile) Name() string {
func (s *StepMobile) Type() StepType { func (s *StepMobile) Type() StepType {
if s.step.Android != nil { if s.step.Android != nil {
return stepTypeAndroid return stepTypeAndroid
} else if s.step.Harmony != nil {
return stepTypeHarmony
} }
return stepTypeIOS return stepTypeIOS
} }
@@ -591,10 +593,13 @@ func runStepMobileUI(s *SessionRunner, step *TStep) (stepResult *StepResult, err
// ios step // ios step
osType = "ios" osType = "ios"
mobileStep = step.IOS mobileStep = step.IOS
} else { } else if step.Android != nil {
// android step // android step
osType = "android" osType = "android"
mobileStep = step.Android mobileStep = step.Android
} else {
osType = "harmony"
mobileStep = step.Harmony
} }
// report GA event // report GA event

View File

@@ -257,6 +257,10 @@ func (tc *TestCase) loadISteps() (*TestCase, error) {
testCase.TestSteps = append(testCase.TestSteps, &StepMobile{ testCase.TestSteps = append(testCase.TestSteps, &StepMobile{
step: step, step: step,
}) })
} else if step.Harmony != nil {
testCase.TestSteps = append(testCase.TestSteps, &StepMobile{
step: step,
})
} else if step.Android != nil { } else if step.Android != nil {
testCase.TestSteps = append(testCase.TestSteps, &StepMobile{ testCase.TestSteps = append(testCase.TestSteps, &StepMobile{
step: step, step: step,