Skip to content

Commit 0e9c2ea

Browse files
author
Mykola Mokhnach
committed
Added locking tests for iOS
1 parent a67b61c commit 0e9c2ea

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/test/java/io/appium/java_client/android/AndroidDriverTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,13 @@ public class AndroidDriverTest extends BaseAndroidTest {
102102
}
103103

104104
@Test public void lockTest() {
105-
driver.lockDevice();
106-
assertEquals(true, driver.isLocked());
107-
driver.unlockDevice();
108-
assertEquals(false, driver.isLocked());
105+
try {
106+
driver.lockDevice();
107+
assertTrue(driver.isDeviceLocked());
108+
} finally {
109+
driver.unlockDevice();
110+
assertFalse(driver.isDeviceLocked());
111+
}
109112
}
110113

111114
@Test public void runAppInBackgroundTest() {

src/test/java/io/appium/java_client/ios/IOSDriverTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package io.appium.java_client.ios;
1818

1919
import static org.junit.Assert.assertEquals;
20+
import static org.junit.Assert.assertFalse;
2021
import static org.junit.Assert.assertTrue;
2122

2223
import io.appium.java_client.MobileElement;
@@ -27,9 +28,6 @@
2728
import org.openqa.selenium.ScreenOrientation;
2829
import org.openqa.selenium.html5.Location;
2930

30-
import java.time.Duration;
31-
import java.util.function.Supplier;
32-
3331
public class IOSDriverTest extends AppIOSTest {
3432

3533
//TODO There is no ability to check this function usibg simulators.
@@ -62,11 +60,13 @@ public void getDeviceTimeTest() {
6260
}
6361

6462
@Test public void lockTest() {
65-
Supplier<Boolean> lock = () -> {
66-
driver.lockDevice(Duration.ofSeconds(20));
67-
return true;
68-
};
69-
assertTrue(lock.get());
63+
try {
64+
driver.lockDevice();
65+
assertTrue(driver.isDeviceLocked());
66+
} finally {
67+
driver.unlockDevice();
68+
assertFalse(driver.isDeviceLocked());
69+
}
7070
}
7171

7272
@Test public void pullFileTest() {

0 commit comments

Comments
 (0)