Search in sources :

Example 36 with SimpleViewController

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

the class NavigatorTest method setDefaultOptions.

@Test
public void setDefaultOptions() {
    uut.setDefaultOptions(new Options());
    SimpleViewController spy = spy(child1);
    uut.setRoot(spy, new CommandListenerAdapter(), reactInstanceManager);
    Options defaultOptions = new Options();
    uut.setDefaultOptions(defaultOptions);
    verify(spy).setDefaultOptions(defaultOptions);
    verify(modalStack).setDefaultOptions(defaultOptions);
}
Also used : ModalOptions(com.reactnativenavigation.options.ModalOptions) Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 37 with SimpleViewController

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

the class NavigatorTest method shouldNotCallModalOnHostPauseWhenHostPausesAndNoModals.

@Test
public void shouldNotCallModalOnHostPauseWhenHostPausesAndNoModals() {
    SimpleViewController child1 = spy(this.child1);
    uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
    uut.onHostPause();
    verify(modalStack, never()).onHostPause();
}
Also used : SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 38 with SimpleViewController

use of com.reactnativenavigation.mocks.SimpleViewController 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 39 with SimpleViewController

use of com.reactnativenavigation.mocks.SimpleViewController 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 40 with SimpleViewController

use of com.reactnativenavigation.mocks.SimpleViewController 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

SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)42 BaseTest (com.reactnativenavigation.BaseTest)31 Test (org.junit.Test)31 Options (com.reactnativenavigation.options.Options)27 CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)21 ChildControllersRegistry (com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)8 Activity (android.app.Activity)4 ModalOptions (com.reactnativenavigation.options.ModalOptions)4 StackController (com.reactnativenavigation.viewcontrollers.stack.StackController)4 FrameLayout (android.widget.FrameLayout)3 View (android.view.View)2 CoordinatorLayout (androidx.coordinatorlayout.widget.CoordinatorLayout)2 TransitionAnimationOptions (com.reactnativenavigation.options.TransitionAnimationOptions)2 Text (com.reactnativenavigation.options.params.Text)2 EventEmitter (com.reactnativenavigation.react.events.EventEmitter)2 ViewParent (android.view.ViewParent)1 ReactInstanceManager (com.facebook.react.ReactInstanceManager)1 TestActivity (com.reactnativenavigation.TestActivity)1 TypefaceLoaderMock (com.reactnativenavigation.mocks.TypefaceLoaderMock)1 FabOptions (com.reactnativenavigation.options.FabOptions)1