Search in sources :

Example 6 with ChildControllersRegistry

use of com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry in project react-native-navigation by wix.

the class ModalStackTest method beforeEach.

@Override
public void beforeEach() {
    super.beforeEach();
    activity = newActivity();
    childRegistry = new ChildControllersRegistry();
    root = new SimpleViewController(activity, childRegistry, "root", new Options());
    FrameLayout rootLayout = new FrameLayout(activity);
    CoordinatorLayout modalsLayout = new CoordinatorLayout(activity);
    FrameLayout contentLayout = new FrameLayout(activity);
    contentLayout.addView(rootLayout);
    contentLayout.addView(modalsLayout);
    activity.setContentView(contentLayout);
    animator = spy(new ModalAnimatorMock(activity));
    presenter = spy(new ModalPresenter(animator));
    uut = new ModalStack(activity, presenter);
    uut.setModalsLayout(modalsLayout);
    uut.setRootLayout(rootLayout);
    emitter = Mockito.mock(EventEmitter.class);
    uut.setEventEmitter(emitter);
    modal1 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_1, new Options()));
    modal2 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_2, new Options()));
    modal3 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_3, new Options()));
    modal4 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_4, new Options()));
    stack = TestUtils.newStackController(activity).setChildren(modal4).build();
}
Also used : CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) TransitionAnimationOptions(com.reactnativenavigation.options.TransitionAnimationOptions) Options(com.reactnativenavigation.options.Options) EventEmitter(com.reactnativenavigation.react.events.EventEmitter) FrameLayout(android.widget.FrameLayout) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController)

Example 7 with ChildControllersRegistry

use of com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry in project react-native-navigation by wix.

the class OverlayManagerTest method beforeEach.

@Override
public void beforeEach() {
    super.beforeEach();
    Activity activity = newActivity();
    contentLayout = new FrameLayout(activity);
    contentLayout.layout(0, 0, 1000, 1000);
    activity.setContentView(contentLayout);
    overlayContainer = new FrameLayout(activity);
    contentLayout.addView(overlayContainer);
    ChildControllersRegistry childRegistry = new ChildControllersRegistry();
    overlay1 = spy(new SimpleViewController(activity, childRegistry, OVERLAY_ID_1, new Options()));
    overlay2 = spy(new SimpleViewController(activity, childRegistry, OVERLAY_ID_2, new Options()));
    uut = new OverlayManager();
}
Also used : Options(com.reactnativenavigation.options.Options) FrameLayout(android.widget.FrameLayout) Activity(android.app.Activity) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController)

Example 8 with ChildControllersRegistry

use of com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry 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 9 with ChildControllersRegistry

use of com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry 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 10 with ChildControllersRegistry

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

Aggregations

ChildControllersRegistry (com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)19 Options (com.reactnativenavigation.options.Options)16 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)9 Presenter (com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter)6 Activity (android.app.Activity)4 FrameLayout (android.widget.FrameLayout)4 EventEmitter (com.reactnativenavigation.react.events.EventEmitter)4 CoordinatorLayout (androidx.coordinatorlayout.widget.CoordinatorLayout)3 ReactInstanceManager (com.facebook.react.ReactInstanceManager)3 Context (android.content.Context)2 View (android.view.View)2 TestComponentLayout (com.reactnativenavigation.mocks.TestComponentLayout)2 TestReactView (com.reactnativenavigation.mocks.TestReactView)2 TypefaceLoaderMock (com.reactnativenavigation.mocks.TypefaceLoaderMock)2 Bool (com.reactnativenavigation.options.params.Bool)2 Text (com.reactnativenavigation.options.params.Text)2 ComponentPresenter (com.reactnativenavigation.viewcontrollers.component.ComponentPresenter)2 ModalStack (com.reactnativenavigation.viewcontrollers.modal.ModalStack)2 OverlayManager (com.reactnativenavigation.viewcontrollers.overlay.OverlayManager)2 TopBarController (com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController)2