Search in sources :

Example 31 with Options

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

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

the class SideMenuControllerTest method mergeChildOptions_lockModeIsUpdatedInInitialOptions.

@Test
public void mergeChildOptions_lockModeIsUpdatedInInitialOptions() {
    setLeftRight(left, right);
    Options leftDisabled = new Options();
    leftDisabled.sideMenuRootOptions.left.enabled = new Bool(false);
    left.mergeOptions(leftDisabled);
    assertThat(uut.resolveCurrentOptions().sideMenuRootOptions.left.enabled.get()).isFalse();
    Options rightVisible = new Options();
    rightVisible.sideMenuRootOptions.right.visible = new Bool(true);
    right.mergeOptions(rightVisible);
    assertThat(uut.resolveCurrentOptions().sideMenuRootOptions.left.enabled.get()).isFalse();
}
Also used : SideMenuOptions(com.reactnativenavigation.options.SideMenuOptions) Options(com.reactnativenavigation.options.Options) Bool(com.reactnativenavigation.options.params.Bool) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 33 with Options

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

the class SideMenuControllerTest method setLeftController_setHeightAndWidthWithOptions.

@Test
public void setLeftController_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 34 with Options

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

the class SideMenuControllerTest method applyChildOptions.

@Test
public void applyChildOptions() {
    uut.applyChildOptions(new Options(), child);
    verify(presenter).applyChildOptions(eq(resolvedOptions));
    verify(parent).applyChildOptions(uut.options, child);
}
Also used : SideMenuOptions(com.reactnativenavigation.options.SideMenuOptions) Options(com.reactnativenavigation.options.Options) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 35 with Options

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

the class SideMenuControllerTest method createSideMenuOptions.

@NotNull
private Options createSideMenuOptions() {
    Options options = new Options();
    options.sideMenuRootOptions.left.animate = new Bool(false);
    options.sideMenuRootOptions.right.animate = new Bool(false);
    return options;
}
Also used : SideMenuOptions(com.reactnativenavigation.options.SideMenuOptions) Options(com.reactnativenavigation.options.Options) Bool(com.reactnativenavigation.options.params.Bool) NotNull(org.jetbrains.annotations.NotNull)

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