Skip to content

Commit

Permalink
Merge pull request #460 from KasperskyLab/TECH-new-dialogs-safety
Browse files Browse the repository at this point in the history
TECH: fix system dialog provider
  • Loading branch information
Areyana authored Dec 21, 2022
2 parents 53705be + e38f9ed commit df29037
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.kaspersky.kaspresso.device.server.AdbServer
import com.kaspersky.kaspresso.instrumental.InstrumentalDependencyProvider
import com.kaspersky.kaspresso.logger.UiTestLogger
import java.util.concurrent.TimeUnit
import java.util.regex.Pattern

/**
* The implementation of the [SystemDialogSafetyProvider] interface.
Expand Down Expand Up @@ -100,10 +101,12 @@ class SystemDialogSafetyProviderImpl(

/**
* Checks if error is allowed and android system dialogs/windows are overlaying the app.
* Aware to use By.pkg with String, cause it will cause to use Pattern.quote in internal code,
* internal use Pattern.match() method, so we need regex that will match full string, not part.
*/
private fun isAndroidSystemDetected(): Boolean {
with(uiDevice) {
if (isVisible(By.pkg("android").clazz(FrameLayout::class.java))) {
if (isVisible(By.pkg(Pattern.compile("\\S*google.android\\S*")).clazz(FrameLayout::class.java))) {
logger.i("The android system dialog/window was detected")
return true
}
Expand Down

0 comments on commit df29037

Please sign in to comment.