Search in sources :

Example 91 with Options

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

the class ViewControllerTest method beforeEach.

@Override
public void beforeEach() {
    super.beforeEach();
    yellowBoxDelegate = Mockito.mock(YellowBoxDelegate.class);
    activity = newActivity();
    childRegistry = new ChildControllersRegistry();
    uut = new SimpleViewController(activity, childRegistry, "uut", new Options());
    mockedParent = Mocks.INSTANCE.parentController(null);
    uut.setParentController(mockedParent);
    Mockito.when(mockedParent.resolveChildOptions(any())).thenReturn(Options.EMPTY);
}
Also used : Options(com.reactnativenavigation.options.Options) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController)

Example 92 with Options

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

the class ViewControllerTest method onDestroy_RemovesGlobalLayoutListener.

@Test
public void onDestroy_RemovesGlobalLayoutListener() throws Exception {
    new SimpleViewController(activity, childRegistry, "ensureNotNull", new Options()).destroy();
    ViewController spy = spy(uut);
    View view = spy.getView();
    Shadows.shadowOf(view).setMyParent(mock(ViewParent.class));
    spy.destroy();
    Assertions.assertThat(view).isShown();
    view.getViewTreeObserver().dispatchOnGlobalLayout();
    verify(spy, times(0)).onViewWillAppear();
    verify(spy, times(0)).onViewDisappear();
    Field field = ViewController.class.getDeclaredField("view");
    field.setAccessible(true);
    assertThat(field.get(spy)).isNull();
}
Also used : Options(com.reactnativenavigation.options.Options) Field(java.lang.reflect.Field) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) ViewParent(android.view.ViewParent) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) View(android.view.View) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 93 with Options

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

the class ViewControllerTest method canOverrideViewCreation.

@Test
public void canOverrideViewCreation() {
    final FrameLayout otherView = new FrameLayout(activity);
    yellowBoxDelegate = spy(new YellowBoxDelegate(activity));
    ViewController myController = new ViewController(activity, "vc", yellowBoxDelegate, new Options(), new ViewControllerOverlay(activity)) {

        @Override
        public FrameLayout createView() {
            return otherView;
        }

        @Override
        public void sendOnNavigationButtonPressed(String buttonId) {
        }

        @Override
        public String getCurrentComponentName() {
            return null;
        }
    };
    assertThat(myController.getView()).isEqualTo(otherView);
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) FrameLayout(android.widget.FrameLayout) ViewControllerOverlay(com.reactnativenavigation.viewcontrollers.viewcontroller.overlay.ViewControllerOverlay) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 94 with Options

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

the class AttachModeTest method beforeEach.

@Override
public void beforeEach() {
    activity = newActivity();
    childRegistry = new ChildControllersRegistry();
    parent = new CoordinatorLayout(activity);
    tabs = createTabs();
    options = new Options();
    options.bottomTabsOptions.currentTabIndex = new Number(INITIAL_TAB);
    presenter = Mockito.mock(BottomTabsPresenter.class);
}
Also used : CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) Options(com.reactnativenavigation.options.Options) Number(com.reactnativenavigation.options.params.Number) BottomTabsPresenter(com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsPresenter) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)

Example 95 with Options

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

the class AttachModeTest method createTabs.

private List<ViewController<?>> createTabs() {
    tab1 = new SimpleViewController(activity, childRegistry, "child1", new Options());
    tab2 = spy(new SimpleViewController(activity, childRegistry, "child2", new Options()));
    ViewController<?> tab3 = new SimpleViewController(activity, childRegistry, "child3", new Options());
    return Arrays.asList(tab1, tab2, tab3);
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController)

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