Skip to content

Commit 92d09a4

Browse files
Add toggleTouchIdEnrollment function (appium#659)
* Added touchIDEnrollment feature * Added touchIDEnrollment feature * Added touchIDEnrollment feature
1 parent f6d93cc commit 92d09a4

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

src/main/java/io/appium/java_client/MobileCommand.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public class MobileCommand {
5757
//iOS
5858
protected static final String SHAKE;
5959
protected static final String TOUCH_ID;
60+
protected static final String TOUCH_ID_ENROLLMENT;
6061
//Android
6162
protected static final String CURRENT_ACTIVITY;
6263
protected static final String END_TEST_COVERAGE;
@@ -104,6 +105,7 @@ public class MobileCommand {
104105
LOCK = "lock";
105106
SHAKE = "shake";
106107
TOUCH_ID = "touchId";
108+
TOUCH_ID_ENROLLMENT = "toggleEnrollTouchId";
107109

108110
CURRENT_ACTIVITY = "currentActivity";
109111
END_TEST_COVERAGE = "endTestCoverage";
@@ -153,6 +155,8 @@ public class MobileCommand {
153155
//iOS
154156
commandRepository.put(SHAKE, postC("/session/:sessionId/appium/device/shake"));
155157
commandRepository.put(TOUCH_ID, postC("/session/:sessionId/appium/simulator/touch_id"));
158+
commandRepository.put(TOUCH_ID_ENROLLMENT,
159+
postC("/session/:sessionId/appium/simulator/toggle_touch_id_enrollment"));
156160
//Android
157161
commandRepository.put(CURRENT_ACTIVITY,
158162
getC("/session/:sessionId/appium/device/current_activity"));

src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,14 @@ public class IOSMobileCommandHelper extends MobileCommand {
4747
return new AbstractMap.SimpleEntry<>(
4848
TOUCH_ID, prepareArguments("match", match));
4949
}
50+
51+
/**
52+
* This method forms a {@link java.util.Map} of parameters for the toggling touchId
53+
* enrollment in simulator.
54+
*
55+
*/
56+
public static Map.Entry<String, Map<String, ?>> toggleTouchIdEnrollmentCommand() {
57+
return new AbstractMap.SimpleEntry<>(
58+
TOUCH_ID_ENROLLMENT, ImmutableMap.<String, Object>of());
59+
}
5060
}

src/main/java/io/appium/java_client/ios/PerformsTouchID.java

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

1919
import static io.appium.java_client.ios.IOSMobileCommandHelper.touchIdCommand;
20+
import static io.appium.java_client.ios.IOSMobileCommandHelper.toggleTouchIdEnrollmentCommand;
2021

2122
import io.appium.java_client.CommandExecutionHelper;
2223
import io.appium.java_client.ExecutesMethod;
@@ -31,4 +32,12 @@ public interface PerformsTouchID extends ExecutesMethod {
3132
default void performTouchID(boolean match) {
3233
CommandExecutionHelper.execute(this, touchIdCommand(match));
3334
}
35+
36+
/**
37+
* Enrolls touchId in iOS Simulators.
38+
*
39+
*/
40+
default void toggleTouchIDEnrollment() {
41+
CommandExecutionHelper.execute(this, toggleTouchIdEnrollmentCommand());
42+
}
3443
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class AppXCUITTest extends BaseIOSTest {
2929
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "");
3030
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.1");
3131
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 6");
32+
capabilities.setCapability(IOSMobileCapabilityType.ALLOW_TOUCHID_ENROLL, "true");
3233
//sometimes environment has performance problems
3334
capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000);
3435
capabilities

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public class XCUIAutomationTest extends AppXCUITTest {
5050

5151
@Test public void testTouchId() {
5252
try {
53+
driver.toggleTouchIDEnrollment();
5354
driver.performTouchID(true);
5455
driver.performTouchID(false);
5556
assertEquals(true, true);

0 commit comments

Comments
 (0)