|
2 | 2 |
|
3 | 3 | import androidx.test.rule.ActivityTestRule;
|
4 | 4 | import androidx.test.ext.junit.runners.AndroidJUnit4;
|
| 5 | +import androidx.test.uiautomator.UiDevice; |
| 6 | +import androidx.test.uiautomator.UiObject; |
| 7 | +import androidx.test.uiautomator.UiSelector; |
5 | 8 |
|
6 | 9 | import org.junit.Rule;
|
7 | 10 | import org.junit.Test;
|
|
10 | 13 | import static androidx.test.espresso.Espresso.onView;
|
11 | 14 | import static androidx.test.espresso.action.ViewActions.click;
|
12 | 15 | import static androidx.test.espresso.action.ViewActions.replaceText;
|
| 16 | +import static androidx.test.espresso.matcher.ViewMatchers.withParent; |
13 | 17 | import static androidx.test.espresso.matcher.ViewMatchers.withResourceName;
|
14 | 18 | import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
15 |
| - |
16 |
| -import com.instabug.flutter.InstabugFlutterPlugin; |
| 19 | +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; |
| 20 | +import static org.hamcrest.Matchers.allOf; |
17 | 21 |
|
18 | 22 | @RunWith(AndroidJUnit4.class)
|
19 | 23 | public class InvokeInstabugUITest {
|
| 24 | + UiDevice device = UiDevice.getInstance(getInstrumentation()); |
20 | 25 |
|
21 | 26 | @Rule
|
22 | 27 | public ActivityTestRule<MainActivity> mActivityRule =
|
23 | 28 | new ActivityTestRule<>(MainActivity.class);
|
24 | 29 |
|
25 | 30 | @Test
|
26 |
| - public void ensureInstabugInvocati1on() throws InterruptedException { |
27 |
| - disableScreenShotByMediaProjection(); |
| 31 | + public void ensureInstabugInvocation() throws InterruptedException { |
28 | 32 | Thread.sleep(1000);
|
29 | 33 | onView(withResourceName("instabug_floating_button")).perform(click());
|
30 | 34 | Thread.sleep(1000);
|
| 35 | + |
| 36 | + // Dismiss media projection prompt. |
| 37 | + // This is a temporary solution as we are dropping media projection in a future release. |
| 38 | + device.pressBack(); |
| 39 | + Thread.sleep(1000); |
| 40 | + |
31 | 41 | onView(withText("Report a bug")).perform(click());
|
32 | 42 | Thread.sleep(1000);
|
33 |
| - onView( withResourceName( "instabug_edit_text_email")). perform( replaceText( "[email protected]")); |
| 43 | + |
| 44 | + onView( |
| 45 | + allOf( |
| 46 | + withResourceName("ib_edit_text"), |
| 47 | + withParent(withResourceName("instabug_edit_text_email")) |
| 48 | + ) |
| 49 | + ). perform( replaceText( "[email protected]")); |
| 50 | + |
34 | 51 | onView(withResourceName("instabug_bugreporting_send")).perform(click());
|
35 |
| - onView(withResourceName("instabug_success_dialog_container")).perform(click()); |
36 |
| - } |
37 | 52 |
|
38 |
| - private void disableScreenShotByMediaProjection() { |
39 |
| - InstabugFlutterPlugin.enableScreenShotByMediaProjection(false); |
| 53 | + UiObject successDialog = device.findObject(new UiSelector().resourceIdMatches(".*/id:instabug_success_dialog_container")); |
| 54 | + successDialog.waitForExists(3000); |
40 | 55 | }
|
41 | 56 | }
|
42 | 57 |
|
0 commit comments