SideMenuController extends ParentController<DrawerLayout> { public void setLeftController(ViewController controller) { this.left = controller; int height = this.getHeight(options.sideMenuRootOptions.left); int width = this.getWidth(options.sideMenuRootOptions.left); getView().addView(controller.getView(), new LayoutParams(width, height, Gravity.LEFT)); } SideMenuController(Activity activity, ChildControllersRegistry childRegistry, String id, Options initialOptions, SideMenuPresenter sideMenuOptionsPresenter, Presenter presenter); @Override void sendOnNavigationButtonPressed(String buttonId); @NonNull @Override Collection<ViewController> getChildControllers(); @Override void applyChildOptions(Options options, Component child); @Override void mergeChildOptions(Options options, ViewController childController, Component child); @Override void mergeOptions(Options options); @Override boolean handleBack(CommandListener listener); void setCenterController(ViewController centerController); void setLeftController(ViewController controller); void setRightController(ViewController controller);  }
@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); }
@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); }
@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); }