|
@@ -1,25 +1,52 @@
|
1
|
1
|
package com.reactnativenavigation.playground;
|
2
|
2
|
|
3
|
|
-import android.support.test.espresso.action.ViewActions;
|
|
3
|
+import android.app.Activity;
|
|
4
|
+import android.app.Instrumentation;
|
|
5
|
+import android.provider.Settings;
|
|
6
|
+import android.support.test.espresso.intent.Intents;
|
4
|
7
|
import android.support.test.rule.ActivityTestRule;
|
5
|
8
|
import android.support.test.runner.AndroidJUnit4;
|
|
9
|
+import android.support.test.uiautomator.UiDevice;
|
|
10
|
+import android.support.test.uiautomator.UiObjectNotFoundException;
|
|
11
|
+import android.support.test.uiautomator.UiSelector;
|
6
|
12
|
|
7
|
13
|
import org.junit.Rule;
|
8
|
14
|
import org.junit.Test;
|
9
|
15
|
import org.junit.runner.RunWith;
|
10
|
16
|
|
|
17
|
+import static android.support.test.InstrumentationRegistry.getInstrumentation;
|
11
|
18
|
import static android.support.test.espresso.Espresso.onView;
|
|
19
|
+import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
|
20
|
+import static android.support.test.espresso.intent.matcher.IntentMatchers.hasAction;
|
|
21
|
+import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
12
|
22
|
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
13
|
23
|
|
14
|
24
|
@RunWith(AndroidJUnit4.class)
|
15
|
25
|
public class ApplicationTest {
|
16
|
26
|
|
17
|
27
|
@Rule
|
18
|
|
- public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class);
|
|
28
|
+ public ActivityTestRule<MainActivity> rule = new ActivityTestRule<>(MainActivity.class, false, false);
|
19
|
29
|
|
20
|
30
|
@Test
|
21
|
|
- public void startsTheApp() {
|
22
|
|
-
|
23
|
|
- onView(withText("Playground")).perform(ViewActions.click());
|
|
31
|
+ public void startAppShowsTheSplash() throws InterruptedException {
|
|
32
|
+ Intents.init();
|
|
33
|
+ Intents.intending(hasAction(Settings.ACTION_MANAGE_OVERLAY_PERMISSION)).respondWith(new Instrumentation.ActivityResult(Activity.RESULT_OK, null));
|
|
34
|
+
|
|
35
|
+ rule.launchActivity(null);
|
|
36
|
+
|
|
37
|
+ onView(withText("Splash :)")).check(matches(isDisplayed()));
|
|
38
|
+ Intents.release();
|
|
39
|
+ }
|
|
40
|
+
|
|
41
|
+ @Test
|
|
42
|
+ public void startAppLoadsBridgeShowsWelcomeScreen() throws UiObjectNotFoundException {
|
|
43
|
+ rule.launchActivity(null);
|
|
44
|
+
|
|
45
|
+ UiDevice.getInstance(getInstrumentation()).findObject(new UiSelector().text("Playground")).click();
|
|
46
|
+ UiDevice.getInstance(getInstrumentation()).findObject(new UiSelector().text("Permit drawing over other apps")).click();
|
|
47
|
+ UiDevice.getInstance(getInstrumentation()).pressBack();
|
|
48
|
+ UiDevice.getInstance(getInstrumentation()).pressBack();
|
|
49
|
+
|
|
50
|
+ onView(withText("React Native Navigation!")).check(matches(isDisplayed()));
|
24
|
51
|
}
|
25
|
52
|
}
|