Skip to content

Commit 7af738f

Browse files
Merge pull request #695 from mykola-mokhnach/update_enroll
Update touch ID enroll method
2 parents 124e2df + 6f3351d commit 7af738f

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,23 @@ public class IOSMobileCommandHelper extends MobileCommand {
5151
/**
5252
* This method forms a {@link java.util.Map} of parameters for the toggling touchId
5353
* enrollment in simulator.
54-
*
54+
* The method is deprecated. Please use {@link #toggleTouchIdEnrollmentCommand(boolean)} instead.
5555
*/
56+
@Deprecated
5657
public static Map.Entry<String, Map<String, ?>> toggleTouchIdEnrollmentCommand() {
5758
return new AbstractMap.SimpleEntry<>(
5859
TOUCH_ID_ENROLLMENT, ImmutableMap.<String, Object>of());
5960
}
61+
62+
/**
63+
* This method forms a {@link java.util.Map} of parameters for the toggling touchId
64+
* enrollment in simulator.
65+
*
66+
* @param enabled Whether to enable or disable Touch ID Enrollment for Simulator.
67+
*
68+
*/
69+
public static Map.Entry<String, Map<String, ?>> toggleTouchIdEnrollmentCommand(boolean enabled) {
70+
return new AbstractMap.SimpleEntry<>(
71+
TOUCH_ID_ENROLLMENT, prepareArguments("enabled", enabled));
72+
}
6073
}

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,24 @@ default void performTouchID(boolean match) {
3535

3636
/**
3737
* Enrolls touchId in iOS Simulators.
38-
*
38+
* This method is deprecated. Please use {@link #toggleTouchIDEnrollment(boolean)} instead
3939
*/
40+
@Deprecated
4041
default void toggleTouchIDEnrollment() {
4142
CommandExecutionHelper.execute(this, toggleTouchIdEnrollmentCommand());
4243
}
44+
45+
/**
46+
* Enrolls touchId in iOS Simulators. This call will only work if Appium process or its
47+
* parent application (e.g. Terminal.app or Appium.app) has
48+
* access to Mac OS accessibility in System Preferences &gt;
49+
* Security &amp; Privacy &gt; Privacy &gt; Accessibility list.
50+
*
51+
* @param enabled Whether to enable or disable Touch ID Enrollment. The actual state of the feature
52+
* will only be changed if the current value is different from the previous one.
53+
* Multiple calls of the method with the same argument value have no effect.
54+
*/
55+
default void toggleTouchIDEnrollment(boolean enabled) {
56+
CommandExecutionHelper.execute(this, toggleTouchIdEnrollmentCommand(enabled));
57+
}
4358
}

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

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

5151
@Test public void testTouchId() {
5252
try {
53-
driver.toggleTouchIDEnrollment();
53+
driver.toggleTouchIDEnrollment(true);
5454
driver.performTouchID(true);
5555
driver.performTouchID(false);
5656
assertEquals(true, true);

0 commit comments

Comments
 (0)