use of com.reactnativenavigation.mocks.TestReactView in project react-native-navigation by wix.
the class OptionsApplyingTest method beforeEach.
@Override
public void beforeEach() {
super.beforeEach();
activity = newActivity();
initialNavigationOptions = new Options();
view = spy(new TestComponentLayout(activity, new TestReactView(activity)));
view.asView().setLayoutParams(new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
uut = new ComponentViewController(activity, new ChildControllersRegistry(), "componentId1", "componentName", (activity1, componentId, componentName) -> view, initialNavigationOptions, new Presenter(activity, new Options()), new ComponentPresenter(Options.EMPTY)) {
@Override
public boolean isViewShown() {
return true;
}
};
TopBarController topBarController = new TopBarController() {
@Override
protected TopBar createTopBar(Context context, StackLayout stackLayout) {
topBar = spy(super.createTopBar(context, stackLayout));
return topBar;
}
};
stack = TestUtils.newStackController(activity).setTopBarController(topBarController).build();
stack.ensureViewIsCreated();
stack.getView().layout(0, 0, 1000, 1000);
stack.getTopBar().layout(0, 0, 1000, 100);
activity.setContentView(stack.getView());
disablePushAnimation(uut);
}
use of com.reactnativenavigation.mocks.TestReactView in project react-native-navigation by wix.
the class ComponentViewControllerTest method beforeEach.
@Override
public void beforeEach() {
super.beforeEach();
activity = newActivity();
SystemUiUtils.saveStatusBarHeight(63);
view = Mockito.spy(new TestComponentLayout(activity, new TestReactView(activity)));
parent = TestUtils.newStackController(activity).build();
Presenter presenter = new Presenter(activity, new Options());
this.presenter = Mockito.spy(new ComponentPresenter(Options.EMPTY));
uut = Mockito.spy(new ComponentViewController(activity, new ChildControllersRegistry(), "componentId1", "componentName", (activity1, componentId, componentName) -> view, new Options(), presenter, this.presenter) {
@Override
public Options resolveCurrentOptions(Options defaultOptions) {
// Hacky way to return the same instance of resolvedOptions without copying it.
return resolvedOptions.withDefaultOptions(uut.options).withDefaultOptions(defaultOptions);
}
});
uut.setParentController(parent);
parent.ensureViewIsCreated();
}
use of com.reactnativenavigation.mocks.TestReactView in project react-native-navigation by wix.
the class TopTabsViewControllerTest method lifecycleMethodsSentWhenSelectedTabChanges.
@Test
@Ignore("TopTabs not yet well supported")
public void lifecycleMethodsSentWhenSelectedTabChanges() {
stack.ensureViewIsCreated();
uut.ensureViewIsCreated();
tabControllers.get(0).ensureViewIsCreated();
tabControllers.get(1).ensureViewIsCreated();
TestReactView initialTab = getActualTabView(0);
TestReactView selectedTab = getActualTabView(1);
uut.switchToTab(1);
verify(initialTab, times(1)).sendComponentStop(ComponentType.Component);
verify(selectedTab, times(1)).sendComponentWillStart(ComponentType.Component);
verify(selectedTab, times(1)).sendComponentStart(ComponentType.Component);
verify(selectedTab, times(0)).sendComponentStop(ComponentType.Component);
}
Aggregations