feat: add validator AssertAppInForeground and AssertAppNotInForeground

This commit is contained in:
lilong.129
2023-04-16 18:54:40 +08:00
parent 2249cfab9e
commit 2644c24fae
7 changed files with 97 additions and 14 deletions
+30
View File
@@ -468,6 +468,36 @@ func (s *StepMobileUIValidation) AssertImageNotExists(expectedImagePath string,
return s
}
func (s *StepMobileUIValidation) AssertAppInForeground(packageName string, msg ...string) *StepMobileUIValidation {
v := Validator{
Check: uixt.SelectorForegroundApp,
Assert: uixt.AssertionEqual,
Expect: packageName,
}
if len(msg) > 0 {
v.Message = msg[0]
} else {
v.Message = fmt.Sprintf("app [%s] should be in foreground", packageName)
}
s.step.Validators = append(s.step.Validators, v)
return s
}
func (s *StepMobileUIValidation) AssertAppNotInForeground(packageName string, msg ...string) *StepMobileUIValidation {
v := Validator{
Check: uixt.SelectorForegroundApp,
Assert: uixt.AssertionNotEqual,
Expect: packageName,
}
if len(msg) > 0 {
v.Message = msg[0]
} else {
v.Message = fmt.Sprintf("app [%s] should not be in foreground", packageName)
}
s.step.Validators = append(s.step.Validators, v)
return s
}
func (s *StepMobileUIValidation) Name() string {
return s.step.Name
}