|
@@ -2,14 +2,22 @@ package com.reactnativenavigation;
|
2
|
2
|
|
3
|
3
|
import android.view.View;
|
4
|
4
|
|
|
5
|
+import com.reactnativenavigation.controllers.ActivityLifecycleDelegate;
|
|
6
|
+
|
5
|
7
|
import org.junit.Test;
|
6
|
8
|
import org.robolectric.Robolectric;
|
7
|
9
|
import org.robolectric.android.controller.ActivityController;
|
8
|
10
|
|
9
|
11
|
import static org.assertj.core.api.Java6Assertions.assertThat;
|
|
12
|
+import static org.mockito.Mockito.mock;
|
|
13
|
+import static org.mockito.Mockito.times;
|
|
14
|
+import static org.mockito.Mockito.verify;
|
|
15
|
+import static org.mockito.Mockito.verifyNoMoreInteractions;
|
|
16
|
+import static org.mockito.Mockito.verifyZeroInteractions;
|
10
|
17
|
|
11
|
18
|
public class NavigationActivityTest extends BaseTest {
|
12
|
19
|
|
|
20
|
+
|
13
|
21
|
@Test
|
14
|
22
|
public void holdsContentView() throws Exception {
|
15
|
23
|
NavigationActivity activity = Robolectric.setupActivity(NavigationActivity.class);
|
|
@@ -22,6 +30,25 @@ public class NavigationActivityTest extends BaseTest {
|
22
|
30
|
@Test
|
23
|
31
|
public void reportsLifecycleEventsToDelegate() throws Exception {
|
24
|
32
|
ActivityController<NavigationActivity> activityController = Robolectric.buildActivity(NavigationActivity.class);
|
|
33
|
+ NavigationApplication.instance.getConfig().activityLifecycleDelegate = mock(ActivityLifecycleDelegate.class);
|
|
34
|
+ ActivityLifecycleDelegate activityLifecycleDelegate = NavigationApplication.instance.getConfig().activityLifecycleDelegate;
|
|
35
|
+
|
|
36
|
+ verifyZeroInteractions(activityLifecycleDelegate);
|
|
37
|
+
|
25
|
38
|
activityController.create();
|
|
39
|
+ verify(activityLifecycleDelegate, times(1)).onActivityCreated(activityController.get());
|
|
40
|
+ verifyNoMoreInteractions(activityLifecycleDelegate);
|
|
41
|
+
|
|
42
|
+ activityController.resume();
|
|
43
|
+ verify(activityLifecycleDelegate, times(1)).onActivityResumed(activityController.get(), activityController.get());
|
|
44
|
+ verifyNoMoreInteractions(activityLifecycleDelegate);
|
|
45
|
+
|
|
46
|
+ activityController.pause();
|
|
47
|
+ verify(activityLifecycleDelegate, times(1)).onActivityPaused(activityController.get());
|
|
48
|
+ verifyNoMoreInteractions(activityLifecycleDelegate);
|
|
49
|
+
|
|
50
|
+ activityController.destroy();
|
|
51
|
+ verify(activityLifecycleDelegate, times(1)).onActivityDestroyed(activityController.get());
|
|
52
|
+ verifyNoMoreInteractions(activityLifecycleDelegate);
|
26
|
53
|
}
|
27
|
|
-}
|
|
54
|
+}
|