|  | @@ -12,16 +12,22 @@ import com.reactnativenavigation.parse.Options;
 | 
	
		
			
			| 12 | 12 |  import com.reactnativenavigation.parse.SideMenuOptions;
 | 
	
		
			
			| 13 | 13 |  import com.reactnativenavigation.parse.params.Bool;
 | 
	
		
			
			| 14 | 14 |  import com.reactnativenavigation.parse.params.Number;
 | 
	
		
			
			|  | 15 | +import com.reactnativenavigation.parse.params.Text;
 | 
	
		
			
			| 15 | 16 |  import com.reactnativenavigation.presentation.Presenter;
 | 
	
		
			
			| 16 | 17 |  import com.reactnativenavigation.presentation.SideMenuPresenter;
 | 
	
		
			
			| 17 | 18 |  import com.reactnativenavigation.utils.CommandListenerAdapter;
 | 
	
		
			
			| 18 | 19 |  import com.reactnativenavigation.viewcontrollers.ChildControllersRegistry;
 | 
	
		
			
			|  | 20 | +import com.reactnativenavigation.viewcontrollers.ParentController;
 | 
	
		
			
			|  | 21 | +import com.reactnativenavigation.viewcontrollers.ViewController;
 | 
	
		
			
			|  | 22 | +import com.reactnativenavigation.views.Component;
 | 
	
		
			
			| 19 | 23 |  
 | 
	
		
			
			| 20 | 24 |  import org.junit.Test;
 | 
	
		
			
			|  | 25 | +import org.mockito.Mockito;
 | 
	
		
			
			| 21 | 26 |  
 | 
	
		
			
			| 22 | 27 |  import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
 | 
	
		
			
			| 23 | 28 |  import static org.assertj.core.api.Java6Assertions.assertThat;
 | 
	
		
			
			| 24 | 29 |  import static org.mockito.ArgumentMatchers.any;
 | 
	
		
			
			|  | 30 | +import static org.mockito.ArgumentMatchers.eq;
 | 
	
		
			
			| 25 | 31 |  import static org.mockito.Mockito.spy;
 | 
	
		
			
			| 26 | 32 |  import static org.mockito.Mockito.times;
 | 
	
		
			
			| 27 | 33 |  import static org.mockito.Mockito.verify;
 | 
	
	
		
			
			|  | @@ -32,20 +38,32 @@ public class SideMenuControllerTest extends BaseTest {
 | 
	
		
			
			| 32 | 38 |      private Activity activity;
 | 
	
		
			
			| 33 | 39 |      private ChildControllersRegistry childRegistry;
 | 
	
		
			
			| 34 | 40 |      private SideMenuPresenter presenter;
 | 
	
		
			
			| 35 |  | -    private SimpleComponentViewController left;
 | 
	
		
			
			| 36 |  | -    private SimpleComponentViewController right;
 | 
	
		
			
			| 37 |  | -    private SimpleComponentViewController center;
 | 
	
		
			
			|  | 41 | +    private ViewController left;
 | 
	
		
			
			|  | 42 | +    private ViewController right;
 | 
	
		
			
			|  | 43 | +    private ViewController center;
 | 
	
		
			
			|  | 44 | +    private ViewController child;
 | 
	
		
			
			|  | 45 | +    private ParentController parent;
 | 
	
		
			
			|  | 46 | +    private Options resolvedOptions;
 | 
	
		
			
			| 38 | 47 |  
 | 
	
		
			
			| 39 | 48 |      @Override
 | 
	
		
			
			| 40 | 49 |      public void beforeEach() {
 | 
	
		
			
			| 41 | 50 |          activity = newActivity();
 | 
	
		
			
			| 42 | 51 |          childRegistry = new ChildControllersRegistry();
 | 
	
		
			
			| 43 | 52 |          presenter = spy(new SideMenuPresenter());
 | 
	
		
			
			|  | 53 | +        child = new SimpleComponentViewController(activity, childRegistry, "child", new Options());
 | 
	
		
			
			| 44 | 54 |          left = new SimpleComponentViewController(activity, childRegistry, "left", new Options());
 | 
	
		
			
			| 45 | 55 |          right = new SimpleComponentViewController(activity, childRegistry, "right", new Options());
 | 
	
		
			
			| 46 | 56 |          center = spy(new SimpleComponentViewController(activity, childRegistry, "center", new Options()));
 | 
	
		
			
			| 47 |  | -        uut = new SideMenuController(activity, childRegistry, "sideMenu", new Options(), presenter, new Presenter(activity, new Options()));
 | 
	
		
			
			|  | 57 | +        uut = new SideMenuController(activity, childRegistry, "sideMenu", new Options(), presenter, new Presenter(activity, new Options())) {
 | 
	
		
			
			|  | 58 | +            @Override
 | 
	
		
			
			|  | 59 | +            public Options resolveCurrentOptions() {
 | 
	
		
			
			|  | 60 | +                resolvedOptions = super.resolveCurrentOptions();
 | 
	
		
			
			|  | 61 | +                return resolvedOptions;
 | 
	
		
			
			|  | 62 | +            }
 | 
	
		
			
			|  | 63 | +        };
 | 
	
		
			
			| 48 | 64 |          uut.setCenterController(center);
 | 
	
		
			
			|  | 65 | +        parent = Mockito.mock(ParentController.class);
 | 
	
		
			
			|  | 66 | +        uut.setParentController(parent);
 | 
	
		
			
			| 49 | 67 |      }
 | 
	
		
			
			| 50 | 68 |  
 | 
	
		
			
			| 51 | 69 |      @Test
 | 
	
	
		
			
			|  | @@ -54,6 +72,13 @@ public class SideMenuControllerTest extends BaseTest {
 | 
	
		
			
			| 54 | 72 |          verify(presenter).bindView(uut.getView());
 | 
	
		
			
			| 55 | 73 |      }
 | 
	
		
			
			| 56 | 74 |  
 | 
	
		
			
			|  | 75 | +    @Test
 | 
	
		
			
			|  | 76 | +    public void applyChildOptions() {
 | 
	
		
			
			|  | 77 | +        uut.applyChildOptions(new Options(), (Component) child.getView());
 | 
	
		
			
			|  | 78 | +        verify(presenter).applyChildOptions(eq(resolvedOptions));
 | 
	
		
			
			|  | 79 | +        verify(parent).applyChildOptions(uut.options, (Component) child.getView());
 | 
	
		
			
			|  | 80 | +    }
 | 
	
		
			
			|  | 81 | +
 | 
	
		
			
			| 57 | 82 |      @Test
 | 
	
		
			
			| 58 | 83 |      public void mergeOptions_openLeftSideMenu() {
 | 
	
		
			
			| 59 | 84 |          uut.setLeftController(new SimpleComponentViewController(activity, childRegistry, "left", new Options()));
 | 
	
	
		
			
			|  | @@ -84,6 +109,23 @@ public class SideMenuControllerTest extends BaseTest {
 | 
	
		
			
			| 84 | 109 |          assertThat(uut.options.sideMenuRootOptions).isNotEqualTo(initialOptions.sideMenuRootOptions);
 | 
	
		
			
			| 85 | 110 |      }
 | 
	
		
			
			| 86 | 111 |  
 | 
	
		
			
			|  | 112 | +    @Test
 | 
	
		
			
			|  | 113 | +    public void mergeChildOptions() {
 | 
	
		
			
			|  | 114 | +        Options options = new Options();
 | 
	
		
			
			|  | 115 | +        uut.mergeChildOptions(options, child, (Component) child.getView());
 | 
	
		
			
			|  | 116 | +        verify(presenter).mergeChildOptions(options.sideMenuRootOptions);
 | 
	
		
			
			|  | 117 | +    }
 | 
	
		
			
			|  | 118 | +
 | 
	
		
			
			|  | 119 | +    @Test
 | 
	
		
			
			|  | 120 | +    public void resolveCurrentOptions_centerOptionsAreMergedEvenIfDrawerIsOpen() {
 | 
	
		
			
			|  | 121 | +        uut.setLeftController(left);
 | 
	
		
			
			|  | 122 | +        center.options.topBar.title.text = new Text("Center");
 | 
	
		
			
			|  | 123 | +        assertThat(uut.resolveCurrentOptions().topBar.title.text.hasValue()).isTrue();
 | 
	
		
			
			|  | 124 | +
 | 
	
		
			
			|  | 125 | +        uut.getView().openDrawer(Gravity.LEFT);
 | 
	
		
			
			|  | 126 | +        assertThat(uut.resolveCurrentOptions().topBar.title.text.hasValue()).isTrue();
 | 
	
		
			
			|  | 127 | +    }
 | 
	
		
			
			|  | 128 | +
 | 
	
		
			
			| 87 | 129 |      @Test
 | 
	
		
			
			| 88 | 130 |      public void setLeftController_matchesParentByDefault() {
 | 
	
		
			
			| 89 | 131 |          SideMenuOptions options = new SideMenuOptions();
 | 
	
	
		
			
			|  | @@ -98,6 +140,7 @@ public class SideMenuControllerTest extends BaseTest {
 | 
	
		
			
			| 98 | 140 |          assertThat(params.width).isEqualTo(MATCH_PARENT);
 | 
	
		
			
			| 99 | 141 |          assertThat(params.height).isEqualTo(MATCH_PARENT);
 | 
	
		
			
			| 100 | 142 |      }
 | 
	
		
			
			|  | 143 | +
 | 
	
		
			
			| 101 | 144 |      @Test
 | 
	
		
			
			| 102 | 145 |      public void setLeftController_setHeightAndWidthWithOptions() {
 | 
	
		
			
			| 103 | 146 |          SideMenuOptions options = new SideMenuOptions();
 | 
	
	
		
			
			|  | @@ -115,6 +158,7 @@ public class SideMenuControllerTest extends BaseTest {
 | 
	
		
			
			| 115 | 158 |          assertThat(params.width).isEqualTo(widthInDp);
 | 
	
		
			
			| 116 | 159 |          assertThat(params.height).isEqualTo(heightInDp);
 | 
	
		
			
			| 117 | 160 |      }
 | 
	
		
			
			|  | 161 | +
 | 
	
		
			
			| 118 | 162 |      @Test
 | 
	
		
			
			| 119 | 163 |      public void setRightController_matchesParentByDefault() {
 | 
	
		
			
			| 120 | 164 |          SideMenuOptions options = new SideMenuOptions();
 | 
	
	
		
			
			|  | @@ -129,6 +173,7 @@ public class SideMenuControllerTest extends BaseTest {
 | 
	
		
			
			| 129 | 173 |          assertThat(params.width).isEqualTo(MATCH_PARENT);
 | 
	
		
			
			| 130 | 174 |          assertThat(params.height).isEqualTo(MATCH_PARENT);
 | 
	
		
			
			| 131 | 175 |      }
 | 
	
		
			
			|  | 176 | +
 | 
	
		
			
			| 132 | 177 |      @Test
 | 
	
		
			
			| 133 | 178 |      public void setRightController_setHeightAndWidthWithOptions() {
 | 
	
		
			
			| 134 | 179 |          SideMenuOptions options = new SideMenuOptions();
 |