Skip to content

Commit da9064b

Browse files
Merge branch 'master' of https://github.com/appium/java-client into TikhomirovSergey-SrinivasanTarget-TouchActionSplitting
2 parents f9a928e + 604b230 commit da9064b

File tree

7 files changed

+375
-316
lines changed

7 files changed

+375
-316
lines changed

README.md

Lines changed: 312 additions & 311 deletions
Large diffs are not rendered by default.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public static <T extends Object> T execute(ExecutesMethod executesMethod, String
3131
return handleResponse(executesMethod.execute(command));
3232
}
3333

34-
private static <T extends Object> T handleResponse(Response responce) {
35-
if (responce != null) {
36-
return (T) responce.getValue();
34+
private static <T extends Object> T handleResponse(Response response) {
35+
if (response != null) {
36+
return (T) response.getValue();
3737
}
3838
return null;
3939
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class MobileCommand {
5252
protected static final String GET_SESSION = "getSession";
5353
//iOS
5454
protected static final String SHAKE = "shake";
55+
protected static final String TOUCH_ID = "touchId";
5556
//Android
5657
protected static final String CURRENT_ACTIVITY = "currentActivity";
5758
protected static final String END_TEST_COVERAGE = "endTestCoverage";
@@ -95,6 +96,7 @@ private static Map<String, CommandInfo> createCommandRepository() {
9596
result.put(GET_SESSION,getC("/session/:sessionId/"));
9697
//iOS
9798
result.put(SHAKE, postC("/session/:sessionId/appium/device/shake"));
99+
result.put(TOUCH_ID, postC("/session/:sessionId/appium/simulator/touch_id"));
98100
//Android
99101
result.put(CURRENT_ACTIVITY,
100102
getC("/session/:sessionId/appium/device/current_activity"));

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
public class IOSDriver<T extends WebElement>
5252
extends AppiumDriver<T>
5353
implements HidesKeyboardWithKeyName, ShakesDevice,
54-
FindsByIosUIAutomation<T>, LocksIOSDevice {
54+
FindsByIosUIAutomation<T>, LocksIOSDevice, PerformsTouchID {
5555

5656
private static final String IOS_PLATFORM = MobilePlatform.IOS;
5757

@@ -165,7 +165,7 @@ public IOSDriver(Capabilities desiredCapabilities) {
165165
}
166166

167167
/**
168-
* @see io.appium.java_client.TouchableElement#swipe(int, int, int, int, int).
168+
* @see io.appium.java_client.CreatesSwipeAction#swipe(int, int, int, int, int).
169169
*/
170170
@Override public void swipe(int startx, int starty, int endx, int endy, int duration) {
171171
IOSTouchAction touchaction = new IOSTouchAction(this);

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,15 @@ public class IOSMobileCommandHelper extends MobileCommand {
8181
return new AbstractMap.SimpleEntry<>(
8282
SHAKE, ImmutableMap.<String, Object>of());
8383
}
84+
85+
/**
86+
* This method forms a {@link java.util.Map} of parameters for the touchId simulator.
87+
*
88+
* @param match If true, simulates a successful fingerprint scan. If false, simulates a failed fingerprint scan.
89+
*
90+
*/
91+
public static Map.Entry<String, Map<String, ?>> touchIdCommand(boolean match) {
92+
return new AbstractMap.SimpleEntry<>(
93+
TOUCH_ID, prepareArguments("match", match));
94+
}
8495
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.appium.java_client.ios;
18+
19+
import static io.appium.java_client.ios.IOSMobileCommandHelper.touchIdCommand;
20+
21+
import io.appium.java_client.CommandExecutionHelper;
22+
import io.appium.java_client.ExecutesMethod;
23+
24+
public interface PerformsTouchID extends ExecutesMethod {
25+
26+
/**
27+
* Simulate touchId event
28+
*
29+
* @param match If true, simulates a successful fingerprint scan. If false, simulates a failed fingerprint scan.
30+
*/
31+
default void performTouchID(boolean match) {
32+
CommandExecutionHelper.execute(this, touchIdCommand(match));
33+
}
34+
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,15 @@ public class XCUIAutomationTest {
9191
driver.rotate(landscapeLeftRotation);
9292
assertEquals(driver.rotation(), landscapeLeftRotation);
9393
}
94+
95+
@Test public void testTouchId() {
96+
try {
97+
driver.performTouchID(true);
98+
driver.performTouchID(false);
99+
assertEquals(true, true);
100+
} catch (Exception e) {
101+
throw e;
102+
}
103+
104+
}
94105
}

0 commit comments

Comments
 (0)