mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-02 14:29:44 +08:00
fix: assert app activity
This commit is contained in:
@@ -183,11 +183,21 @@ var androidActivities = map[string]map[string]string{
|
|||||||
"feed": ".splash.SplashActivity",
|
"feed": ".splash.SplashActivity",
|
||||||
"live": ".live.LivePlayActivity",
|
"live": ".live.LivePlayActivity",
|
||||||
},
|
},
|
||||||
|
// DY lite
|
||||||
|
"com.ss.android.ugc.aweme.lite": {
|
||||||
|
"feed": ".splash.SplashActivity",
|
||||||
|
"live": ".live.LivePlayActivity",
|
||||||
|
},
|
||||||
// KS
|
// KS
|
||||||
"com.smile.gifmaker": {
|
"com.smile.gifmaker": {
|
||||||
"feed": "com.yxcorp.gifshow.HomeActivity",
|
"feed": "com.yxcorp.gifshow.HomeActivity",
|
||||||
"live": "com.kuaishou.live.core.basic.activity.LiveSlideActivity",
|
"live": "com.kuaishou.live.core.basic.activity.LiveSlideActivity",
|
||||||
},
|
},
|
||||||
|
// KS lite
|
||||||
|
"com.kuaishou.nebula": {
|
||||||
|
"feed": "com.yxcorp.gifshow.HomeActivity",
|
||||||
|
"live": "com.kuaishou.live.core.basic.activity.LiveSlideActivity",
|
||||||
|
},
|
||||||
// TODO: SPH, XHS
|
// TODO: SPH, XHS
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,16 +457,26 @@ func (dExt *DriverExt) assertActivity(packageName, activityType string) error {
|
|||||||
fmt.Sprintf("foreground app %s, expect %s", app.PackageName, packageName))
|
fmt.Sprintf("foreground app %s, expect %s", app.PackageName, packageName))
|
||||||
}
|
}
|
||||||
|
|
||||||
var expectActivity string
|
activities, ok := androidActivities[app.PackageName]
|
||||||
if activities, ok := androidActivities[app.PackageName]; ok {
|
if !ok {
|
||||||
if activity, ok := activities[activityType]; ok {
|
msg := fmt.Sprintf("app package %s not configured", app.PackageName)
|
||||||
if strings.HasSuffix(app.Activity, activity) {
|
log.Error().Interface("app", app.AppBaseInfo).Msg(msg)
|
||||||
return nil
|
return errors.Wrap(code.MobileUIActivityNotMatchError, msg)
|
||||||
}
|
|
||||||
expectActivity = activity
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expectActivity, ok := activities[activityType]
|
||||||
|
if !ok {
|
||||||
|
msg := fmt.Sprintf("app package %s %s not configured", app.PackageName, activityType)
|
||||||
|
log.Error().Interface("app", app.AppBaseInfo).Msg(msg)
|
||||||
|
return errors.Wrap(code.MobileUIActivityNotMatchError, msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// assert success
|
||||||
|
if strings.HasSuffix(app.Activity, expectActivity) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// assert failed
|
||||||
log.Error().Interface("app", app.AppBaseInfo).Msg("app activity not match")
|
log.Error().Interface("app", app.AppBaseInfo).Msg("app activity not match")
|
||||||
return errors.Wrap(code.MobileUIActivityNotMatchError,
|
return errors.Wrap(code.MobileUIActivityNotMatchError,
|
||||||
fmt.Sprintf("foreground activity %s, expect %s %s",
|
fmt.Sprintf("foreground activity %s, expect %s %s",
|
||||||
|
|||||||
Reference in New Issue
Block a user