Skip to content

Commit

Permalink
Add toggleTouchIdEnrollment function (#659)
Browse files Browse the repository at this point in the history
* Added touchIDEnrollment feature

* Added touchIDEnrollment feature

* Added touchIDEnrollment feature
  • Loading branch information
SrinivasanTarget authored Jun 24, 2017
1 parent f6d93cc commit 92d09a4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/io/appium/java_client/MobileCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Map<String, ?>> toggleTouchIdEnrollmentCommand() {
return new AbstractMap.SimpleEntry<>(
TOUCH_ID_ENROLLMENT, ImmutableMap.<String, Object>of());
}
}
9 changes: 9 additions & 0 deletions src/main/java/io/appium/java_client/ios/PerformsTouchID.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
}
}
1 change: 1 addition & 0 deletions src/test/java/io/appium/java_client/ios/AppXCUITTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 92d09a4

Please sign in to comment.