Search in sources :

Example 21 with SimpleViewController

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

the class ParentControllerTest method onViewDidAppearShouldCallCurrentChildDidAppear.

@Test
public void onViewDidAppearShouldCallCurrentChildDidAppear() {
    SimpleViewController child1 = spy(new SimpleViewController(activity, childRegistry, "child1", new Options()));
    SimpleViewController child2 = spy(new SimpleViewController(activity, childRegistry, "child2", new Options()));
    children.add(child1);
    children.add(child2);
    uut.onViewDidAppear();
    verify(child1).onViewDidAppear();
    verify(child2, never()).onViewDidAppear();
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 22 with SimpleViewController

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

the class ParentControllerTest method onConfigurationChange_shouldCallConfigurationChangeForPresenterAndChildren.

@Test
public void onConfigurationChange_shouldCallConfigurationChangeForPresenterAndChildren() {
    children.add(spy(new SimpleViewController(activity, childRegistry, "child1", new Options())));
    children.add(spy(new SimpleViewController(activity, childRegistry, "child2", new Options())));
    ParentController<?> spyUUT = spy(uut);
    spyUUT.onConfigurationChanged(mockConfiguration);
    verify(presenter).onConfigurationChanged(any(), any());
    for (ViewController<?> controller : children) {
        verify(controller).onConfigurationChanged(any());
    }
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 23 with SimpleViewController

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

the class ParentControllerTest method onViewDisappearShouldCallCurrentChildDisAppear.

@Test
public void onViewDisappearShouldCallCurrentChildDisAppear() {
    SimpleViewController child1 = spy(new SimpleViewController(activity, childRegistry, "child1", new Options()));
    SimpleViewController child2 = spy(new SimpleViewController(activity, childRegistry, "child2", new Options()));
    children.add(child1);
    children.add(child2);
    uut.onViewDisappear();
    verify(child1).onViewDisappear();
    verify(child2, never()).onViewDisappear();
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 24 with SimpleViewController

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

the class ParentControllerTest method findControllerById_ChildById.

@Test
public void findControllerById_ChildById() {
    SimpleViewController child1 = new SimpleViewController(activity, childRegistry, "child1", new Options());
    SimpleViewController child2 = new SimpleViewController(activity, childRegistry, "child2", new Options());
    children.add(child1);
    children.add(child2);
    assertThat(uut.findController("uut")).isEqualTo(uut);
    assertThat(uut.findController("child1")).isEqualTo(child1);
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 25 with SimpleViewController

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

the class NavigatorTest method shouldCallRootOnViewDidAppearWhenModalDisplayedOverContext.

@Test
public void shouldCallRootOnViewDidAppearWhenModalDisplayedOverContext() {
    SimpleViewController child1 = spy(this.child1);
    final Options overContextOptions = tabOptions.copy();
    overContextOptions.modal = new ModalOptions();
    overContextOptions.modal.presentationStyle = ModalPresentationStyle.OverCurrentContext;
    ViewController<?> overContextModal = spy(new SimpleViewController(activity, childRegistry, "overContextModal", overContextOptions));
    uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
    uut.showModal(overContextModal, new CommandListenerAdapter());
    uut.onHostResume();
    verify(child1, times(2)).onViewDidAppear();
    verify(overContextModal, times(1)).onViewDidAppear();
}
Also used : ModalOptions(com.reactnativenavigation.options.ModalOptions) Options(com.reactnativenavigation.options.Options) ModalOptions(com.reactnativenavigation.options.ModalOptions) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

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