From 92d09a48a27f408e1692064fc7821bf9d009cb0c Mon Sep 17 00:00:00 2001 From: Srinivasan Sekar Date: Sat, 24 Jun 2017 11:46:02 +0530 Subject: [PATCH] Add toggleTouchIdEnrollment function (#659) * Added touchIDEnrollment feature * Added touchIDEnrollment feature * Added touchIDEnrollment feature --- src/main/java/io/appium/java_client/MobileCommand.java | 4 ++++ .../appium/java_client/ios/IOSMobileCommandHelper.java | 10 ++++++++++ .../io/appium/java_client/ios/PerformsTouchID.java | 9 +++++++++ .../java/io/appium/java_client/ios/AppXCUITTest.java | 1 + .../io/appium/java_client/ios/XCUIAutomationTest.java | 1 + 5 files changed, 25 insertions(+) diff --git a/src/main/java/io/appium/java_client/MobileCommand.java b/src/main/java/io/appium/java_client/MobileCommand.java index b027baeb6..40a131a0e 100644 --- a/src/main/java/io/appium/java_client/MobileCommand.java +++ b/src/main/java/io/appium/java_client/MobileCommand.java @@ -57,6 +57,7 @@ public class MobileCommand { //iOS protected static final String SHAKE; protected static final String TOUCH_ID; + protected static final String TOUCH_ID_ENROLLMENT; //Android protected static final String CURRENT_ACTIVITY; protected static final String END_TEST_COVERAGE; @@ -104,6 +105,7 @@ public class MobileCommand { LOCK = "lock"; SHAKE = "shake"; TOUCH_ID = "touchId"; + TOUCH_ID_ENROLLMENT = "toggleEnrollTouchId"; CURRENT_ACTIVITY = "currentActivity"; END_TEST_COVERAGE = "endTestCoverage"; @@ -153,6 +155,8 @@ public class MobileCommand { //iOS commandRepository.put(SHAKE, postC("/session/:sessionId/appium/device/shake")); commandRepository.put(TOUCH_ID, postC("/session/:sessionId/appium/simulator/touch_id")); + commandRepository.put(TOUCH_ID_ENROLLMENT, + postC("/session/:sessionId/appium/simulator/toggle_touch_id_enrollment")); //Android commandRepository.put(CURRENT_ACTIVITY, getC("/session/:sessionId/appium/device/current_activity")); diff --git a/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java b/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java index 9f4af73e3..d99842d33 100644 --- a/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java +++ b/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java @@ -47,4 +47,14 @@ public class IOSMobileCommandHelper extends MobileCommand { return new AbstractMap.SimpleEntry<>( TOUCH_ID, prepareArguments("match", match)); } + + /** + * This method forms a {@link java.util.Map} of parameters for the toggling touchId + * enrollment in simulator. + * + */ + public static Map.Entry> toggleTouchIdEnrollmentCommand() { + return new AbstractMap.SimpleEntry<>( + TOUCH_ID_ENROLLMENT, ImmutableMap.of()); + } } diff --git a/src/main/java/io/appium/java_client/ios/PerformsTouchID.java b/src/main/java/io/appium/java_client/ios/PerformsTouchID.java index 8f5555347..5b0b422f2 100644 --- a/src/main/java/io/appium/java_client/ios/PerformsTouchID.java +++ b/src/main/java/io/appium/java_client/ios/PerformsTouchID.java @@ -17,6 +17,7 @@ package io.appium.java_client.ios; import static io.appium.java_client.ios.IOSMobileCommandHelper.touchIdCommand; +import static io.appium.java_client.ios.IOSMobileCommandHelper.toggleTouchIdEnrollmentCommand; import io.appium.java_client.CommandExecutionHelper; import io.appium.java_client.ExecutesMethod; @@ -31,4 +32,12 @@ public interface PerformsTouchID extends ExecutesMethod { default void performTouchID(boolean match) { CommandExecutionHelper.execute(this, touchIdCommand(match)); } + + /** + * Enrolls touchId in iOS Simulators. + * + */ + default void toggleTouchIDEnrollment() { + CommandExecutionHelper.execute(this, toggleTouchIdEnrollmentCommand()); + } } diff --git a/src/test/java/io/appium/java_client/ios/AppXCUITTest.java b/src/test/java/io/appium/java_client/ios/AppXCUITTest.java index 8eda617d5..efbb81210 100644 --- a/src/test/java/io/appium/java_client/ios/AppXCUITTest.java +++ b/src/test/java/io/appium/java_client/ios/AppXCUITTest.java @@ -29,6 +29,7 @@ public class AppXCUITTest extends BaseIOSTest { capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, ""); capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.1"); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 6"); + capabilities.setCapability(IOSMobileCapabilityType.ALLOW_TOUCHID_ENROLL, "true"); //sometimes environment has performance problems capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000); capabilities diff --git a/src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java b/src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java index f6062b543..f4b2c99e0 100644 --- a/src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java +++ b/src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java @@ -50,6 +50,7 @@ public class XCUIAutomationTest extends AppXCUITTest { @Test public void testTouchId() { try { + driver.toggleTouchIDEnrollment(); driver.performTouchID(true); driver.performTouchID(false); assertEquals(true, true);