Search in sources :

Example 1 with TitleBarButtonCreatorMock

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

the class TestUtils method newStackController.

public static StackControllerBuilder newStackController(Activity activity) {
    TopBarController topBarController = new TopBarController() {

        @Override
        protected TopBar createTopBar(@NonNull Context context, @NonNull StackLayout stackLayout) {
            TopBar topBar = super.createTopBar(context, stackLayout);
            topBar.layout(0, 0, 1000, UiUtils.getTopBarHeight(context));
            return topBar;
        }
    };
    return new StackControllerBuilder(activity, Mockito.mock(EventEmitter.class)).setId("stack" + CompatUtils.generateViewId()).setChildRegistry(new ChildControllersRegistry()).setTopBarController(topBarController).setStackPresenter(new StackPresenter(activity, new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewCreatorMock(), new TitleBarButtonCreatorMock(), new IconResolver(activity, new ImageLoader()), new TypefaceLoaderMock(), new RenderChecker(), new Options())).setInitialOptions(new Options());
}
Also used : Context(android.content.Context) Options(com.reactnativenavigation.options.Options) IconResolver(com.reactnativenavigation.viewcontrollers.stack.topbar.button.IconResolver) ChildControllersRegistry(com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry) TitleBarButtonCreatorMock(com.reactnativenavigation.mocks.TitleBarButtonCreatorMock) TypefaceLoaderMock(com.reactnativenavigation.mocks.TypefaceLoaderMock) TopBarBackgroundViewCreatorMock(com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock) TitleBarReactViewCreatorMock(com.reactnativenavigation.mocks.TitleBarReactViewCreatorMock) NonNull(androidx.annotation.NonNull) StackLayout(com.reactnativenavigation.views.stack.StackLayout) StackPresenter(com.reactnativenavigation.viewcontrollers.stack.StackPresenter) TopBar(com.reactnativenavigation.views.stack.topbar.TopBar) StackControllerBuilder(com.reactnativenavigation.viewcontrollers.stack.StackControllerBuilder) ImageLoader(com.reactnativenavigation.utils.ImageLoader) TopBarController(com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController) RenderChecker(com.reactnativenavigation.utils.RenderChecker)

Example 2 with TitleBarButtonCreatorMock

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

the class TitleBarButtonControllerTest method beforeEach.

@Override
public void beforeEach() {
    Activity activity = newActivity();
    titleBar = new ButtonBar(activity);
    ButtonOptions button = createComponentButton();
    uut = new ButtonController(activity, new ButtonPresenter(activity, button, new IconResolver(activity, ImageLoaderMock.mock())), button, new TitleBarButtonCreatorMock(), Mockito.mock(ButtonController.OnClickListener.class));
}
Also used : ButtonOptions(com.reactnativenavigation.options.ButtonOptions) ButtonController(com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonController) ButtonBar(com.reactnativenavigation.views.stack.topbar.titlebar.ButtonBar) ButtonPresenter(com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonPresenter) IconResolver(com.reactnativenavigation.viewcontrollers.stack.topbar.button.IconResolver) Activity(android.app.Activity) TitleBarButtonCreatorMock(com.reactnativenavigation.mocks.TitleBarButtonCreatorMock)

Example 3 with TitleBarButtonCreatorMock

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

the class TopBarButtonControllerTest method beforeEach.

@Override
public void beforeEach() {
    button = new ButtonOptions();
    final Activity activity = newActivity();
    TitleBarButtonCreatorMock buttonCreatorMock = new TitleBarButtonCreatorMock();
    stackController = spy(TestUtils.newStackController(activity).build());
    stackController.getView().layout(0, 0, 1080, 1920);
    stackController.getTopBar().layout(0, 0, 1080, 200);
    getTitleBar().layout(0, 0, 1080, 200);
    optionsPresenter = spy(new ButtonPresenter(activity, button, new IconResolverFake(activity, ImageLoaderMock.mock())));
    uut = new ButtonController(activity, optionsPresenter, button, buttonCreatorMock, (buttonId) -> {
    });
    stackController.ensureViewIsCreated();
}
Also used : IconResolverFake(com.reactnativenavigation.fakes.IconResolverFake) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Text(com.reactnativenavigation.options.params.Text) Java6Assertions.assertThat(org.assertj.core.api.Java6Assertions.assertThat) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Colour(com.reactnativenavigation.options.params.Colour) ButtonBar(com.reactnativenavigation.views.stack.topbar.titlebar.ButtonBar) Mockito.spy(org.mockito.Mockito.spy) MenuItem(android.view.MenuItem) TitleBarButtonCreatorMock(com.reactnativenavigation.mocks.TitleBarButtonCreatorMock) NullText(com.reactnativenavigation.options.params.NullText) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) Bool(com.reactnativenavigation.options.params.Bool) ButtonOptions(com.reactnativenavigation.options.ButtonOptions) BaseTest(com.reactnativenavigation.BaseTest) ButtonPresenter(com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonPresenter) Number(com.reactnativenavigation.options.params.Number) ButtonController(com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonController) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) Mockito.verify(org.mockito.Mockito.verify) Color(android.graphics.Color) IconResolverFake(com.reactnativenavigation.fakes.IconResolverFake) ThemeColour(com.reactnativenavigation.options.params.ThemeColour) TestUtils(com.reactnativenavigation.TestUtils) Activity(android.app.Activity) ImageLoaderMock(com.reactnativenavigation.mocks.ImageLoaderMock) ButtonOptions(com.reactnativenavigation.options.ButtonOptions) ButtonController(com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonController) ButtonPresenter(com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonPresenter) Activity(android.app.Activity) TitleBarButtonCreatorMock(com.reactnativenavigation.mocks.TitleBarButtonCreatorMock)

Aggregations

TitleBarButtonCreatorMock (com.reactnativenavigation.mocks.TitleBarButtonCreatorMock)3 Activity (android.app.Activity)2 ButtonOptions (com.reactnativenavigation.options.ButtonOptions)2 ButtonController (com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonController)2 ButtonPresenter (com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonPresenter)2 IconResolver (com.reactnativenavigation.viewcontrollers.stack.topbar.button.IconResolver)2 ButtonBar (com.reactnativenavigation.views.stack.topbar.titlebar.ButtonBar)2 Context (android.content.Context)1 Color (android.graphics.Color)1 MenuItem (android.view.MenuItem)1 NonNull (androidx.annotation.NonNull)1 BaseTest (com.reactnativenavigation.BaseTest)1 TestUtils (com.reactnativenavigation.TestUtils)1 IconResolverFake (com.reactnativenavigation.fakes.IconResolverFake)1 ImageLoaderMock (com.reactnativenavigation.mocks.ImageLoaderMock)1 TitleBarReactViewCreatorMock (com.reactnativenavigation.mocks.TitleBarReactViewCreatorMock)1 TopBarBackgroundViewCreatorMock (com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock)1 TypefaceLoaderMock (com.reactnativenavigation.mocks.TypefaceLoaderMock)1 Options (com.reactnativenavigation.options.Options)1 Bool (com.reactnativenavigation.options.params.Bool)1