mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
change: remove cache last launched package name
This commit is contained in:
@@ -197,7 +197,6 @@ func (ad *adbDriver) AppLaunch(packageName string) (err error) {
|
|||||||
return errors.Wrap(code.MobileUILaunchAppError,
|
return errors.Wrap(code.MobileUILaunchAppError,
|
||||||
fmt.Sprintf("monkey aborted: %s", strings.TrimSpace(sOutput)))
|
fmt.Sprintf("monkey aborted: %s", strings.TrimSpace(sOutput)))
|
||||||
}
|
}
|
||||||
ad.lastLaunchedPackageName = packageName
|
|
||||||
return nil
|
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")
|
return false, errors.Wrap(err, "force-stop app failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
if ad.lastLaunchedPackageName == packageName {
|
|
||||||
ad.lastLaunchedPackageName = "" // reset last launched package name
|
|
||||||
}
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,10 +395,6 @@ func (ad *adbDriver) StopCaptureLog() (result interface{}, err error) {
|
|||||||
return ConvertPoints(content), nil
|
return ConvertPoints(content), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ad *adbDriver) GetLastLaunchedApp() (packageName string) {
|
|
||||||
return ad.lastLaunchedPackageName
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ad *adbDriver) AssertAppForeground(packageName string) error {
|
func (ad *adbDriver) AssertAppForeground(packageName string) error {
|
||||||
if packageName == "" {
|
if packageName == "" {
|
||||||
return errors.New("package name is not given")
|
return errors.New("package name is not given")
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ func TestDriver_IsAppInForeground(t *testing.T) {
|
|||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
err = driverExt.Driver.AssertAppForeground(driverExt.Driver.GetLastLaunchedApp())
|
err = driverExt.Driver.AssertAppForeground("com.android.settings")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ type Driver struct {
|
|||||||
sessionId string
|
sessionId string
|
||||||
client *http.Client
|
client *http.Client
|
||||||
scale float64
|
scale float64
|
||||||
// cache the last launched package name
|
|
||||||
lastLaunchedPackageName string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wd *Driver) concatURL(u *url.URL, elem ...string) string {
|
func (wd *Driver) concatURL(u *url.URL, elem ...string) string {
|
||||||
|
|||||||
@@ -489,8 +489,6 @@ type WebDriver interface {
|
|||||||
// AppTerminate Terminate an application with the given pacakge name.
|
// 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
|
// Either `true` if the app has been successfully terminated or `false` if it was not running
|
||||||
AppTerminate(packageName string) (bool, error)
|
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 returns nil if the given package is in foreground
|
||||||
AssertAppForeground(packageName string) error
|
AssertAppForeground(packageName string) error
|
||||||
// GetForegroundApp returns current foreground app package name and activity name
|
// GetForegroundApp returns current foreground app package name and activity name
|
||||||
|
|||||||
@@ -322,7 +322,6 @@ func (wd *wdaDriver) AppLaunch(bundleId string) (err error) {
|
|||||||
return errors.Wrap(code.MobileUILaunchAppError,
|
return errors.Wrap(code.MobileUILaunchAppError,
|
||||||
fmt.Sprintf("wda launch failed: %v", err))
|
fmt.Sprintf("wda launch failed: %v", err))
|
||||||
}
|
}
|
||||||
wd.lastLaunchedPackageName = bundleId
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,9 +346,6 @@ func (wd *wdaDriver) AppTerminate(bundleId string) (successful bool, err error)
|
|||||||
if successful, err = rawResp.valueConvertToBool(); err != nil {
|
if successful, err = rawResp.valueConvertToBool(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
if wd.lastLaunchedPackageName == bundleId {
|
|
||||||
wd.lastLaunchedPackageName = "" // reset last launched package name
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,10 +366,6 @@ func (wd *wdaDriver) AppDeactivate(second float64) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wd *wdaDriver) GetLastLaunchedApp() (packageName string) {
|
|
||||||
return wd.lastLaunchedPackageName
|
|
||||||
}
|
|
||||||
|
|
||||||
func (wd *wdaDriver) AssertAppForeground(packageName string) error {
|
func (wd *wdaDriver) AssertAppForeground(packageName string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user