소스 검색

Push and Pop always accept a promise (#2514)

Guy Carmeli 6 년 전
부모
커밋
abb67a2640
No account linked to committer's email address

+ 0
- 8
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/StackController.java 파일 보기

26
 		this.animator = animator;
26
 		this.animator = animator;
27
 	}
27
 	}
28
 
28
 
29
-	public void push(final ViewController child) {
30
-		push(child, null);
31
-	}
32
-
33
 	public void push(final ViewController child, final Promise promise) {
29
 	public void push(final ViewController child, final Promise promise) {
34
 		final ViewController previousTop = peek();
30
 		final ViewController previousTop = peek();
35
 
31
 
58
 		pop(true, promise);
54
 		pop(true, promise);
59
 	}
55
 	}
60
 
56
 
61
-	void pop() {
62
-		pop(true, null);
63
-	}
64
-
65
 	private void pop(boolean animate, final Promise promise) {
57
 	private void pop(boolean animate, final Promise promise) {
66
 		if (!canPop()) {
58
 		if (!canPop()) {
67
 			Navigator.rejectPromise(promise);
59
 			Navigator.rejectPromise(promise);

+ 4
- 14
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/BottomTabsControllerTest.java 파일 보기

57
         List<ViewController> tabs = createTabs();
57
         List<ViewController> tabs = createTabs();
58
         uut.setTabs(tabs);
58
         uut.setTabs(tabs);
59
         assertThat(uut.getView().getChildCount()).isEqualTo(6);
59
         assertThat(uut.getView().getChildCount()).isEqualTo(6);
60
-        assertThat(uut.getChildControllers()).extracting(new Extractor<ViewController, Integer>() {
61
-            @Override
62
-            public Integer extract(final ViewController input) {
63
-                return input.getView().getVisibility();
64
-            }
65
-        }).containsExactly(View.VISIBLE, View.GONE, View.GONE, View.GONE, View.GONE);
60
+        assertThat(uut.getChildControllers()).extracting((Extractor<ViewController, Integer>) input -> input.getView().getVisibility()).containsExactly(View.VISIBLE, View.GONE, View.GONE, View.GONE, View.GONE);
66
     }
61
     }
67
 
62
 
68
     @Test
63
     @Test
73
         uut.selectTabAtIndex(3);
68
         uut.selectTabAtIndex(3);
74
 
69
 
75
         assertThat(uut.getSelectedIndex()).isEqualTo(3);
70
         assertThat(uut.getSelectedIndex()).isEqualTo(3);
76
-        assertThat(uut.getChildControllers()).extracting(new Extractor<ViewController, Integer>() {
77
-            @Override
78
-            public Integer extract(final ViewController input) {
79
-                return input.getView().getVisibility();
80
-            }
81
-        }).containsExactly(View.GONE, View.GONE, View.GONE, View.VISIBLE, View.GONE);
71
+        assertThat(uut.getChildControllers()).extracting((Extractor<ViewController, Integer>) input -> input.getView().getVisibility()).containsExactly(View.GONE, View.GONE, View.GONE, View.VISIBLE, View.GONE);
82
     }
72
     }
83
 
73
 
84
     @Test
74
     @Test
86
         assertThat(uut.findControllerById("123")).isNull();
76
         assertThat(uut.findControllerById("123")).isNull();
87
         assertThat(uut.findControllerById(uut.getId())).isEqualTo(uut);
77
         assertThat(uut.findControllerById(uut.getId())).isEqualTo(uut);
88
         StackController inner = new StackController(activity, "inner");
78
         StackController inner = new StackController(activity, "inner");
89
-        inner.push(child1);
79
+        inner.push(child1, new MockPromise());
90
         assertThat(uut.findControllerById(child1.getId())).isNull();
80
         assertThat(uut.findControllerById(child1.getId())).isNull();
91
-        uut.setTabs(Arrays.<ViewController>asList(inner));
81
+        uut.setTabs(Collections.singletonList(inner));
92
         assertThat(uut.findControllerById(child1.getId())).isEqualTo(child1);
82
         assertThat(uut.findControllerById(child1.getId())).isEqualTo(child1);
93
     }
83
     }
94
 
84
 

+ 27
- 27
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/NavigatorTest.java 파일 보기

62
     @Test
62
     @Test
63
     public void push() throws Exception {
63
     public void push() throws Exception {
64
         StackController stackController = newStack();
64
         StackController stackController = newStack();
65
-        stackController.push(child1);
65
+        stackController.push(child1, new MockPromise());
66
         uut.setRoot(stackController);
66
         uut.setRoot(stackController);
67
 
67
 
68
         assertIsChildById(uut.getView(), stackController.getView());
68
         assertIsChildById(uut.getView(), stackController.getView());
86
         BottomTabsController bottomTabsController = newTabs();
86
         BottomTabsController bottomTabsController = newTabs();
87
         StackController stack1 = newStack();
87
         StackController stack1 = newStack();
88
         StackController stack2 = newStack();
88
         StackController stack2 = newStack();
89
-        stack1.push(child1);
90
-        stack2.push(child2);
89
+        stack1.push(child1, new MockPromise());
90
+        stack2.push(child2, new MockPromise());
91
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
91
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
92
         uut.setRoot(bottomTabsController);
92
         uut.setRoot(bottomTabsController);
93
 
93
 
111
         BottomTabsController bottomTabsController = newTabs();
111
         BottomTabsController bottomTabsController = newTabs();
112
         StackController stack1 = newStack();
112
         StackController stack1 = newStack();
113
         StackController stack2 = newStack();
113
         StackController stack2 = newStack();
114
-        stack1.push(child1);
115
-        stack2.push(child2);
116
-        stack2.push(child3);
117
-        stack2.push(child4);
114
+        stack1.push(child1, new MockPromise());
115
+        stack2.push(child2, new MockPromise());
116
+        stack2.push(child3, new MockPromise());
117
+        stack2.push(child4, new MockPromise());
118
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
118
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
119
         uut.setRoot(bottomTabsController);
119
         uut.setRoot(bottomTabsController);
120
 
120
 
128
         BottomTabsController bottomTabsController = newTabs();
128
         BottomTabsController bottomTabsController = newTabs();
129
         StackController stack1 = newStack();
129
         StackController stack1 = newStack();
130
         StackController stack2 = newStack();
130
         StackController stack2 = newStack();
131
-        stack1.push(child1);
132
-        stack2.push(child2);
133
-        stack2.push(child3);
134
-        stack2.push(child4);
131
+        stack1.push(child1, new MockPromise());
132
+        stack2.push(child2, new MockPromise());
133
+        stack2.push(child3, new MockPromise());
134
+        stack2.push(child4, new MockPromise());
135
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
135
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
136
         uut.setRoot(bottomTabsController);
136
         uut.setRoot(bottomTabsController);
137
 
137
 
145
         BottomTabsController bottomTabsController = newTabs();
145
         BottomTabsController bottomTabsController = newTabs();
146
         StackController stack1 = newStack();
146
         StackController stack1 = newStack();
147
         StackController stack2 = newStack();
147
         StackController stack2 = newStack();
148
-        stack1.push(child1);
149
-        stack2.push(child2);
150
-        stack2.push(child3);
151
-        stack2.push(child4);
152
-        stack2.push(child5);
148
+        stack1.push(child1, new MockPromise());
149
+        stack2.push(child2, new MockPromise());
150
+        stack2.push(child3, new MockPromise());
151
+        stack2.push(child4, new MockPromise());
152
+        stack2.push(child5, new MockPromise());
153
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
153
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
154
         uut.setRoot(bottomTabsController);
154
         uut.setRoot(bottomTabsController);
155
 
155
 
163
         BottomTabsController bottomTabsController = newTabs();
163
         BottomTabsController bottomTabsController = newTabs();
164
         StackController stack1 = newStack();
164
         StackController stack1 = newStack();
165
         StackController stack2 = newStack();
165
         StackController stack2 = newStack();
166
-        stack1.push(child1);
167
-        stack2.push(child2);
168
-        stack2.push(child3);
169
-        stack2.push(child4);
170
-        stack2.push(child5);
166
+        stack1.push(child1, new MockPromise());
167
+        stack2.push(child2, new MockPromise());
168
+        stack2.push(child3, new MockPromise());
169
+        stack2.push(child4, new MockPromise());
170
+        stack2.push(child5, new MockPromise());
171
 
171
 
172
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
172
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
173
         uut.setRoot(bottomTabsController);
173
         uut.setRoot(bottomTabsController);
218
     @Test
218
     @Test
219
     public void push_Promise() throws Exception {
219
     public void push_Promise() throws Exception {
220
         final StackController stackController = newStack();
220
         final StackController stackController = newStack();
221
-        stackController.push(child1);
221
+        stackController.push(child1, new MockPromise());
222
         uut.setRoot(stackController);
222
         uut.setRoot(stackController);
223
 
223
 
224
         assertIsChildById(uut.getView(), stackController.getView());
224
         assertIsChildById(uut.getView(), stackController.getView());
262
         BottomTabsController bottomTabsController = newTabs();
262
         BottomTabsController bottomTabsController = newTabs();
263
         StackController stack1 = newStack();
263
         StackController stack1 = newStack();
264
         final StackController stack2 = newStack();
264
         final StackController stack2 = newStack();
265
-        stack1.push(child1);
266
-        stack2.push(child2);
267
-        stack2.push(child3);
268
-        stack2.push(child4);
265
+        stack1.push(child1, new MockPromise());
266
+        stack2.push(child2, new MockPromise());
267
+        stack2.push(child3, new MockPromise());
268
+        stack2.push(child4, new MockPromise());
269
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
269
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
270
         uut.setRoot(bottomTabsController);
270
         uut.setRoot(bottomTabsController);
271
 
271
 
280
     @Test
280
     @Test
281
     public void pushIntoModal() throws Exception {
281
     public void pushIntoModal() throws Exception {
282
         StackController stackController = newStack();
282
         StackController stackController = newStack();
283
-        stackController.push(child1);
283
+        stackController.push(child1, new MockPromise());
284
         uut.showModal(stackController, new MockPromise());
284
         uut.showModal(stackController, new MockPromise());
285
         uut.push(stackController.getId(), child2);
285
         uut.push(stackController.getId(), child2);
286
         assertIsChildById(stackController.getView(), child2.getView());
286
         assertIsChildById(stackController.getView(), child2.getView());

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java 파일 보기

49
         assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
49
         assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
50
         initialNavigationOptions.topBarOptions.title = "the title";
50
         initialNavigationOptions.topBarOptions.title = "the title";
51
         StackController stackController = new StackController(activity, "stackId");
51
         StackController stackController = new StackController(activity, "stackId");
52
-        stackController.push(uut);
52
+        stackController.push(uut, new MockPromise());
53
         assertThat(uut.getTopBar().getTitle()).isEmpty();
53
         assertThat(uut.getTopBar().getTitle()).isEmpty();
54
 
54
 
55
         uut.onViewAppeared();
55
         uut.onViewAppeared();

+ 2
- 2
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ParentControllerTest.java 파일 보기

68
         StackController stackController = new StackController(activity, "stack", new TestNavigationAnimator());
68
         StackController stackController = new StackController(activity, "stack", new TestNavigationAnimator());
69
         SimpleViewController child1 = new SimpleViewController(activity, "child1");
69
         SimpleViewController child1 = new SimpleViewController(activity, "child1");
70
         SimpleViewController child2 = new SimpleViewController(activity, "child2");
70
         SimpleViewController child2 = new SimpleViewController(activity, "child2");
71
-        stackController.push(child1);
72
-        stackController.push(child2);
71
+        stackController.push(child1, new MockPromise());
72
+        stackController.push(child2, new MockPromise());
73
         children.add(stackController);
73
         children.add(stackController);
74
 
74
 
75
         assertThat(uut.findControllerById("child2")).isEqualTo(child2);
75
         assertThat(uut.findControllerById("child2")).isEqualTo(child2);

+ 49
- 54
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/StackControllerTest.java 파일 보기

38
     @Test
38
     @Test
39
     public void holdsAStackOfViewControllers() throws Exception {
39
     public void holdsAStackOfViewControllers() throws Exception {
40
         assertThat(uut.isEmpty()).isTrue();
40
         assertThat(uut.isEmpty()).isTrue();
41
-        uut.push(child1);
42
-        uut.push(child2);
43
-        uut.push(child3);
41
+        uut.push(child1, new MockPromise());
42
+        uut.push(child2, new MockPromise());
43
+        uut.push(child3, new MockPromise());
44
         assertThat(uut.peek()).isEqualTo(child3);
44
         assertThat(uut.peek()).isEqualTo(child3);
45
         assertContainsOnlyId(child1.getId(), child2.getId(), child3.getId());
45
         assertContainsOnlyId(child1.getId(), child2.getId(), child3.getId());
46
     }
46
     }
48
     @Test
48
     @Test
49
     public void push() throws Exception {
49
     public void push() throws Exception {
50
         assertThat(uut.isEmpty()).isTrue();
50
         assertThat(uut.isEmpty()).isTrue();
51
-        uut.push(child1);
51
+        uut.push(child1, new MockPromise());
52
         assertContainsOnlyId(child1.getId());
52
         assertContainsOnlyId(child1.getId());
53
     }
53
     }
54
 
54
 
55
     @Test
55
     @Test
56
     public void pop() throws Exception {
56
     public void pop() throws Exception {
57
-        uut.push(child1);
58
-        uut.push(child2);
57
+        uut.push(child1, new MockPromise());
58
+        uut.push(child2, new MockPromise());
59
         assertContainsOnlyId(child2.getId(), child1.getId());
59
         assertContainsOnlyId(child2.getId(), child1.getId());
60
-        uut.pop();
60
+        uut.pop(new MockPromise());
61
         assertContainsOnlyId(child1.getId());
61
         assertContainsOnlyId(child1.getId());
62
     }
62
     }
63
 
63
 
66
         assertThat(uut.peek()).isNull();
66
         assertThat(uut.peek()).isNull();
67
         assertThat(uut.size()).isZero();
67
         assertThat(uut.size()).isZero();
68
         assertThat(uut.isEmpty()).isTrue();
68
         assertThat(uut.isEmpty()).isTrue();
69
-        uut.push(child1);
69
+        uut.push(child1, new MockPromise());
70
         assertThat(uut.peek()).isEqualTo(child1);
70
         assertThat(uut.peek()).isEqualTo(child1);
71
         assertThat(uut.size()).isEqualTo(1);
71
         assertThat(uut.size()).isEqualTo(1);
72
         assertThat(uut.isEmpty()).isFalse();
72
         assertThat(uut.isEmpty()).isFalse();
75
     @Test
75
     @Test
76
     public void pushAssignsRefToSelfOnPushedController() throws Exception {
76
     public void pushAssignsRefToSelfOnPushedController() throws Exception {
77
         assertThat(child1.getParentStackController()).isNull();
77
         assertThat(child1.getParentStackController()).isNull();
78
-        uut.push(child1);
78
+        uut.push(child1, new MockPromise());
79
         assertThat(child1.getParentStackController()).isEqualTo(uut);
79
         assertThat(child1.getParentStackController()).isEqualTo(uut);
80
 
80
 
81
         StackController anotherNavController = new StackController(activity, "another", new TestNavigationAnimator());
81
         StackController anotherNavController = new StackController(activity, "another", new TestNavigationAnimator());
82
-        anotherNavController.push(child2);
82
+        anotherNavController.push(child2, new MockPromise());
83
         assertThat(child2.getParentStackController()).isEqualTo(anotherNavController);
83
         assertThat(child2.getParentStackController()).isEqualTo(anotherNavController);
84
     }
84
     }
85
 
85
 
88
         assertThat(uut.isEmpty()).isTrue();
88
         assertThat(uut.isEmpty()).isTrue();
89
         assertThat(uut.handleBack()).isFalse();
89
         assertThat(uut.handleBack()).isFalse();
90
 
90
 
91
-        uut.push(child1);
91
+        uut.push(child1, new MockPromise());
92
         assertThat(uut.size()).isEqualTo(1);
92
         assertThat(uut.size()).isEqualTo(1);
93
         assertThat(uut.handleBack()).isFalse();
93
         assertThat(uut.handleBack()).isFalse();
94
 
94
 
95
-        uut.push(child2);
95
+        uut.push(child2, new MockPromise());
96
         assertThat(uut.size()).isEqualTo(2);
96
         assertThat(uut.size()).isEqualTo(2);
97
         assertThat(uut.handleBack()).isTrue();
97
         assertThat(uut.handleBack()).isTrue();
98
         assertThat(uut.size()).isEqualTo(1);
98
         assertThat(uut.size()).isEqualTo(1);
102
     @Test
102
     @Test
103
     public void popDoesNothingWhenZeroOrOneChild() throws Exception {
103
     public void popDoesNothingWhenZeroOrOneChild() throws Exception {
104
         assertThat(uut.isEmpty()).isTrue();
104
         assertThat(uut.isEmpty()).isTrue();
105
-        uut.pop();
105
+        uut.pop(new MockPromise());
106
         assertThat(uut.isEmpty()).isTrue();
106
         assertThat(uut.isEmpty()).isTrue();
107
 
107
 
108
-        uut.push(child1);
109
-        uut.pop();
108
+        uut.push(child1, new MockPromise());
109
+        uut.pop(new MockPromise());
110
         assertContainsOnlyId(child1.getId());
110
         assertContainsOnlyId(child1.getId());
111
     }
111
     }
112
 
112
 
114
     public void canPopWhenSizeIsMoreThanOne() throws Exception {
114
     public void canPopWhenSizeIsMoreThanOne() throws Exception {
115
         assertThat(uut.isEmpty()).isTrue();
115
         assertThat(uut.isEmpty()).isTrue();
116
         assertThat(uut.canPop()).isFalse();
116
         assertThat(uut.canPop()).isFalse();
117
-        uut.push(child1);
117
+        uut.push(child1, new MockPromise());
118
         assertContainsOnlyId(child1.getId());
118
         assertContainsOnlyId(child1.getId());
119
         assertThat(uut.canPop()).isFalse();
119
         assertThat(uut.canPop()).isFalse();
120
-        uut.push(child2);
120
+        uut.push(child2, new MockPromise());
121
         assertContainsOnlyId(child1.getId(), child2.getId());
121
         assertContainsOnlyId(child1.getId(), child2.getId());
122
         assertThat(uut.canPop()).isTrue();
122
         assertThat(uut.canPop()).isTrue();
123
     }
123
     }
125
     @Test
125
     @Test
126
     public void pushAddsToViewTree() throws Exception {
126
     public void pushAddsToViewTree() throws Exception {
127
         assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
127
         assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
128
-        uut.push(child1);
128
+        uut.push(child1, new MockPromise());
129
         assertThat(uut.getView().findViewById(child1.getView().getId())).isNotNull();
129
         assertThat(uut.getView().findViewById(child1.getView().getId())).isNotNull();
130
     }
130
     }
131
 
131
 
132
     @Test
132
     @Test
133
     public void pushRemovesPreviousFromTree() throws Exception {
133
     public void pushRemovesPreviousFromTree() throws Exception {
134
         assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
134
         assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
135
-        uut.push(child1);
135
+        uut.push(child1, new MockPromise());
136
         assertThat(uut.getView().findViewById(child1.getView().getId())).isNotNull();
136
         assertThat(uut.getView().findViewById(child1.getView().getId())).isNotNull();
137
-        uut.push(child2);
137
+        uut.push(child2, new MockPromise());
138
         assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
138
         assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
139
         assertThat(uut.getView().findViewById(child2.getView().getId())).isNotNull();
139
         assertThat(uut.getView().findViewById(child2.getView().getId())).isNotNull();
140
     }
140
     }
141
 
141
 
142
     @Test
142
     @Test
143
     public void popReplacesViewWithPrevious() throws Exception {
143
     public void popReplacesViewWithPrevious() throws Exception {
144
-        uut.push(child1);
145
-        uut.push(child2);
144
+        uut.push(child1, new MockPromise());
145
+        uut.push(child2, new MockPromise());
146
         final View child2View = child2.getView();
146
         final View child2View = child2.getView();
147
         final View child1View = child1.getView();
147
         final View child1View = child1.getView();
148
         assertIsChildById(uut.getView(), child2View);
148
         assertIsChildById(uut.getView(), child2View);
149
         assertNotChildOf(uut.getView(), child1View);
149
         assertNotChildOf(uut.getView(), child1View);
150
-        uut.pop();
150
+        uut.pop(new MockPromise());
151
         assertNotChildOf(uut.getView(), child2View);
151
         assertNotChildOf(uut.getView(), child2View);
152
         assertIsChildById(uut.getView(), child1View);
152
         assertIsChildById(uut.getView(), child1View);
153
     }
153
     }
154
 
154
 
155
     @Test
155
     @Test
156
     public void popSpecificWhenTopIsRegularPop() throws Exception {
156
     public void popSpecificWhenTopIsRegularPop() throws Exception {
157
-        uut.push(child1);
158
-        uut.push(child2);
157
+        uut.push(child1, new MockPromise());
158
+        uut.push(child2, new MockPromise());
159
         uut.popSpecific(child2);
159
         uut.popSpecific(child2);
160
         assertContainsOnlyId(child1.getId());
160
         assertContainsOnlyId(child1.getId());
161
         assertIsChildById(uut.getView(), child1.getView());
161
         assertIsChildById(uut.getView(), child1.getView());
163
 
163
 
164
     @Test
164
     @Test
165
     public void popSpecificDeepInStack() throws Exception {
165
     public void popSpecificDeepInStack() throws Exception {
166
-        uut.push(child1);
167
-        uut.push(child2);
166
+        uut.push(child1, new MockPromise());
167
+        uut.push(child2, new MockPromise());
168
         assertIsChildById(uut.getView(), child2.getView());
168
         assertIsChildById(uut.getView(), child2.getView());
169
         uut.popSpecific(child1);
169
         uut.popSpecific(child1);
170
         assertContainsOnlyId(child2.getId());
170
         assertContainsOnlyId(child2.getId());
173
 
173
 
174
     @Test
174
     @Test
175
     public void popTo_PopsTopUntilControllerIsNewTop() throws Exception {
175
     public void popTo_PopsTopUntilControllerIsNewTop() throws Exception {
176
-        uut.push(child1);
177
-        uut.push(child2);
178
-        uut.push(child3);
176
+        uut.push(child1, new MockPromise());
177
+        uut.push(child2, new MockPromise());
178
+        uut.push(child3, new MockPromise());
179
 
179
 
180
         assertThat(uut.size()).isEqualTo(3);
180
         assertThat(uut.size()).isEqualTo(3);
181
         assertThat(uut.peek()).isEqualTo(child3);
181
         assertThat(uut.peek()).isEqualTo(child3);
188
 
188
 
189
     @Test
189
     @Test
190
     public void popTo_NotAChildOfThisStack_DoesNothing() throws Exception {
190
     public void popTo_NotAChildOfThisStack_DoesNothing() throws Exception {
191
-        uut.push(child1);
192
-        uut.push(child3);
191
+        uut.push(child1, new MockPromise());
192
+        uut.push(child3, new MockPromise());
193
         assertThat(uut.size()).isEqualTo(2);
193
         assertThat(uut.size()).isEqualTo(2);
194
         uut.popTo(child2);
194
         uut.popTo(child2);
195
         assertThat(uut.size()).isEqualTo(2);
195
         assertThat(uut.size()).isEqualTo(2);
197
 
197
 
198
     @Test
198
     @Test
199
     public void popToRoot_PopsEverythingAboveFirstController() throws Exception {
199
     public void popToRoot_PopsEverythingAboveFirstController() throws Exception {
200
-        uut.push(child1);
201
-        uut.push(child2);
202
-        uut.push(child3);
200
+        uut.push(child1, new MockPromise());
201
+        uut.push(child2, new MockPromise());
202
+        uut.push(child3, new MockPromise());
203
 
203
 
204
         assertThat(uut.size()).isEqualTo(3);
204
         assertThat(uut.size()).isEqualTo(3);
205
         assertThat(uut.peek()).isEqualTo(child3);
205
         assertThat(uut.peek()).isEqualTo(child3);
221
     public void findControllerById_ReturnsSelfOrChildrenById() throws Exception {
221
     public void findControllerById_ReturnsSelfOrChildrenById() throws Exception {
222
         assertThat(uut.findControllerById("123")).isNull();
222
         assertThat(uut.findControllerById("123")).isNull();
223
         assertThat(uut.findControllerById(uut.getId())).isEqualTo(uut);
223
         assertThat(uut.findControllerById(uut.getId())).isEqualTo(uut);
224
-        uut.push(child1);
224
+        uut.push(child1, new MockPromise());
225
         assertThat(uut.findControllerById(child1.getId())).isEqualTo(child1);
225
         assertThat(uut.findControllerById(child1.getId())).isEqualTo(child1);
226
     }
226
     }
227
 
227
 
228
     @Test
228
     @Test
229
     public void findControllerById_Deeply() throws Exception {
229
     public void findControllerById_Deeply() throws Exception {
230
         StackController stack = new StackController(activity, "stack2", new TestNavigationAnimator());
230
         StackController stack = new StackController(activity, "stack2", new TestNavigationAnimator());
231
-        stack.push(child2);
232
-        uut.push(stack);
231
+        stack.push(child2, new MockPromise());
232
+        uut.push(stack, new MockPromise());
233
         assertThat(uut.findControllerById(child2.getId())).isEqualTo(child2);
233
         assertThat(uut.findControllerById(child2.getId())).isEqualTo(child2);
234
     }
234
     }
235
 
235
 
238
         child1 = spy(child1);
238
         child1 = spy(child1);
239
         child2 = spy(child2);
239
         child2 = spy(child2);
240
         child3 = spy(child3);
240
         child3 = spy(child3);
241
-        uut.push(child1);
242
-        uut.push(child2);
243
-        uut.push(child3);
241
+        uut.push(child1, new MockPromise());
242
+        uut.push(child2, new MockPromise());
243
+        uut.push(child3, new MockPromise());
244
 
244
 
245
         verify(child3, times(0)).destroy();
245
         verify(child3, times(0)).destroy();
246
-        uut.pop();
246
+        uut.pop(new MockPromise());
247
         verify(child3, times(1)).destroy();
247
         verify(child3, times(1)).destroy();
248
     }
248
     }
249
 
249
 
252
         child1 = spy(child1);
252
         child1 = spy(child1);
253
         child2 = spy(child2);
253
         child2 = spy(child2);
254
         child3 = spy(child3);
254
         child3 = spy(child3);
255
-        uut.push(child1);
256
-        uut.push(child2);
257
-        uut.push(child3);
255
+        uut.push(child1, new MockPromise());
256
+        uut.push(child2, new MockPromise());
257
+        uut.push(child3, new MockPromise());
258
 
258
 
259
         verify(child2, times(0)).destroy();
259
         verify(child2, times(0)).destroy();
260
         uut.popSpecific(child2);
260
         uut.popSpecific(child2);
266
         child1 = spy(child1);
266
         child1 = spy(child1);
267
         child2 = spy(child2);
267
         child2 = spy(child2);
268
         child3 = spy(child3);
268
         child3 = spy(child3);
269
-        uut.push(child1);
270
-        uut.push(child2);
271
-        uut.push(child3);
269
+        uut.push(child1, new MockPromise());
270
+        uut.push(child2, new MockPromise());
271
+        uut.push(child3, new MockPromise());
272
 
272
 
273
         verify(child2, times(0)).destroy();
273
         verify(child2, times(0)).destroy();
274
         verify(child3, times(0)).destroy();
274
         verify(child3, times(0)).destroy();
279
 
279
 
280
     private void assertContainsOnlyId(String... ids) {
280
     private void assertContainsOnlyId(String... ids) {
281
         assertThat(uut.size()).isEqualTo(ids.length);
281
         assertThat(uut.size()).isEqualTo(ids.length);
282
-        assertThat(uut.getChildControllers()).extracting(new Extractor<ViewController, String>() {
283
-            @Override
284
-            public String extract(final ViewController input) {
285
-                return input.getId();
286
-            }
287
-        }).containsOnly(ids);
282
+        assertThat(uut.getChildControllers()).extracting((Extractor<ViewController, String>) ViewController::getId).containsOnly(ids);
288
     }
283
     }
289
 }
284
 }

+ 2
- 1
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ViewControllerTest.java 파일 보기

6
 import android.widget.LinearLayout;
6
 import android.widget.LinearLayout;
7
 
7
 
8
 import com.reactnativenavigation.BaseTest;
8
 import com.reactnativenavigation.BaseTest;
9
+import com.reactnativenavigation.mocks.MockPromise;
9
 import com.reactnativenavigation.mocks.SimpleViewController;
10
 import com.reactnativenavigation.mocks.SimpleViewController;
10
 
11
 
11
 import org.assertj.android.api.Assertions;
12
 import org.assertj.android.api.Assertions;
58
     public void holdsAReferenceToStackControllerOrNull() throws Exception {
59
     public void holdsAReferenceToStackControllerOrNull() throws Exception {
59
         assertThat(uut.getParentStackController()).isNull();
60
         assertThat(uut.getParentStackController()).isNull();
60
         StackController nav = new StackController(activity, "stack");
61
         StackController nav = new StackController(activity, "stack");
61
-        nav.push(uut);
62
+        nav.push(uut, new MockPromise());
62
         assertThat(uut.getParentStackController()).isEqualTo(nav);
63
         assertThat(uut.getParentStackController()).isEqualTo(nav);
63
     }
64
     }
64
 
65