Browse Source

android: refactor

Daniel Zlotin 7 years ago
parent
commit
7aa098eb98

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java View File

47
         host.getReactInstanceManager().addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
47
         host.getReactInstanceManager().addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
48
             @Override
48
             @Override
49
             public void onReactContextInitialized(ReactContext context) {
49
             public void onReactContextInitialized(ReactContext context) {
50
+                // TODO should we implement this line also if context already exists onCreate?
50
                 new NavigationEventEmitter(context).emitAppLaunched();
51
                 new NavigationEventEmitter(context).emitAppLaunched();
51
             }
52
             }
52
         });
53
         });

+ 9
- 2
playground/android/app/src/androidTest/java/com/reactnativenavigation/playground/ApplicationLifecycleTest.java View File

78
         rule.launchActivity(null);
78
         rule.launchActivity(null);
79
     }
79
     }
80
 
80
 
81
-    private void acceptPermission() throws Exception {
81
+    private void acceptPermissionIfNeeded() throws Exception {
82
+        if (Settings.canDrawOverlays(getInstrumentation().getContext())) {
83
+            return;
84
+        }
82
         UiDevice.getInstance(getInstrumentation()).findObject(new UiSelector().text("Playground")).click();
85
         UiDevice.getInstance(getInstrumentation()).findObject(new UiSelector().text("Playground")).click();
83
         UiDevice.getInstance(getInstrumentation()).findObject(new UiSelector().text("Permit drawing over other apps")).click();
86
         UiDevice.getInstance(getInstrumentation()).findObject(new UiSelector().text("Permit drawing over other apps")).click();
84
         UiDevice.getInstance(getInstrumentation()).pressBack();
87
         UiDevice.getInstance(getInstrumentation()).pressBack();
90
     public void startApp_HandleOverlayPermissions_LoadsBridge_ThenShowsWelcomeScreen() throws Exception {
93
     public void startApp_HandleOverlayPermissions_LoadsBridge_ThenShowsWelcomeScreen() throws Exception {
91
         assumeFalse(Settings.canDrawOverlays(getInstrumentation().getContext()));
94
         assumeFalse(Settings.canDrawOverlays(getInstrumentation().getContext()));
92
         launchActivity();
95
         launchActivity();
93
-        acceptPermission();
96
+        acceptPermissionIfNeeded();
94
         onView(withText("React Native Navigation!")).check(matches(isDisplayed()));
97
         onView(withText("React Native Navigation!")).check(matches(isDisplayed()));
95
     }
98
     }
96
 
99
 
100
         launchActivity();
103
         launchActivity();
101
         onView(withText("React Native Navigation!")).check(matches(isDisplayed()));
104
         onView(withText("React Native Navigation!")).check(matches(isDisplayed()));
102
     }
105
     }
106
+
107
+    @Test
108
+    public void () {
109
+    }
103
 }
110
 }