|
1 | 1 | package io.appium.java_client.android;
|
2 | 2 |
|
3 | 3 | import io.appium.java_client.AppiumBy;
|
| 4 | +import io.appium.java_client.TestUtils; |
4 | 5 | import io.appium.java_client.flutter.commands.DoubleClickParameter;
|
5 | 6 | import io.appium.java_client.flutter.commands.DragAndDropParameter;
|
6 | 7 | import io.appium.java_client.flutter.commands.LongPressParameter;
|
|
10 | 11 | import org.openqa.selenium.Point;
|
11 | 12 | import org.openqa.selenium.WebElement;
|
12 | 13 |
|
| 14 | +import java.io.IOException; |
| 15 | + |
13 | 16 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
14 | 17 | import static org.junit.jupiter.api.Assertions.assertFalse;
|
15 | 18 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
@@ -115,4 +118,25 @@ void testDragAndDropCommand() {
|
115 | 118 | assertEquals(driver.findElement(AppiumBy.flutterText("The box is dropped")).getText(), "The box is dropped");
|
116 | 119 |
|
117 | 120 | }
|
| 121 | + |
| 122 | + @Test |
| 123 | + void testCameraMocking() throws IOException { |
| 124 | + driver.findElement(BaseFlutterTest.LOGIN_BUTTON).click(); |
| 125 | + openScreen("Image Picker"); |
| 126 | + |
| 127 | + final String successQr = driver.injectMockImage( |
| 128 | + TestUtils.resourcePathToAbsolutePath("success_qr.png").toFile()); |
| 129 | + driver.injectMockImage( |
| 130 | + TestUtils.resourcePathToAbsolutePath("second_qr.png").toFile()); |
| 131 | + |
| 132 | + driver.findElement(AppiumBy.flutterKey("capture_image")).click(); |
| 133 | + driver.findElement(AppiumBy.flutterText("PICK")).click(); |
| 134 | + assertTrue(driver.findElement(AppiumBy.flutterText("SecondInjectedImage")).isDisplayed()); |
| 135 | + |
| 136 | + driver.activateInjectedImage(successQr); |
| 137 | + |
| 138 | + driver.findElement(AppiumBy.flutterKey("capture_image")).click(); |
| 139 | + driver.findElement(AppiumBy.flutterText("PICK")).click(); |
| 140 | + assertTrue(driver.findElement(AppiumBy.flutterText("Success!")).isDisplayed()); |
| 141 | + } |
118 | 142 | }
|
0 commit comments