Search in sources :

Example 36 with Options

use of com.reactnativenavigation.options.Options in project react-native-navigation by wix.

the class SideMenuControllerTest method openRightMenu.

private void openRightMenu() {
    Options options = new Options();
    options.sideMenuRootOptions.right.visible = new Bool(true);
    options.sideMenuRootOptions.right.animate = new Bool(false);
    uut.mergeOptions(options);
    uut.onDrawerSlide(right.getView(), 1);
}
Also used : SideMenuOptions(com.reactnativenavigation.options.SideMenuOptions) Options(com.reactnativenavigation.options.Options) Bool(com.reactnativenavigation.options.params.Bool)

Example 37 with Options

use of com.reactnativenavigation.options.Options 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();
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 38 with Options

use of com.reactnativenavigation.options.Options in project react-native-navigation by wix.

the class ViewControllerTest method onChildViewAdded_delegatesToYellowBoxDelegate.

@Test
public void onChildViewAdded_delegatesToYellowBoxDelegate() {
    View child = new View(activity);
    ViewGroup view = new FrameLayout(activity);
    ViewController vc = new ViewController(activity, "", yellowBoxDelegate, new Options(), new ViewControllerOverlay(activity)) {

        @Override
        public ViewGroup createView() {
            return view;
        }

        @Override
        public void sendOnNavigationButtonPressed(String buttonId) {
        }

        @Override
        public String getCurrentComponentName() {
            return null;
        }
    };
    vc.onChildViewAdded(view, child);
    verify(yellowBoxDelegate).onChildViewAdded(view, child);
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) View(android.view.View) ViewControllerOverlay(com.reactnativenavigation.viewcontrollers.viewcontroller.overlay.ViewControllerOverlay) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 39 with Options

use of com.reactnativenavigation.options.Options in project react-native-navigation by wix.

the class ComponentViewControllerTest method getTopInset_drawBehind_defaultOptions.

@Test
public void getTopInset_drawBehind_defaultOptions() {
    Options defaultOptions = new Options();
    defaultOptions.statusBar.drawBehind = new Bool(true);
    uut.setDefaultOptions(defaultOptions);
    uut.options.topBar.drawBehind = new Bool(true);
    Java6Assertions.assertThat(uut.getTopInset()).isEqualTo(0);
}
Also used : Options(com.reactnativenavigation.options.Options) Bool(com.reactnativenavigation.options.params.Bool) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 40 with Options

use of com.reactnativenavigation.options.Options 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)

Aggregations

Options (com.reactnativenavigation.options.Options)110 BaseTest (com.reactnativenavigation.BaseTest)57 Test (org.junit.Test)57 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)32 SideMenuOptions (com.reactnativenavigation.options.SideMenuOptions)19 CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)18 ChildControllersRegistry (com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)16 Bool (com.reactnativenavigation.options.params.Bool)15 Text (com.reactnativenavigation.options.params.Text)15 OrientationOptions (com.reactnativenavigation.options.OrientationOptions)10 AnimationOptions (com.reactnativenavigation.options.AnimationOptions)9 ButtonOptions (com.reactnativenavigation.options.ButtonOptions)9 FrameLayout (android.widget.FrameLayout)8 SimpleComponentViewController (com.reactnativenavigation.mocks.SimpleComponentViewController)8 Presenter (com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter)8 ComponentOptions (com.reactnativenavigation.options.ComponentOptions)6 TopBarOptions (com.reactnativenavigation.options.TopBarOptions)6 TopTabOptions (com.reactnativenavigation.options.TopTabOptions)6 TopTabsOptions (com.reactnativenavigation.options.TopTabsOptions)6 Activity (android.app.Activity)5