|
@@ -1,7 +1,6 @@
|
1
|
1
|
package com.reactnativenavigation.playground;
|
2
|
2
|
|
3
|
3
|
import android.provider.Settings;
|
4
|
|
-import android.support.annotation.RequiresApi;
|
5
|
4
|
import android.support.test.espresso.Espresso;
|
6
|
5
|
import android.support.test.espresso.IdlingResource;
|
7
|
6
|
import android.support.test.filters.SdkSuppress;
|
|
@@ -24,12 +23,9 @@ import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
24
|
23
|
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
25
|
24
|
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
26
|
25
|
import static org.assertj.core.api.Java6Assertions.assertThat;
|
27
|
|
-import static org.junit.Assume.assumeFalse;
|
28
|
|
-import static org.junit.Assume.assumeTrue;
|
29
|
26
|
|
30
|
27
|
@RunWith(AndroidJUnit4.class)
|
31
|
28
|
@SdkSuppress(minSdkVersion = 23)
|
32
|
|
-@RequiresApi(api = 23)
|
33
|
29
|
public class ApplicationLifecycleTest {
|
34
|
30
|
|
35
|
31
|
@Rule
|
|
@@ -37,11 +33,11 @@ public class ApplicationLifecycleTest {
|
37
|
33
|
@Override
|
38
|
34
|
protected void afterActivityLaunched() {
|
39
|
35
|
super.afterActivityLaunched();
|
40
|
|
- registerIdlingResource(rule.getActivity());
|
|
36
|
+ registerReactIdlingResource(rule.getActivity());
|
41
|
37
|
}
|
42
|
38
|
};
|
43
|
39
|
|
44
|
|
- private void registerIdlingResource(final NavigationActivity activity) {
|
|
40
|
+ private void registerReactIdlingResource(final NavigationActivity activity) {
|
45
|
41
|
Espresso.registerIdlingResources(new IdlingResource() {
|
46
|
42
|
@Override
|
47
|
43
|
public String getName() {
|
|
@@ -91,20 +87,12 @@ public class ApplicationLifecycleTest {
|
91
|
87
|
}
|
92
|
88
|
|
93
|
89
|
@Test
|
94
|
|
- public void startApp_RequiredOverlayPermissions_LoadsBridge_ThenShowsWelcomeScreen() throws Exception {
|
95
|
|
- assumeFalse(Settings.canDrawOverlays(getInstrumentation().getContext()));
|
|
90
|
+ public void acceptsOverlayPermissions_ShowsWelcomeScreen() throws Exception {
|
96
|
91
|
launchActivity();
|
97
|
92
|
acceptOverlayPermissionIfNeeded();
|
98
|
93
|
onView(withText("React Native Navigation!")).check(matches(isDisplayed()));
|
99
|
94
|
}
|
100
|
95
|
|
101
|
|
- @Test
|
102
|
|
- public void startApp_NoPermissionRequired_ShowsWelcomeScreen() {
|
103
|
|
- assumeTrue(Settings.canDrawOverlays(getInstrumentation().getContext()));
|
104
|
|
- launchActivity();
|
105
|
|
- onView(withText("React Native Navigation!")).check(matches(isDisplayed()));
|
106
|
|
- }
|
107
|
|
-
|
108
|
96
|
@Test
|
109
|
97
|
public void showsSplashOnStartup() throws Exception {
|
110
|
98
|
launchActivity();
|