use of com.reactnativenavigation.mocks.SimpleViewController in project react-native-navigation by wix.
the class ViewControllerTest method onDestroy_destroysViewEvenIfHidden.
@Test
public void onDestroy_destroysViewEvenIfHidden() {
final SimpleViewController.SimpleView[] spy = new SimpleViewController.SimpleView[1];
ViewController uut = new SimpleViewController(activity, childRegistry, "uut", new Options()) {
@Override
public SimpleView createView() {
SimpleView view = spy(super.createView());
spy[0] = view;
return view;
}
};
assertThat(uut.isViewShown()).isFalse();
uut.destroy();
verify(spy[0], times(1)).destroy();
}
use of com.reactnativenavigation.mocks.SimpleViewController in project react-native-navigation by wix.
the class FloatingActionButtonTest method beforeEach.
@Override
public void beforeEach() {
super.beforeEach();
activity = newActivity();
childRegistry = new ChildControllersRegistry();
stackController = TestUtils.newStackController(activity).setFabPresenter(createFabPresenter()).build();
stackController.ensureViewIsCreated();
Options options = getOptionsWithFab();
childFab = new SimpleViewController(activity, childRegistry, "child1", options);
childNoFab = new SimpleViewController(activity, childRegistry, "child2", new Options());
}
use of com.reactnativenavigation.mocks.SimpleViewController in project react-native-navigation by wix.
the class BottomTabPresenterTest method createBottomTabs.
private void createBottomTabs(Options tab1Options, Options tab2Options, Options tab3Options) {
childRegistry = new ChildControllersRegistry();
bottomTabs = Mockito.mock(BottomTabs.class);
child1 = spy(new SimpleViewController(activity, childRegistry, "child1", tab1Options));
child2 = spy(new SimpleViewController(activity, childRegistry, "child2", tab2Options));
child3 = spy(new SimpleViewController(activity, childRegistry, "child2", tab3Options));
tabs = Arrays.asList(child1, child2, child3);
uut = new BottomTabPresenter(activity, tabs, ImageLoaderMock.mock(), new TypefaceLoaderMock(), new Options());
uut.bindView(bottomTabs);
uut.setDefaultOptions(new Options());
}
use of com.reactnativenavigation.mocks.SimpleViewController in project react-native-navigation by wix.
the class ParentControllerTest method mergeOptions_optionsAreMergedWhenChildAppears.
@Test
public void mergeOptions_optionsAreMergedWhenChildAppears() {
Options options = new Options();
options.topBar.title.text = new Text("new title");
ViewController<?> child1 = spy(new SimpleViewController(activity, childRegistry, "child1", options));
children.add(child1);
uut.ensureViewIsCreated();
child1.ensureViewIsCreated();
child1.onViewWillAppear();
ArgumentCaptor<Options> optionsCaptor = ArgumentCaptor.forClass(Options.class);
verify(uut, times(1)).clearOptions();
verify(uut, times(1)).applyChildOptions(optionsCaptor.capture(), eq(child1));
assertThat(optionsCaptor.getValue().topBar.title.text.get()).isEqualTo("new title");
}
use of com.reactnativenavigation.mocks.SimpleViewController in project react-native-navigation by wix.
the class ParentControllerTest method destroy_DestroysChildren.
@Test
public void destroy_DestroysChildren() {
ViewController<?> child1 = spy(new SimpleViewController(activity, childRegistry, "child1", new Options()));
children.add(child1);
verify(child1, times(0)).destroy();
uut.destroy();
verify(child1, times(1)).destroy();
}
Aggregations