From a66bcc4672de192d5a937f4d37be3a42e0ba8277 Mon Sep 17 00:00:00 2001 From: Eugene Matsyuk Date: Sat, 24 Sep 2022 17:36:01 +0400 Subject: [PATCH] fix the exploit test --- .../device_tests/DeviceExploitSampleTest.kt | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/samples/kaspresso-sample/src/androidTest/kotlin/com/kaspersky/kaspressample/device_tests/DeviceExploitSampleTest.kt b/samples/kaspresso-sample/src/androidTest/kotlin/com/kaspersky/kaspressample/device_tests/DeviceExploitSampleTest.kt index c61f1a65f..9b9ede8de 100644 --- a/samples/kaspresso-sample/src/androidTest/kotlin/com/kaspersky/kaspressample/device_tests/DeviceExploitSampleTest.kt +++ b/samples/kaspresso-sample/src/androidTest/kotlin/com/kaspersky/kaspressample/device_tests/DeviceExploitSampleTest.kt @@ -35,47 +35,51 @@ class DeviceExploitSampleTest : TestCase() { device.exploit.setAutoRotationEnabled(true) }.run { - activityRule.scenario.onActivity { activity -> - step("Change orientation manually") { - device.exploit.setOrientation(Exploit.DeviceOrientation.Landscape) + step("Change orientation manually") { + device.exploit.setOrientation(Exploit.DeviceOrientation.Landscape) + activityRule.scenario.onActivity { activity -> assertTrueSafely { Configuration.ORIENTATION_LANDSCAPE == activity.resources.configuration.orientation } + } - device.exploit.setOrientation(Exploit.DeviceOrientation.Portrait) + device.exploit.setOrientation(Exploit.DeviceOrientation.Portrait) + activityRule.scenario.onActivity { activity -> assertTrueSafely { Configuration.ORIENTATION_PORTRAIT == activity.resources.configuration.orientation } } + } - step("Rotate device") { - device.exploit.rotate() + step("Rotate device") { + device.exploit.rotate() + activityRule.scenario.onActivity { activity -> assertTrueSafely { Configuration.ORIENTATION_LANDSCAPE == activity.resources.configuration.orientation } } + } - step("Open web view and press back button") { - MainScreen { - flakySafely { - webViewButton { - click() - } - device.activities.isCurrent(WebViewActivity::class.java) + step("Open web view and press back button") { + MainScreen { + flakySafely { + webViewButton { + click() } + device.activities.isCurrent(WebViewActivity::class.java) } - - device.exploit.pressBack(true) - device.activities.isCurrent(MainActivity::class.java) // Asserts that MainActivity is resumed } - step("Press home button") { - device.exploit.pressHome() - assertNull(device.activities.getResumed()) - } + device.exploit.pressBack(true) + device.activities.isCurrent(MainActivity::class.java) // Asserts that MainActivity is resumed + } + + step("Press home button") { + device.exploit.pressHome() + assertNull(device.activities.getResumed()) } } }