From 18ee1d7f0e9a7a64380088ad4f494baad0b2f528 Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Wed, 7 Jun 2023 14:58:54 +0800 Subject: [PATCH] change: remove cache last launched package name --- hrp/pkg/uixt/android_adb_driver.go | 8 -------- hrp/pkg/uixt/android_test.go | 2 +- hrp/pkg/uixt/client.go | 2 -- hrp/pkg/uixt/interface.go | 2 -- hrp/pkg/uixt/ios_driver.go | 8 -------- 5 files changed, 1 insertion(+), 21 deletions(-) diff --git a/hrp/pkg/uixt/android_adb_driver.go b/hrp/pkg/uixt/android_adb_driver.go index 742f8107..cfed8043 100644 --- a/hrp/pkg/uixt/android_adb_driver.go +++ b/hrp/pkg/uixt/android_adb_driver.go @@ -197,7 +197,6 @@ func (ad *adbDriver) AppLaunch(packageName string) (err error) { return errors.Wrap(code.MobileUILaunchAppError, fmt.Sprintf("monkey aborted: %s", strings.TrimSpace(sOutput))) } - ad.lastLaunchedPackageName = packageName return nil } @@ -209,9 +208,6 @@ func (ad *adbDriver) AppTerminate(packageName string) (successful bool, err erro return false, errors.Wrap(err, "force-stop app failed") } - if ad.lastLaunchedPackageName == packageName { - ad.lastLaunchedPackageName = "" // reset last launched package name - } return true, nil } @@ -399,10 +395,6 @@ func (ad *adbDriver) StopCaptureLog() (result interface{}, err error) { return ConvertPoints(content), nil } -func (ad *adbDriver) GetLastLaunchedApp() (packageName string) { - return ad.lastLaunchedPackageName -} - func (ad *adbDriver) AssertAppForeground(packageName string) error { if packageName == "" { return errors.New("package name is not given") diff --git a/hrp/pkg/uixt/android_test.go b/hrp/pkg/uixt/android_test.go index 46ab5a0d..230bcaa5 100644 --- a/hrp/pkg/uixt/android_test.go +++ b/hrp/pkg/uixt/android_test.go @@ -364,7 +364,7 @@ func TestDriver_IsAppInForeground(t *testing.T) { t.FailNow() } - err = driverExt.Driver.AssertAppForeground(driverExt.Driver.GetLastLaunchedApp()) + err = driverExt.Driver.AssertAppForeground("com.android.settings") if err != nil { t.Fatal(err) } diff --git a/hrp/pkg/uixt/client.go b/hrp/pkg/uixt/client.go index b8166da8..1f7d7aca 100644 --- a/hrp/pkg/uixt/client.go +++ b/hrp/pkg/uixt/client.go @@ -21,8 +21,6 @@ type Driver struct { sessionId string client *http.Client scale float64 - // cache the last launched package name - lastLaunchedPackageName string } func (wd *Driver) concatURL(u *url.URL, elem ...string) string { diff --git a/hrp/pkg/uixt/interface.go b/hrp/pkg/uixt/interface.go index 595a52d8..7895fddf 100644 --- a/hrp/pkg/uixt/interface.go +++ b/hrp/pkg/uixt/interface.go @@ -489,8 +489,6 @@ type WebDriver interface { // AppTerminate Terminate an application with the given pacakge name. // Either `true` if the app has been successfully terminated or `false` if it was not running AppTerminate(packageName string) (bool, error) - // GetLastLaunchedApp returns the package name of the last launched app - GetLastLaunchedApp() string // AssertAppForeground returns nil if the given package is in foreground AssertAppForeground(packageName string) error // GetForegroundApp returns current foreground app package name and activity name diff --git a/hrp/pkg/uixt/ios_driver.go b/hrp/pkg/uixt/ios_driver.go index c18114a7..828684dd 100644 --- a/hrp/pkg/uixt/ios_driver.go +++ b/hrp/pkg/uixt/ios_driver.go @@ -322,7 +322,6 @@ func (wd *wdaDriver) AppLaunch(bundleId string) (err error) { return errors.Wrap(code.MobileUILaunchAppError, fmt.Sprintf("wda launch failed: %v", err)) } - wd.lastLaunchedPackageName = bundleId return nil } @@ -347,9 +346,6 @@ func (wd *wdaDriver) AppTerminate(bundleId string) (successful bool, err error) if successful, err = rawResp.valueConvertToBool(); err != nil { return false, err } - if wd.lastLaunchedPackageName == bundleId { - wd.lastLaunchedPackageName = "" // reset last launched package name - } return } @@ -370,10 +366,6 @@ func (wd *wdaDriver) AppDeactivate(second float64) (err error) { return } -func (wd *wdaDriver) GetLastLaunchedApp() (packageName string) { - return wd.lastLaunchedPackageName -} - func (wd *wdaDriver) AssertAppForeground(packageName string) error { return nil }