Search in sources :

Example 26 with Options

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

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

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

the class SideMenuControllerTest method setRightController_matchesParentByDefault.

@Test
public void setRightController_matchesParentByDefault() {
    SideMenuOptions options = new SideMenuOptions();
    assertThat(options.width.hasValue()).isFalse();
    assertThat(options.height.hasValue()).isFalse();
    uut.options.sideMenuRootOptions.left = options;
    SimpleComponentViewController componentViewController = new SimpleComponentViewController(activity, childRegistry, "right", new Options());
    uut.setRightController(componentViewController);
    LayoutParams params = componentViewController.getView().getLayoutParams();
    assertThat(params.width).isEqualTo(MATCH_PARENT);
    assertThat(params.height).isEqualTo(MATCH_PARENT);
}
Also used : SideMenuOptions(com.reactnativenavigation.options.SideMenuOptions) Options(com.reactnativenavigation.options.Options) LayoutParams(android.view.ViewGroup.LayoutParams) SideMenuOptions(com.reactnativenavigation.options.SideMenuOptions) SimpleComponentViewController(com.reactnativenavigation.mocks.SimpleComponentViewController) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 29 with Options

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

the class SideMenuControllerTest method setRightController_setHeightAndWidthWithOptions.

@Test
public void setRightController_setHeightAndWidthWithOptions() {
    SideMenuOptions options = new SideMenuOptions();
    options.height = new Number(100);
    options.width = new Number(200);
    uut.options.sideMenuRootOptions.left = options;
    SimpleComponentViewController componentViewController = new SimpleComponentViewController(activity, childRegistry, "left", new Options());
    uut.setLeftController(componentViewController);
    int heightInDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, Resources.getSystem().getDisplayMetrics());
    int widthInDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200, Resources.getSystem().getDisplayMetrics());
    LayoutParams params = componentViewController.getView().getLayoutParams();
    assertThat(params.width).isEqualTo(widthInDp);
    assertThat(params.height).isEqualTo(heightInDp);
}
Also used : SideMenuOptions(com.reactnativenavigation.options.SideMenuOptions) Options(com.reactnativenavigation.options.Options) LayoutParams(android.view.ViewGroup.LayoutParams) Number(com.reactnativenavigation.options.params.Number) SideMenuOptions(com.reactnativenavigation.options.SideMenuOptions) SimpleComponentViewController(com.reactnativenavigation.mocks.SimpleComponentViewController) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 30 with Options

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

the class SideMenuControllerTest method openLeftMenu.

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

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