|
@@ -0,0 +1,53 @@
|
|
1
|
+package com.reactnativenavigation.viewcontrollers;
|
|
2
|
+
|
|
3
|
+import android.app.Activity;
|
|
4
|
+
|
|
5
|
+import com.reactnativenavigation.BaseTest;
|
|
6
|
+import com.reactnativenavigation.mocks.TestContainerView;
|
|
7
|
+import com.reactnativenavigation.parse.NavigationOptions;
|
|
8
|
+
|
|
9
|
+import org.junit.Test;
|
|
10
|
+
|
|
11
|
+import static org.assertj.core.api.Java6Assertions.assertThat;
|
|
12
|
+import static org.mockito.Mockito.spy;
|
|
13
|
+import static org.mockito.Mockito.times;
|
|
14
|
+import static org.mockito.Mockito.verify;
|
|
15
|
+
|
|
16
|
+public class ContainerViewControllerTest extends BaseTest {
|
|
17
|
+ private ContainerViewController uut;
|
|
18
|
+ private Activity activity;
|
|
19
|
+
|
|
20
|
+ @Override
|
|
21
|
+ public void beforeEach() {
|
|
22
|
+ super.beforeEach();
|
|
23
|
+ activity = newActivity();
|
|
24
|
+ }
|
|
25
|
+
|
|
26
|
+ @Test
|
|
27
|
+ public void createsViewFromContainerViewCreator() throws Exception {
|
|
28
|
+ final ContainerViewController.ContainerView view = new TestContainerView(activity);
|
|
29
|
+ uut = new ContainerViewController(newActivity(), "id1", "containerName", new ContainerViewController.ContainerViewCreator() {
|
|
30
|
+ @Override
|
|
31
|
+ public ContainerViewController.ContainerView create(final Activity activity1, final String containerId, final String containerName) {
|
|
32
|
+ return view;
|
|
33
|
+ }
|
|
34
|
+ }, new NavigationOptions());
|
|
35
|
+ assertThat(uut.getView()).isSameAs(view);
|
|
36
|
+ }
|
|
37
|
+
|
|
38
|
+ @Test
|
|
39
|
+ public void containerViewDestroyedOnDestory() throws Exception {
|
|
40
|
+ final ContainerViewController.ContainerView view = spy(new TestContainerView(activity));
|
|
41
|
+ uut = new ContainerViewController(newActivity(), "id1", "containerName", new ContainerViewController.ContainerViewCreator() {
|
|
42
|
+ @Override
|
|
43
|
+ public ContainerViewController.ContainerView create(final Activity activity1, final String containerId, final String containerName) {
|
|
44
|
+ return view;
|
|
45
|
+ }
|
|
46
|
+ }, new NavigationOptions());
|
|
47
|
+ uut.ensureViewIsCreated();
|
|
48
|
+
|
|
49
|
+ verify(view, times(0)).destroy();
|
|
50
|
+ uut.destroy();
|
|
51
|
+ verify(view, times(1)).destroy();
|
|
52
|
+ }
|
|
53
|
+}
|