Search in sources :

Example 66 with CommandListenerAdapter

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

the class NavigatorTest method dismissModal_rejectIfRootIsNotSetAndSingleModalIsDisplayed.

@Test
public void dismissModal_rejectIfRootIsNotSetAndSingleModalIsDisplayed() {
    disableModalAnimations(child1, child2);
    uut.showModal(child1, new CommandListenerAdapter());
    uut.showModal(child2, new CommandListenerAdapter());
    CommandListenerAdapter listener1 = spy(new CommandListenerAdapter());
    uut.dismissModal(child2.getId(), listener1);
    verify(listener1).onSuccess(any());
    assertThat(child2.isDestroyed()).isTrue();
    CommandListenerAdapter listener2 = spy(new CommandListenerAdapter());
    uut.dismissModal(child1.getId(), listener2);
    verify(listener2).onError(any());
    assertThat(child1.isDestroyed()).isFalse();
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 67 with CommandListenerAdapter

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

the class NavigatorTest method destroyViews.

@Test
public void destroyViews() {
    uut.setRoot(parentController, new CommandListenerAdapter(), reactInstanceManager);
    uut.showModal(child1, new CommandListenerAdapter());
    uut.showOverlay(child2, new CommandListenerAdapter());
    uut.destroy();
    assertThat(childRegistry.size()).isZero();
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 68 with CommandListenerAdapter

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

the class NavigatorTest method shouldNotCallModalOnHostResumeWhenHostResumesAndNoModals.

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

Example 69 with CommandListenerAdapter

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

the class NavigatorTest method onConfigurationChange_shouldCallOnConfigurationChangedForModals.

@Test
public void onConfigurationChange_shouldCallOnConfigurationChangedForModals() {
    Navigator spyUUT = spy(uut);
    SimpleViewController spyChild1 = spy(child1);
    ViewController<?> spyChild2 = spy(child2);
    ViewController<?> spyChild3 = spy(child3);
    spyUUT.setRoot(spyChild1, new CommandListenerAdapter(), reactInstanceManager);
    spyUUT.showModal(spyChild2, new CommandListenerAdapter());
    spyUUT.showModal(spyChild3, new CommandListenerAdapter());
    spyUUT.onConfigurationChanged(mockConfiguration);
    verify(spyChild2).onConfigurationChanged(any());
    verify(spyChild3).onConfigurationChanged(any());
}
Also used : SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 70 with CommandListenerAdapter

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

the class NavigatorTest method push_InvalidPushWithoutAStack_DoesNothing_Promise.

@Test
public void push_InvalidPushWithoutAStack_DoesNothing_Promise() {
    uut.setRoot(child1, new CommandListenerAdapter(), reactInstanceManager);
    uut.push(child1.getId(), child2, new CommandListenerAdapter() {

        @Override
        public void onError(String message) {
            assertIsChild(uut.getView(), child1.getView());
        }
    });
}
Also used : CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Aggregations

CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)121 BaseTest (com.reactnativenavigation.BaseTest)115 Test (org.junit.Test)115 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)22 StackController (com.reactnativenavigation.viewcontrollers.stack.StackController)19 Options (com.reactnativenavigation.options.Options)17 CommandListener (com.reactnativenavigation.react.CommandListener)16 Bool (com.reactnativenavigation.options.params.Bool)7 ModalOptions (com.reactnativenavigation.options.ModalOptions)5 BottomTabsController (com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController)5 Text (com.reactnativenavigation.options.params.Text)4 TransitionAnimationOptions (com.reactnativenavigation.options.TransitionAnimationOptions)3 FrameLayout (android.widget.FrameLayout)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 InOrder (org.mockito.InOrder)2 ColorDrawable (android.graphics.drawable.ColorDrawable)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 Nullable (androidx.annotation.Nullable)1 SimpleComponentViewController (com.reactnativenavigation.mocks.SimpleComponentViewController)1