|
@@ -21,6 +21,7 @@ import static org.mockito.ArgumentMatchers.any;
|
21
|
21
|
import static org.mockito.Mockito.spy;
|
22
|
22
|
import static org.mockito.Mockito.times;
|
23
|
23
|
import static org.mockito.Mockito.verify;
|
|
24
|
+import static org.mockito.Mockito.verifyZeroInteractions;
|
24
|
25
|
import static org.mockito.Mockito.when;
|
25
|
26
|
|
26
|
27
|
public class ComponentViewControllerTest extends BaseTest {
|
|
@@ -40,12 +41,12 @@ public class ComponentViewControllerTest extends BaseTest {
|
40
|
41
|
parent = TestUtils.newStackController(activity).build();
|
41
|
42
|
Presenter presenter = new Presenter(activity, new Options());
|
42
|
43
|
this.presenter = spy(new ComponentPresenter(Options.EMPTY));
|
43
|
|
- uut = new ComponentViewController(activity, new ChildControllersRegistry(), "componentId1", "componentName", (activity1, componentId, componentName) -> view, new Options(), presenter, this.presenter) {
|
|
44
|
+ uut = spy(new ComponentViewController(activity, new ChildControllersRegistry(), "componentId1", "componentName", (activity1, componentId, componentName) -> view, new Options(), presenter, this.presenter) {
|
44
|
45
|
@Override
|
45
|
46
|
public Options resolveCurrentOptions(Options defaultOptions) {
|
46
|
47
|
return resolvedOptions;
|
47
|
48
|
}
|
48
|
|
- };
|
|
49
|
+ });
|
49
|
50
|
uut.setParentController(parent);
|
50
|
51
|
parent.ensureViewIsCreated();
|
51
|
52
|
}
|
|
@@ -117,8 +118,13 @@ public class ComponentViewControllerTest extends BaseTest {
|
117
|
118
|
}
|
118
|
119
|
|
119
|
120
|
@Test
|
120
|
|
- public void mergeOptions_delegatesToPresenter() {
|
|
121
|
+ public void mergeOptions_delegatesToPresenterIfViewIsNotShown() {
|
121
|
122
|
Options options = new Options();
|
|
123
|
+ assertThat(uut.isViewShown()).isFalse();
|
|
124
|
+ uut.mergeOptions(options);
|
|
125
|
+ verifyZeroInteractions(presenter);
|
|
126
|
+
|
|
127
|
+ when(uut.isViewShown()).thenReturn(true);
|
122
|
128
|
uut.mergeOptions(options);
|
123
|
129
|
verify(presenter).mergeOptions(uut.getView(), options);
|
124
|
130
|
}
|