Search in sources :

Example 11 with SimpleViewController

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

the class ParentControllerTest method resolveCurrentOptions_withDefaultOptions.

@Test
public void resolveCurrentOptions_withDefaultOptions() {
    SimpleViewController child1 = new SimpleViewController(activity, childRegistry, "child1", new Options());
    children.add(child1);
    uut.ensureViewIsCreated();
    Options defaultOptions = new Options();
    Options currentOptions = spy(new Options());
    ParentController<?> spy = spy(uut);
    Mockito.when(spy.resolveCurrentOptions()).thenReturn(currentOptions);
    spy.resolveCurrentOptions(defaultOptions);
    verify(currentOptions).withDefaultOptions(defaultOptions);
}
Also used : Options(com.reactnativenavigation.options.Options) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 12 with SimpleViewController

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

the class ParentControllerTest method mergeOptions_initialParentOptionsAreNotMutatedWhenChildAppears.

@Test
public void mergeOptions_initialParentOptionsAreNotMutatedWhenChildAppears() {
    Options options = new Options();
    options.topBar.title.text = new Text("new title");
    ViewController<?> child1 = spy(new SimpleViewController(activity, childRegistry, "child1", options));
    children.add(child1);
    uut.ensureViewIsCreated();
    child1.ensureViewIsCreated();
    child1.onViewWillAppear();
    assertThat(uut.initialOptions.topBar.title.text.get()).isEqualTo(INITIAL_TITLE);
}
Also used : Options(com.reactnativenavigation.options.Options) Text(com.reactnativenavigation.options.params.Text) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Example 13 with SimpleViewController

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

the class ModalPresenterTest method beforeEach.

@Override
public void beforeEach() {
    super.beforeEach();
    Activity activity = newActivity();
    ChildControllersRegistry childRegistry = new ChildControllersRegistry();
    root = spy(new SimpleViewController(activity, childRegistry, "root", new Options()));
    FrameLayout contentLayout = new FrameLayout(activity);
    FrameLayout rootLayout = new FrameLayout(activity);
    rootLayout.addView(root.getView());
    modalsLayout = new CoordinatorLayout(activity);
    contentLayout.addView(rootLayout);
    contentLayout.addView(modalsLayout);
    activity.setContentView(contentLayout);
    animator = spy(new ModalAnimator(activity));
    uut = new ModalPresenter(animator);
    uut.setModalsLayout(modalsLayout);
    uut.setRootLayout(rootLayout);
    modal1 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_1, new Options()));
    modal2 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_2, new Options()));
}
Also used : CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) Options(com.reactnativenavigation.options.Options) FrameLayout(android.widget.FrameLayout) Activity(android.app.Activity) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController)

Example 14 with SimpleViewController

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

the class ModalStackTest method beforeEach.

@Override
public void beforeEach() {
    super.beforeEach();
    activity = newActivity();
    childRegistry = new ChildControllersRegistry();
    root = new SimpleViewController(activity, childRegistry, "root", new Options());
    FrameLayout rootLayout = new FrameLayout(activity);
    CoordinatorLayout modalsLayout = new CoordinatorLayout(activity);
    FrameLayout contentLayout = new FrameLayout(activity);
    contentLayout.addView(rootLayout);
    contentLayout.addView(modalsLayout);
    activity.setContentView(contentLayout);
    animator = spy(new ModalAnimatorMock(activity));
    presenter = spy(new ModalPresenter(animator));
    uut = new ModalStack(activity, presenter);
    uut.setModalsLayout(modalsLayout);
    uut.setRootLayout(rootLayout);
    emitter = Mockito.mock(EventEmitter.class);
    uut.setEventEmitter(emitter);
    modal1 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_1, new Options()));
    modal2 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_2, new Options()));
    modal3 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_3, new Options()));
    modal4 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_4, new Options()));
    stack = TestUtils.newStackController(activity).setChildren(modal4).build();
}
Also used : CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) TransitionAnimationOptions(com.reactnativenavigation.options.TransitionAnimationOptions) Options(com.reactnativenavigation.options.Options) EventEmitter(com.reactnativenavigation.react.events.EventEmitter) FrameLayout(android.widget.FrameLayout) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) SimpleViewController(com.reactnativenavigation.mocks.SimpleViewController)

Example 15 with SimpleViewController

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

the class OverlayManagerTest method beforeEach.

@Override
public void beforeEach() {
    super.beforeEach();
    Activity activity = newActivity();
    contentLayout = new FrameLayout(activity);
    contentLayout.layout(0, 0, 1000, 1000);
    activity.setContentView(contentLayout);
    overlayContainer = new FrameLayout(activity);
    contentLayout.addView(overlayContainer);
    ChildControllersRegistry childRegistry = new ChildControllersRegistry();
    overlay1 = spy(new SimpleViewController(activity, childRegistry, OVERLAY_ID_1, new Options()));
    overlay2 = spy(new SimpleViewController(activity, childRegistry, OVERLAY_ID_2, new Options()));
    uut = new OverlayManager();
}
Also used : Options(com.reactnativenavigation.options.Options) FrameLayout(android.widget.FrameLayout) Activity(android.app.Activity) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) 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