Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE-656: add flag to remove PermissionController #657

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.kaspersky.kaspresso.params

data class SystemDialogsSafetyParams(
val shouldIgnoreKeyboard: Boolean
val shouldIgnoreKeyboard: Boolean,
val shouldIgnorePermissionDialogs: Boolean
) {
companion object {
fun default() = SystemDialogsSafetyParams(shouldIgnoreKeyboard = false)
fun default() = SystemDialogsSafetyParams(
shouldIgnoreKeyboard = false,
shouldIgnorePermissionDialogs = false
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class SystemDialogSafetyProviderImpl(

private val attemptsToSuppress: List<(UiDevice, AdbServer) -> Unit> = listOf(
{ _, adbServer ->
adbServer.performShell("input keyevent KEYCODE_BACK")
adbServer.performShell("input keyevent KEYCODE_ENTER")
adbServer.performShell("input keyevent KEYCODE_ENTER")
adbServer.performShell("input", listOf("keyevent", "KEYCODE_BACK"))
adbServer.performShell("input", listOf("keyevent", "KEYCODE_ENTER"))
adbServer.performShell("input", listOf("keyevent", "KEYCODE_ENTER"))
},
{ uiDevice, _ -> uiDevice.wait(Until.findObject(By.res("android:id/button1")), DEFAULT_TIMEOUT).click() },
{ uiDevice, _ -> uiDevice.wait(Until.findObject(By.res("android:id/closeButton")), DEFAULT_TIMEOUT).click() },
Expand Down Expand Up @@ -111,7 +111,12 @@ class SystemDialogSafetyProviderImpl(
*/
private fun isAndroidSystemDetected(): Boolean {
with(uiDevice) {
var isSystemDialogVisible = SystemDialogSafetyPattern.values().any { isVisible(By.pkg(it.pattern).clazz(FrameLayout::class.java)) }
var isSystemDialogVisible = if (systemDialogsSafetyParams.shouldIgnorePermissionDialogs) {
SystemDialogSafetyPattern.values().filter { it != SystemDialogSafetyPattern.PERMISSION_API30 && it != SystemDialogSafetyPattern.PERMISSION_API23}
.any { isVisible(By.pkg(it.pattern).clazz(FrameLayout::class.java)) }
} else {
SystemDialogSafetyPattern.values().any { isVisible(By.pkg(it.pattern).clazz(FrameLayout::class.java)) }
}

if (systemDialogsSafetyParams.shouldIgnoreKeyboard) {
val isKeyboardVisible = isVisible(By.pkg(Pattern.compile("\\S*google.android.inputmethod\\S*")).clazz(FrameLayout::class.java))
Expand Down
Loading