|
@@ -38,6 +38,7 @@ import org.assertj.core.api.iterable.Extractor;
|
38
|
38
|
import org.json.JSONObject;
|
39
|
39
|
import org.junit.Test;
|
40
|
40
|
import org.mockito.ArgumentCaptor;
|
|
41
|
+import org.mockito.InOrder;
|
41
|
42
|
import org.mockito.Mockito;
|
42
|
43
|
|
43
|
44
|
import java.util.ArrayList;
|
|
@@ -48,6 +49,7 @@ import java.util.List;
|
48
|
49
|
import static org.assertj.core.api.Java6Assertions.assertThat;
|
49
|
50
|
import static org.mockito.ArgumentMatchers.any;
|
50
|
51
|
import static org.mockito.ArgumentMatchers.eq;
|
|
52
|
+import static org.mockito.Mockito.inOrder;
|
51
|
53
|
import static org.mockito.Mockito.mock;
|
52
|
54
|
import static org.mockito.Mockito.spy;
|
53
|
55
|
import static org.mockito.Mockito.times;
|
|
@@ -65,11 +67,13 @@ public class StackControllerTest extends BaseTest {
|
65
|
67
|
private NavigationAnimator animator;
|
66
|
68
|
private TopBarController topBarController;
|
67
|
69
|
private StackOptionsPresenter presenter;
|
|
70
|
+ private BackButtonHelper backButtonHelper;
|
68
|
71
|
|
69
|
72
|
@Override
|
70
|
73
|
public void beforeEach() {
|
71
|
74
|
super.beforeEach();
|
72
|
75
|
animator = Mockito.mock(NavigationAnimator.class);
|
|
76
|
+ backButtonHelper = spy(new BackButtonHelper());
|
73
|
77
|
activity = newActivity();
|
74
|
78
|
childRegistry = new ChildControllersRegistry();
|
75
|
79
|
presenter = spy(new StackOptionsPresenter(activity, new TitleBarReactViewCreatorMock(), new Options()));
|
|
@@ -121,18 +125,6 @@ public class StackControllerTest extends BaseTest {
|
121
|
125
|
verify(listener, times(1)).onSuccess(child1.getId());
|
122
|
126
|
}
|
123
|
127
|
|
124
|
|
- @Test
|
125
|
|
- public void push_backButtonIsAddedIfStackContainsMoreThenOneScreen() {
|
126
|
|
- uut.push(child1, new CommandListenerAdapter());
|
127
|
|
- verify(child1, times(0)).mergeOptions(any());
|
128
|
|
- assertThat(child1.options.topBar.buttons.back.visible.isFalseOrUndefined()).isTrue();
|
129
|
|
-
|
130
|
|
- uut.push(child2, new CommandListenerAdapter());
|
131
|
|
- ArgumentCaptor<Options> captor = ArgumentCaptor.forClass(Options.class);
|
132
|
|
- verify(child2, times(1)).mergeOptions(captor.capture());
|
133
|
|
- assertThat(captor.getValue().topBar.buttons.back.visible.get()).isTrue();
|
134
|
|
- }
|
135
|
|
-
|
136
|
128
|
@Test
|
137
|
129
|
public void push_backButtonIsNotAddedIfScreenContainsLeftButton() {
|
138
|
130
|
disablePushAnimation(child1, child2);
|
|
@@ -157,6 +149,18 @@ public class StackControllerTest extends BaseTest {
|
157
|
149
|
verify(child1, times(0)).mergeOptions(any());
|
158
|
150
|
}
|
159
|
151
|
|
|
152
|
+ @Test
|
|
153
|
+ public void push_backButtonAddedBeforeChildViewIsCreated() {
|
|
154
|
+ disablePopAnimation(child1, child2);
|
|
155
|
+ uut.push(child1, new CommandListenerAdapter());
|
|
156
|
+ uut.push(child2, new CommandListenerAdapter());
|
|
157
|
+
|
|
158
|
+ InOrder inOrder = inOrder(backButtonHelper, child2);
|
|
159
|
+ inOrder.verify(backButtonHelper).addToPushedChild(child2);
|
|
160
|
+ inOrder.verify(child2).setParentController(uut);
|
|
161
|
+ inOrder.verify(child2).getView(); // creates view
|
|
162
|
+ }
|
|
163
|
+
|
160
|
164
|
@Test
|
161
|
165
|
public void push_waitForRender() {
|
162
|
166
|
disablePushAnimation(child1);
|
|
@@ -845,6 +849,7 @@ public class StackControllerTest extends BaseTest {
|
845
|
849
|
.setChildRegistry(childRegistry)
|
846
|
850
|
.setAnimator(animator)
|
847
|
851
|
.setStackPresenter(presenter)
|
|
852
|
+ .setBackButtonHelper(backButtonHelper)
|
848
|
853
|
.build();
|
849
|
854
|
}
|
850
|
855
|
|