|
@@ -84,9 +84,10 @@ public class StackPresenterTest extends BaseTest {
|
84
|
84
|
private Button textBtn2 = TitleBarHelper.textualButton("btn2");
|
85
|
85
|
private Button componentBtn1 = TitleBarHelper.reactViewButton("btn1_");
|
86
|
86
|
private Button componentBtn2 = TitleBarHelper.reactViewButton("btn2_");
|
|
87
|
+ private Component titleComponent1 = TitleBarHelper.titleComponent("component1");
|
|
88
|
+ private Component titleComponent2 = TitleBarHelper.titleComponent("component2");
|
87
|
89
|
private TopBarController topBarController;
|
88
|
90
|
private ChildControllersRegistry childRegistry;
|
89
|
|
- private IconResolver iconResolver;
|
90
|
91
|
|
91
|
92
|
@Override
|
92
|
93
|
public void beforeEach() {
|
|
@@ -98,7 +99,7 @@ public class StackPresenterTest extends BaseTest {
|
98
|
99
|
}
|
99
|
100
|
};
|
100
|
101
|
renderChecker = spy(new RenderChecker());
|
101
|
|
- iconResolver = new IconResolver(activity, ImageLoaderMock.mock());
|
|
102
|
+ IconResolver iconResolver = new IconResolver(activity, ImageLoaderMock.mock());
|
102
|
103
|
uut = spy(new StackPresenter(activity, titleViewCreator, new TopBarBackgroundViewCreatorMock(), new TopBarButtonCreatorMock(), iconResolver, renderChecker, new Options()));
|
103
|
104
|
createTopBarController();
|
104
|
105
|
|
|
@@ -309,6 +310,59 @@ public class StackPresenterTest extends BaseTest {
|
309
|
310
|
uut.mergeChildOptions(options, EMPTY_OPTIONS, parent, child);
|
310
|
311
|
}
|
311
|
312
|
|
|
313
|
+ @Test
|
|
314
|
+ public void applyTopBarOptions_setTitleComponent() {
|
|
315
|
+ Options applyComponent = new Options();
|
|
316
|
+ applyComponent.topBar.title.component.name = new Text("Component1");
|
|
317
|
+ applyComponent.topBar.title.component.componentId = new Text("Component1id");
|
|
318
|
+ uut.applyChildOptions(applyComponent, parent, child);
|
|
319
|
+ verify(topBarController).setTitleComponent(any());
|
|
320
|
+ }
|
|
321
|
+
|
|
322
|
+ @Test
|
|
323
|
+ public void mergeTopBarOptions_settingTitleDestroysComponent() {
|
|
324
|
+ Options componentOptions = new Options();
|
|
325
|
+ componentOptions.topBar.title.component = titleComponent1;
|
|
326
|
+ uut.applyChildOptions(componentOptions, parent, child);
|
|
327
|
+ ArgumentCaptor<TitleBarReactViewController> applyCaptor = ArgumentCaptor.forClass(TitleBarReactViewController.class);
|
|
328
|
+ verify(topBarController).setTitleComponent(applyCaptor.capture());
|
|
329
|
+
|
|
330
|
+ Options titleOptions = new Options();
|
|
331
|
+ titleOptions.topBar.title.text = new Text("Some title");
|
|
332
|
+ uut.mergeChildOptions(titleOptions, Options.EMPTY, parent, child);
|
|
333
|
+ assertThat(applyCaptor.getValue().isDestroyed()).isTrue();
|
|
334
|
+ }
|
|
335
|
+
|
|
336
|
+ @Test
|
|
337
|
+ public void mergeTopBarOptions_doesNotRecreateTitleComponentIfEquals() {
|
|
338
|
+ Options options = new Options();
|
|
339
|
+ options.topBar.title.component = titleComponent1;
|
|
340
|
+ uut.applyChildOptions(options, parent, child);
|
|
341
|
+ ArgumentCaptor<TitleBarReactViewController> applyCaptor = ArgumentCaptor.forClass(TitleBarReactViewController.class);
|
|
342
|
+ verify(topBarController).setTitleComponent(applyCaptor.capture());
|
|
343
|
+
|
|
344
|
+ uut.mergeChildOptions(options, Options.EMPTY, parent, child);
|
|
345
|
+ verify(topBarController, times(2)).setTitleComponent(applyCaptor.getValue());
|
|
346
|
+ }
|
|
347
|
+
|
|
348
|
+ @Test
|
|
349
|
+ public void mergeTopBarOptions_previousTitleComponentIsDestroyed() {
|
|
350
|
+ Options options = new Options();
|
|
351
|
+ options.topBar.title.component = titleComponent1;
|
|
352
|
+ uut.applyChildOptions(options, parent, child);
|
|
353
|
+ ArgumentCaptor<TitleBarReactViewController> applyCaptor = ArgumentCaptor.forClass(TitleBarReactViewController.class);
|
|
354
|
+ verify(topBarController).setTitleComponent(applyCaptor.capture());
|
|
355
|
+
|
|
356
|
+ Options toMerge = new Options();
|
|
357
|
+ toMerge.topBar.title.component = titleComponent2;
|
|
358
|
+ uut.mergeChildOptions(toMerge, Options.EMPTY, parent, child);
|
|
359
|
+ ArgumentCaptor<TitleBarReactViewController> mergeCaptor = ArgumentCaptor.forClass(TitleBarReactViewController.class);
|
|
360
|
+ verify(topBarController, times(2)).setTitleComponent(mergeCaptor.capture());
|
|
361
|
+
|
|
362
|
+ assertThat(applyCaptor.getValue()).isNotEqualTo(mergeCaptor.getValue());
|
|
363
|
+ assertThat(applyCaptor.getValue().isDestroyed()).isTrue();
|
|
364
|
+ }
|
|
365
|
+
|
312
|
366
|
@Test
|
313
|
367
|
public void mergeTopTabsOptions() {
|
314
|
368
|
Options options = new Options();
|