Search in sources :

Example 1 with SimpleComponentViewController

use of com.reactnativenavigation.mocks.SimpleComponentViewController 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 2 with SimpleComponentViewController

use of com.reactnativenavigation.mocks.SimpleComponentViewController 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 3 with SimpleComponentViewController

use of com.reactnativenavigation.mocks.SimpleComponentViewController 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 4 with SimpleComponentViewController

use of com.reactnativenavigation.mocks.SimpleComponentViewController 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 5 with SimpleComponentViewController

use of com.reactnativenavigation.mocks.SimpleComponentViewController in project react-native-navigation by wix.

the class SideMenuControllerTest method setLeftController_matchesParentByDefault.

@Test
public void setLeftController_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, "left", new Options());
    uut.setLeftController(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)

Aggregations

SimpleComponentViewController (com.reactnativenavigation.mocks.SimpleComponentViewController)8 Options (com.reactnativenavigation.options.Options)8 BaseTest (com.reactnativenavigation.BaseTest)7 SideMenuOptions (com.reactnativenavigation.options.SideMenuOptions)7 Test (org.junit.Test)7 LayoutParams (android.view.ViewGroup.LayoutParams)4 Bool (com.reactnativenavigation.options.params.Bool)2 Number (com.reactnativenavigation.options.params.Number)2 ModalOptions (com.reactnativenavigation.options.ModalOptions)1 Text (com.reactnativenavigation.options.params.Text)1 CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)1 ChildControllersRegistry (com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)1 ComponentViewController (com.reactnativenavigation.viewcontrollers.component.ComponentViewController)1 Presenter (com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter)1