|
@@ -12,6 +12,7 @@ import com.reactnativenavigation.parse.TitleOptions;
|
12
|
12
|
import com.reactnativenavigation.parse.params.Button;
|
13
|
13
|
import com.reactnativenavigation.parse.params.Text;
|
14
|
14
|
import com.reactnativenavigation.react.ReactView;
|
|
15
|
+import com.reactnativenavigation.utils.ViewUtils;
|
15
|
16
|
import com.reactnativenavigation.views.titlebar.TitleBar;
|
16
|
17
|
import com.reactnativenavigation.views.titlebar.TitleBarReactView;
|
17
|
18
|
|
|
@@ -38,16 +39,15 @@ public class TitleBarTest extends BaseTest {
|
38
|
39
|
private Button textButton;
|
39
|
40
|
private Button customButton;
|
40
|
41
|
private Map<String, TopBarButtonController> buttonControllers;
|
41
|
|
- private TitleBarReactViewController reactViewController;
|
42
|
42
|
|
43
|
43
|
@Override
|
44
|
44
|
public void beforeEach() {
|
45
|
45
|
final TopBarButtonCreatorMock buttonCreator = new TopBarButtonCreatorMock();
|
46
|
46
|
final Activity activity = newActivity();
|
47
|
|
- reactViewController = spy(new TitleBarReactViewController(activity, new TitleBarReactViewCreatorMock()));
|
48
|
47
|
createButtons();
|
49
|
48
|
buttonControllers = new HashMap<>();
|
50
|
|
- uut = spy(new TitleBar(activity, buttonCreator, reactViewController, (buttonId -> {})) {
|
|
49
|
+ TitleBarReactViewCreatorMock reactViewCreator = new TitleBarReactViewCreatorMock();
|
|
50
|
+ uut = spy(new TitleBar(activity, buttonCreator, reactViewCreator, (buttonId -> {})) {
|
51
|
51
|
@Override
|
52
|
52
|
public TopBarButtonController createButtonController(Button button) {
|
53
|
53
|
TopBarButtonController controller = spy(super.createButtonController(button));
|
|
@@ -169,11 +169,12 @@ public class TitleBarTest extends BaseTest {
|
169
|
169
|
|
170
|
170
|
@Test
|
171
|
171
|
public void clear() throws Exception {
|
|
172
|
+ uut.setComponent("someComponent", TitleOptions.Alignment.Center);
|
172
|
173
|
uut.clear();
|
173
|
174
|
assertThat(uut.getTitle()).isNullOrEmpty();
|
174
|
175
|
assertThat(uut.getMenu().size()).isZero();
|
175
|
176
|
assertThat(uut.getNavigationIcon()).isNull();
|
176
|
|
- verify(reactViewController, times(1)).destroy();
|
|
177
|
+ assertThat(ViewUtils.findChildrenByClassRecursive(uut, TitleBarReactView.class).size()).isZero();
|
177
|
178
|
}
|
178
|
179
|
|
179
|
180
|
private List<Button> leftButton(Button leftButton) {
|