mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
change: remove unused methods
This commit is contained in:
@@ -23,7 +23,6 @@ import (
|
||||
"github.com/httprunner/httprunner/v5/code"
|
||||
"github.com/httprunner/httprunner/v5/internal/config"
|
||||
"github.com/httprunner/httprunner/v5/internal/utf7"
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt/ai"
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt/types"
|
||||
)
|
||||
@@ -164,11 +163,6 @@ func (ad *ADBDriver) WindowSize() (size types.Size, err error) {
|
||||
return size, nil
|
||||
}
|
||||
|
||||
func (ad *ADBDriver) Screen() (screen ai.Screen, err error) {
|
||||
err = types.ErrDriverNotImplemented
|
||||
return
|
||||
}
|
||||
|
||||
func (ad *ADBDriver) Scale() (scale float64, err error) {
|
||||
return 1, nil
|
||||
}
|
||||
@@ -549,7 +543,7 @@ func (ad *ADBDriver) SetRotation(rotation types.Rotation) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (ad *ADBDriver) Screenshot() (raw *bytes.Buffer, err error) {
|
||||
func (ad *ADBDriver) ScreenShot() (raw *bytes.Buffer, err error) {
|
||||
resp, err := ad.runShellCommand("screencap", "-p")
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "adb screencap failed")
|
||||
@@ -735,10 +729,6 @@ func (ad *ADBDriver) GetSession() *Session {
|
||||
return ad.Session
|
||||
}
|
||||
|
||||
func (ad *ADBDriver) GetDriverResults() []*DriverRequests {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ad *ADBDriver) GetForegroundApp() (app types.AppInfo, err error) {
|
||||
packageInfo, err := ad.runShellCommand(
|
||||
"CLASSPATH=/data/local/tmp/evalite", "app_process", "/",
|
||||
@@ -905,7 +895,7 @@ var androidActivities = map[string]map[string][]string{
|
||||
// TODO: SPH, XHS
|
||||
}
|
||||
|
||||
func (ad *ADBDriver) RecordScreen(folderPath string, duration time.Duration) (videoPath string, err error) {
|
||||
func (ad *ADBDriver) ScreenRecord(folderPath string, duration time.Duration) (videoPath string, err error) {
|
||||
// 获取当前时间戳
|
||||
timestamp := time.Now().Format("20060102_150405") + fmt.Sprintf("_%03d", time.Now().UnixNano()/1e6%1000)
|
||||
// 创建文件名
|
||||
|
||||
@@ -543,10 +543,10 @@ func (ud *UIA2Driver) Rotation() (rotation types.Rotation, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (ud *UIA2Driver) Screenshot() (raw *bytes.Buffer, err error) {
|
||||
func (ud *UIA2Driver) ScreenShot() (raw *bytes.Buffer, err error) {
|
||||
// https://bytedance.larkoffice.com/docx/C8qEdmSHnoRvMaxZauocMiYpnLh
|
||||
// ui2截图受内存影响,改为adb截图
|
||||
return ud.ADBDriver.Screenshot()
|
||||
return ud.ADBDriver.ScreenShot()
|
||||
}
|
||||
|
||||
func (ud *UIA2Driver) Source(srcOpt ...option.SourceOption) (source string, err error) {
|
||||
|
||||
@@ -68,7 +68,7 @@ func TestDriver_Status(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDriver_Screenshot(t *testing.T) {
|
||||
screenshot, err := driver.Screenshot()
|
||||
screenshot, err := driver.ScreenShot()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -250,7 +250,7 @@ func TestDriver_AppLaunch(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
raw, err := driver.Screenshot()
|
||||
raw, err := driver.ScreenShot()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -303,14 +303,14 @@ func TestDriver_KeepAlive(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
_, err = driver.Screenshot()
|
||||
_, err = driver.ScreenShot()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
time.Sleep(60 * time.Second)
|
||||
|
||||
_, err = driver.Screenshot()
|
||||
_, err = driver.ScreenShot()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -350,7 +350,7 @@ func TestDriver_ShellInputUnicode(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
raw, err := driver.Screenshot()
|
||||
raw, err := driver.ScreenShot()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -393,7 +393,7 @@ func TestTapTexts(t *testing.T) {
|
||||
|
||||
func TestRecordVideo(t *testing.T) {
|
||||
setupAndroidAdbDriver(t)
|
||||
path, err := driverExt.RecordScreen("", 5*time.Second)
|
||||
path, err := driverExt.ScreenRecord("", 5*time.Second)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -29,21 +29,22 @@ var (
|
||||
// current implemeted driver: ADBDriver, UIA2Driver, WDADriver, HDCDriver
|
||||
type IDriver interface {
|
||||
GetDevice() IDevice
|
||||
Setup() error
|
||||
TearDown() error
|
||||
|
||||
// session
|
||||
InitSession(capabilities option.Capabilities) error
|
||||
DeleteSession() error
|
||||
GetSession() *Session
|
||||
DeleteSession() error
|
||||
|
||||
// device info and status
|
||||
Status() (types.DeviceStatus, error)
|
||||
DeviceInfo() (types.DeviceInfo, error)
|
||||
BatteryInfo() (types.BatteryInfo, error)
|
||||
WindowSize() (types.Size, error)
|
||||
Screen() (ai.Screen, error)
|
||||
Scale() (float64, error)
|
||||
Screenshot() (*bytes.Buffer, error)
|
||||
RecordScreen(folderPath string, duration time.Duration) (videoPath string, err error)
|
||||
ScreenShot() (*bytes.Buffer, error)
|
||||
ScreenRecord(folderPath string, duration time.Duration) (videoPath string, err error)
|
||||
Source(srcOpt ...option.SourceOption) (string, error)
|
||||
|
||||
// actions
|
||||
@@ -70,9 +71,9 @@ type IDriver interface {
|
||||
// app related
|
||||
AppLaunch(packageName string) error
|
||||
AppTerminate(packageName string) (bool, error)
|
||||
GetForegroundApp() (app types.AppInfo, err error)
|
||||
AssertForegroundApp(packageName string, activityType ...string) error
|
||||
AppClear(packageName string) error
|
||||
GetForegroundApp() (app types.AppInfo, err error)
|
||||
AssertForegroundApp(packageName string, activityType ...string) error // TODO: remove
|
||||
|
||||
Orientation() (orientation types.Orientation, err error)
|
||||
SetRotation(rotation types.Rotation) (err error)
|
||||
@@ -83,11 +84,6 @@ type IDriver interface {
|
||||
// triggers the log capture and returns the log entries
|
||||
StartCaptureLog(identifier ...string) (err error)
|
||||
StopCaptureLog() (result interface{}, err error)
|
||||
|
||||
GetDriverResults() []*DriverRequests
|
||||
|
||||
Setup() error
|
||||
TearDown() error
|
||||
}
|
||||
|
||||
func NewXTDriver(driver IDriver, opts ...ai.AIServiceOption) *XTDriver {
|
||||
|
||||
@@ -106,7 +106,7 @@ func TestInput(t *testing.T) {
|
||||
|
||||
func TestSave(t *testing.T) {
|
||||
setupShootsAndroidDriver(t)
|
||||
raw, err := shootsAndroidDriver.Screenshot()
|
||||
raw, err := shootsAndroidDriver.ScreenShot()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func TestIOSSwipe(t *testing.T) {
|
||||
|
||||
func TestIOSSave(t *testing.T) {
|
||||
setupShootsIOSDriver(t)
|
||||
raw, err := shootsIOSDriver.Screenshot()
|
||||
raw, err := shootsIOSDriver.ScreenShot()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ func (dExt *XTDriver) FindUIResult(opts ...option.ActionOption) (point ai.PointF
|
||||
|
||||
// GetScreenShot takes screenshot and saves image file to $CWD/screenshots/ folder
|
||||
func (dExt *XTDriver) GetScreenShot(fileName string) (raw *bytes.Buffer, path string, err error) {
|
||||
if raw, err = dExt.Screenshot(); err != nil {
|
||||
if raw, err = dExt.ScreenShot(); err != nil {
|
||||
log.Error().Err(err).Msg("capture screenshot data failed")
|
||||
return nil, "", errors.Wrap(code.DeviceScreenShotError, err.Error())
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"code.byted.org/iesqa/ghdc"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt/ai"
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt/types"
|
||||
)
|
||||
@@ -81,10 +80,6 @@ func (hd *HDCDriver) WindowSize() (size types.Size, err error) {
|
||||
return size, err
|
||||
}
|
||||
|
||||
func (hd *HDCDriver) Screen() (ai.Screen, error) {
|
||||
return ai.Screen{}, types.ErrDriverNotImplemented
|
||||
}
|
||||
|
||||
func (hd *HDCDriver) Scale() (float64, error) {
|
||||
return 1, nil
|
||||
}
|
||||
@@ -241,7 +236,7 @@ func (hd *HDCDriver) PressHarmonyKeyCode(keyCode ghdc.KeyCode) (err error) {
|
||||
return hd.uiDriver.PressKey(keyCode)
|
||||
}
|
||||
|
||||
func (hd *HDCDriver) Screenshot() (*bytes.Buffer, error) {
|
||||
func (hd *HDCDriver) ScreenShot() (*bytes.Buffer, error) {
|
||||
tempDir := os.TempDir()
|
||||
screenshotPath := fmt.Sprintf("%s/screenshot_%d.png", tempDir, time.Now().Unix())
|
||||
err := hd.uiDriver.Screenshot(screenshotPath)
|
||||
@@ -282,11 +277,7 @@ func (hd *HDCDriver) StopCaptureLog() (result interface{}, err error) {
|
||||
return hd.points, nil
|
||||
}
|
||||
|
||||
func (hd *HDCDriver) GetDriverResults() []*DriverRequests {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (hd *HDCDriver) RecordScreen(folderPath string, duration time.Duration) (videoPath string, err error) {
|
||||
func (hd *HDCDriver) ScreenRecord(folderPath string, duration time.Duration) (videoPath string, err error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ func TestPressBack(t *testing.T) {
|
||||
|
||||
func TestScreenshot(t *testing.T) {
|
||||
setupHarmonyDevice(t)
|
||||
screenshot, err := driver.Screenshot()
|
||||
screenshot, err := driver.ScreenShot()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -267,6 +267,22 @@ func (wd *WDADriver) Screen() (screen ai.Screen, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (wd *WDADriver) ScreenShot() (raw *bytes.Buffer, err error) {
|
||||
// [[FBRoute GET:@"/screenshot"] respondWithTarget:self action:@selector(handleGetScreenshot:)]
|
||||
// [[FBRoute GET:@"/screenshot"].withoutSession respondWithTarget:self action:@selector(handleGetScreenshot:)]
|
||||
var rawResp DriverRawResponse
|
||||
if rawResp, err = wd.httpGET("/session", wd.Session.ID, "/screenshot"); err != nil {
|
||||
return nil, errors.Wrap(code.DeviceScreenShotError,
|
||||
fmt.Sprintf("get WDA screenshot data failed: %v", err))
|
||||
}
|
||||
|
||||
if raw, err = rawResp.ValueDecodeAsBase64(); err != nil {
|
||||
return nil, errors.Wrap(code.DeviceScreenShotError,
|
||||
fmt.Sprintf("decode WDA screenshot data failed: %v", err))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (wd *WDADriver) Scale() (float64, error) {
|
||||
if !builtin.IsZeroFloat64(wd.Session.scale) {
|
||||
return wd.Session.scale, nil
|
||||
@@ -763,22 +779,6 @@ func (wd *WDADriver) SetRotation(rotation types.Rotation) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (wd *WDADriver) Screenshot() (raw *bytes.Buffer, err error) {
|
||||
// [[FBRoute GET:@"/screenshot"] respondWithTarget:self action:@selector(handleGetScreenshot:)]
|
||||
// [[FBRoute GET:@"/screenshot"].withoutSession respondWithTarget:self action:@selector(handleGetScreenshot:)]
|
||||
var rawResp DriverRawResponse
|
||||
if rawResp, err = wd.httpGET("/session", wd.Session.ID, "/screenshot"); err != nil {
|
||||
return nil, errors.Wrap(code.DeviceScreenShotError,
|
||||
fmt.Sprintf("get WDA screenshot data failed: %v", err))
|
||||
}
|
||||
|
||||
if raw, err = rawResp.ValueDecodeAsBase64(); err != nil {
|
||||
return nil, errors.Wrap(code.DeviceScreenShotError,
|
||||
fmt.Sprintf("decode WDA screenshot data failed: %v", err))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (wd *WDADriver) Source(srcOpt ...option.SourceOption) (source string, err error) {
|
||||
// [[FBRoute GET:@"/source"] respondWithTarget:self action:@selector(handleGetSourceCommand:)]
|
||||
// [[FBRoute GET:@"/source"].withoutSession
|
||||
@@ -892,7 +892,7 @@ func (wd *WDADriver) triggerWDALog(data map[string]interface{}) (rawResp []byte,
|
||||
return wd.httpPOST(data, "/gtf/automation/log")
|
||||
}
|
||||
|
||||
func (wd *WDADriver) RecordScreen(folderPath string, duration time.Duration) (videoPath string, err error) {
|
||||
func (wd *WDADriver) ScreenRecord(folderPath string, duration time.Duration) (videoPath string, err error) {
|
||||
// 获取当前时间戳
|
||||
timestamp := time.Now().Format("20060102_150405") + fmt.Sprintf("_%03d", time.Now().UnixNano()/1e6%1000)
|
||||
// 创建文件名
|
||||
@@ -999,13 +999,6 @@ func (wd *WDADriver) GetSession() *Session {
|
||||
return wd.Session
|
||||
}
|
||||
|
||||
func (wd *WDADriver) GetDriverResults() []*DriverRequests {
|
||||
defer func() {
|
||||
wd.Session.requests = nil
|
||||
}()
|
||||
return wd.Session.requests
|
||||
}
|
||||
|
||||
func (wd *WDADriver) Setup() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ func Test_remoteWD_WindowSize(t *testing.T) {
|
||||
func Test_remoteWD_Screen(t *testing.T) {
|
||||
setup(t)
|
||||
|
||||
screen, err := driver.Screen()
|
||||
screen, err := driver.(*WDADriver).Screen()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -348,7 +348,7 @@ func Test_remoteWD_PressButton(t *testing.T) {
|
||||
func Test_remoteWD_Screenshot(t *testing.T) {
|
||||
setup(t)
|
||||
|
||||
screenshot, err := driver.Screenshot()
|
||||
screenshot, err := driver.ScreenShot()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -433,7 +433,7 @@ func Test_remoteWD_AccessibleSource(t *testing.T) {
|
||||
|
||||
func TestRecord(t *testing.T) {
|
||||
setup(t)
|
||||
path, err := driver.(*WDADriver).RecordScreen("", 5*time.Second)
|
||||
path, err := driver.ScreenRecord("", 5*time.Second)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user