Search in sources :

Example 1 with Presenter

use of com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter 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);
}
Also used : StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) TopBar(com.reactnativenavigation.views.stack.topbar.TopBar) Context(android.content.Context) Text(com.reactnativenavigation.options.params.Text) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) StackLayout(com.reactnativenavigation.views.stack.StackLayout) Java6Assertions.assertThat(org.assertj.core.api.Java6Assertions.assertThat) IReactView(com.reactnativenavigation.viewcontrollers.viewcontroller.IReactView) ColorDrawable(android.graphics.drawable.ColorDrawable) Colour(com.reactnativenavigation.options.params.Colour) Mockito.spy(org.mockito.Mockito.spy) ComponentViewController(com.reactnativenavigation.viewcontrollers.component.ComponentViewController) TopBarController(com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController) View(android.view.View) Bool(com.reactnativenavigation.options.params.Bool) BaseTest(com.reactnativenavigation.BaseTest) MATCH_PARENT(android.view.ViewGroup.LayoutParams.MATCH_PARENT) Test(org.junit.Test) Presenter(com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter) Color(android.graphics.Color) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) TestReactView(com.reactnativenavigation.mocks.TestReactView) ThemeColour(com.reactnativenavigation.options.params.ThemeColour) Options(com.reactnativenavigation.options.Options) Configuration(android.content.res.Configuration) ComponentPresenter(com.reactnativenavigation.viewcontrollers.component.ComponentPresenter) TestUtils(com.reactnativenavigation.TestUtils) RelativeLayout(android.widget.RelativeLayout) TestComponentLayout(com.reactnativenavigation.mocks.TestComponentLayout) Activity(android.app.Activity) Context(android.content.Context) Options(com.reactnativenavigation.options.Options) TestReactView(com.reactnativenavigation.mocks.TestReactView) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) ComponentPresenter(com.reactnativenavigation.viewcontrollers.component.ComponentPresenter) Presenter(com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter) ComponentPresenter(com.reactnativenavigation.viewcontrollers.component.ComponentPresenter) TestComponentLayout(com.reactnativenavigation.mocks.TestComponentLayout) RelativeLayout(android.widget.RelativeLayout) StackLayout(com.reactnativenavigation.views.stack.StackLayout) ComponentViewController(com.reactnativenavigation.viewcontrollers.component.ComponentViewController) TopBarController(com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController)

Example 2 with Presenter

use of com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter in project react-native-navigation by wix.

the class SideMenuControllerTest method beforeEach.

@Override
public void beforeEach() {
    super.beforeEach();
    activity = createActivity();
    childRegistry = new ChildControllersRegistry();
    presenter = spy(new SideMenuPresenter());
    child = new SimpleComponentViewController(activity, childRegistry, "child", new Options());
    left = spy(new SimpleComponentViewController(activity, childRegistry, "left", new Options()));
    right = spy(new SimpleComponentViewController(activity, childRegistry, "right", createSideMenuOptions()));
    center = spy(new SimpleComponentViewController(activity, childRegistry, "center", createSideMenuOptions()));
    uut = new SideMenuController(activity, childRegistry, "sideMenu", new Options(), presenter, new Presenter(activity, new Options())) {

        @Override
        public Options resolveCurrentOptions() {
            resolvedOptions = super.resolveCurrentOptions();
            return resolvedOptions;
        }
    };
    uut.setCenterController(center);
    parent = Mocks.INSTANCE.parentController(null);
    Mockito.when(parent.resolveChildOptions(uut)).thenReturn(Options.EMPTY);
    uut.setParentController(parent);
}
Also used : SideMenuOptions(com.reactnativenavigation.options.SideMenuOptions) Options(com.reactnativenavigation.options.Options) Presenter(com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) SimpleComponentViewController(com.reactnativenavigation.mocks.SimpleComponentViewController)

Example 3 with Presenter

use of com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter 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();
}
Also used : Options(com.reactnativenavigation.options.Options) TestReactView(com.reactnativenavigation.mocks.TestReactView) Presenter(com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter) TestComponentLayout(com.reactnativenavigation.mocks.TestComponentLayout) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)

Example 4 with Presenter

use of com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter in project react-native-navigation by wix.

the class ExternalComponentViewControllerTest method beforeEach.

@Override
public void beforeEach() {
    componentCreator = spy(new FragmentCreatorMock());
    activity = newActivity();
    ec = createExternalComponent();
    reactInstanceManager = Mockito.mock(ReactInstanceManager.class);
    emitter = Mockito.mock(EventEmitter.class);
    childRegistry = new ChildControllersRegistry();
    uut = spy(new ExternalComponentViewController(activity, childRegistry, "fragmentId", new Presenter(activity, Options.EMPTY), ec, componentCreator, reactInstanceManager, emitter, new ExternalComponentPresenter(), new Options()));
}
Also used : Options(com.reactnativenavigation.options.Options) ReactInstanceManager(com.facebook.react.ReactInstanceManager) EventEmitter(com.reactnativenavigation.react.events.EventEmitter) Presenter(com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)

Example 5 with Presenter

use of com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter in project react-native-navigation by wix.

the class TopTabsViewControllerTest method beforeEach.

@Override
public void beforeEach() {
    super.beforeEach();
    activity = newActivity();
    childRegistry = new ChildControllersRegistry();
    List<Options> tabOptions = createOptions();
    tabControllers = createTabsControllers(activity, tabOptions);
    topTabsLayout = spy(new TopTabsViewPager(activity, tabControllers, new TopTabsAdapter(tabControllers)));
    TopTabsLayoutCreator layoutCreator = Mockito.mock(TopTabsLayoutCreator.class);
    Mockito.when(layoutCreator.create()).thenReturn(topTabsLayout);
    Presenter presenter = new Presenter(activity, new Options());
    options.topBar.buttons.back.visible = new Bool(false);
    uut = spy(new TopTabsController(activity, childRegistry, "componentId", tabControllers, layoutCreator, options, presenter));
    tabControllers.forEach(viewController -> viewController.setParentController(uut));
    stack = spy(TestUtils.newStackController(activity).build());
    stack.ensureViewIsCreated();
}
Also used : Options(com.reactnativenavigation.options.Options) TopTabsLayoutCreator(com.reactnativenavigation.views.toptabs.TopTabsLayoutCreator) Bool(com.reactnativenavigation.options.params.Bool) Presenter(com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter) ComponentPresenter(com.reactnativenavigation.viewcontrollers.component.ComponentPresenter) TopTabsViewPager(com.reactnativenavigation.views.toptabs.TopTabsViewPager) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)

Aggregations

Presenter (com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter)13 Options (com.reactnativenavigation.options.Options)8 ComponentPresenter (com.reactnativenavigation.viewcontrollers.component.ComponentPresenter)7 ChildControllersRegistry (com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)6 ComponentViewController (com.reactnativenavigation.viewcontrollers.component.ComponentViewController)5 ViewController (com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController)5 BottomTabPresenter (com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabPresenter)4 BottomTabsPresenter (com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsPresenter)4 ExternalComponentPresenter (com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentPresenter)4 SideMenuPresenter (com.reactnativenavigation.viewcontrollers.sidemenu.SideMenuPresenter)4 StackPresenter (com.reactnativenavigation.viewcontrollers.stack.StackPresenter)4 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)3 ExternalComponentViewController (com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentViewController)3 TestComponentLayout (com.reactnativenavigation.mocks.TestComponentLayout)2 TestReactView (com.reactnativenavigation.mocks.TestReactView)2 Bool (com.reactnativenavigation.options.params.Bool)2 Text (com.reactnativenavigation.options.params.Text)2 TopTabsLayoutCreator (com.reactnativenavigation.views.toptabs.TopTabsLayoutCreator)2 ArrayList (java.util.ArrayList)2 Activity (android.app.Activity)1