From 2eebc4ac8af05d08cecc996d285f2841ddb2203c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E6=B3=93=E9=93=AE?= Date: Wed, 25 Sep 2024 12:16:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dtconfig=E4=B8=AD?= =?UTF-8?q?=E6=B2=A1=E6=9C=89harmony?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hrp/config.go | 22 ++++++++++++++++++++++ hrp/step_request.go | 8 ++++++++ 2 files changed, 30 insertions(+) diff --git a/hrp/config.go b/hrp/config.go index 6857aee1..b5f9cbc7 100644 --- a/hrp/config.go +++ b/hrp/config.go @@ -31,6 +31,7 @@ type TConfig struct { WebSocketSetting *WebSocketConfig `json:"websocket,omitempty" yaml:"websocket,omitempty"` IOS []*uixt.IOSDevice `json:"ios,omitempty" yaml:"ios,omitempty"` Android []*uixt.AndroidDevice `json:"android,omitempty" yaml:"android,omitempty"` + Harmony []*uixt.HarmonyDevice `json:"harmony,omitempty" yaml:"harmony,omitempty"` RequestTimeout float32 `json:"request_timeout,omitempty" yaml:"request_timeout,omitempty"` // request timeout in seconds CaseTimeout float32 `json:"case_timeout,omitempty" yaml:"case_timeout,omitempty"` // testcase timeout in seconds Export []string `json:"export,omitempty" yaml:"export,omitempty"` @@ -129,6 +130,27 @@ func (c *TConfig) SetIOS(options ...uixt.IOSDeviceOption) *TConfig { return c } +func (c *TConfig) SetHarmony(options ...uixt.HarmonyDeviceOption) *TConfig { + harmonyOptions := &uixt.HarmonyDevice{} + for _, option := range options { + option(harmonyOptions) + } + + // each device can have its own settings + if harmonyOptions.ConnectKey != "" { + c.Harmony = append(c.Harmony, harmonyOptions) + return c + } + + // device UDID is not specified, settings will be shared + if len(c.Harmony) == 0 { + c.Harmony = append(c.Harmony, harmonyOptions) + } else { + c.Harmony[0] = harmonyOptions + } + return c +} + func (c *TConfig) SetAndroid(options ...uixt.AndroidDeviceOption) *TConfig { uiaOptions := &uixt.AndroidDevice{} for _, option := range options { diff --git a/hrp/step_request.go b/hrp/step_request.go index 40821733..bd1fe8c1 100644 --- a/hrp/step_request.go +++ b/hrp/step_request.go @@ -762,6 +762,14 @@ func (s *StepRequest) IOS() *StepMobile { } } +// Harmony creates a new harmony action +func (s *StepRequest) Harmony() *StepMobile { + s.step.Harmony = &MobileUI{} + return &StepMobile{ + step: s.step, + } +} + // Shell creates a new shell action func (s *StepRequest) Shell(content string) *StepShell { s.step.Shell = &Shell{