public void navigateBack(Object sender) { navigationManager.navigate(sender).back(); }
public void goBackToBasicView(Object sender) { navigationManager.navigate(sender).back(); }
protected void navigateBackByFragment() { navigationManager.navigate(this).back(); }
@Test public void should_not_fail_when_logger_is_set_trace() { navigationManager.logger = mock(Logger.class); when(navigationManager.logger.isTraceEnabled()).thenReturn(true); prepareLocationHistory(); navigationManager.navigate(this).back(); }
@Test public void should_not_raise_navigate_back_event_when_fast_back_navigate_from_null_location() throws Exception { // Arrange BackListener backListener = mock(BackListener.class); eventBusC.register(backListener); // Arrange navigationManager.navigate(this).back(Controller1.class); // Verify ArgumentCaptor<NavigationManager.Event.OnLocationBack> event = ArgumentCaptor.forClass(NavigationManager.Event.OnLocationBack.class); verify(backListener, times(0)).onEvent(event.capture()); }
@Test public void should_not_raise_navigate_back_event_when_navigate_to_unknown_location() throws Exception { // Arrange BackListener backListener = mock(BackListener.class); eventBusC.register(backListener); prepareLocationHistory(); // Arrange navigationManager.navigate(this).back(Controller.class); // Verify ArgumentCaptor<NavigationManager.Event.OnLocationBack> event = ArgumentCaptor.forClass(NavigationManager.Event.OnLocationBack.class); verify(backListener, times(0)).onEvent(event.capture()); }
@Test public void should_not_raise_navigate_back_event_when_navigate_to_first_location_from_the_first_location() throws Exception { // Arrange BackListener backListener = mock(BackListener.class); eventBusC.register(backListener); navigationManager.navigate(this).to(locId1); // Arrange Navigator navigator = navigationManager.navigate(this); navigator.back(null); // Verify ArgumentCaptor<NavigationManager.Event.OnLocationBack> event = ArgumentCaptor.forClass(NavigationManager.Event.OnLocationBack.class); verify(backListener, times(0)).onEvent(event.capture()); }
@Test public void should_post_app_exit_event_on_the_last_back_of_fast_back_navigation() { //mock the subscriber class AppExitListener { public void onEvent(NavigationManager.Event.OnAppExit event) { } } ArgumentCaptor<NavigationManager.Event.OnAppExit> event = ArgumentCaptor.forClass(NavigationManager.Event.OnAppExit.class); AppExitListener exitListener = mock(AppExitListener.class); eventBusC.register(exitListener); prepareLocationHistory(); reset(exitListener); navigationManager.navigate(this).back(null); verify(exitListener, times(0)).onEvent(event.capture()); navigateBackByFragment(); verify(exitListener, times(1)).onEvent(event.capture()); Assert.assertTrue(this == event.getValue().getSender()); }
@Test public void shouldBeAbleToNavigateBackToGivenLocation() throws Exception { //mock the subscriber BackListener backListener = mock(BackListener.class); eventBusC.register(backListener); prepareLocationHistory(); reset(backListener); navigationManager.navigate(this).back(locId2); ArgumentCaptor<NavigationManager.Event.OnLocationBack> event = ArgumentCaptor.forClass(NavigationManager.Event.OnLocationBack.class); verify(backListener).onEvent(event.capture()); assertEquals(event.getValue().getLastValue().getLocationId(), locId4.getName()); assertEquals(event.getValue().getCurrentValue().getLocationId(), locId2.getName()); NavLocation currentLoc = navigationManager.getModel().getCurrentLocation(); assertEquals(currentLoc.getLocationId(), locId2.getName()); assertEquals(currentLoc.getPreviousLocation().getLocationId(), locId1.getName()); assertEquals(currentLoc.getPreviousLocation().getPreviousLocation(), null); Assert.assertTrue(event.getValue().isFastRewind()); }
navigationManager.navigate(this).back(null);
navigationManager.navigate(this).back(null);
@Test public void shouldBeAbleToNavigateBackToFirstLocation() throws Exception { //mock the subscriber BackListener backListener = mock(BackListener.class); eventBusC.register(backListener); prepareLocationHistory(); reset(backListener); Navigator navigator = navigationManager.navigate(this); navigator.back(null); ArgumentCaptor<NavigationManager.Event.OnLocationBack> event = ArgumentCaptor.forClass(NavigationManager.Event.OnLocationBack.class); verify(backListener).onEvent(event.capture()); Assert.assertTrue(this == event.getValue().getSender()); Assert.assertTrue(navigator == event.getValue().getNavigator()); assertEquals(event.getValue().getLastValue().getLocationId(), locId4.getName()); assertEquals(event.getValue().getCurrentValue().getLocationId(), locId1.getName()); NavLocation currentLoc = navigationManager.getModel().getCurrentLocation(); assertEquals(currentLoc.getLocationId(), locId1.getName()); assertEquals(currentLoc.getPreviousLocation(), null); Assert.assertTrue(event.getValue().isFastRewind()); }
@Test public void should_skip_interim_location_on_back_navigation() throws Exception { //mock the subscriber BackListener backListener = mock(BackListener.class); eventBusC.register(backListener); prepareLocationHistory(); reset(backListener); navigationManager.navigate(this).to(locId1, new Forwarder().setInterim(true)); navigationManager.navigate(this).to(locId2, new Forwarder().setInterim(true)); navigationManager.navigate(this).back(); ArgumentCaptor<NavigationManager.Event.OnLocationBack> event = ArgumentCaptor.forClass(NavigationManager.Event.OnLocationBack.class); verify(backListener).onEvent(event.capture()); assertEquals(event.getValue().getLastValue().getLocationId(), locId2.getName()); assertEquals(event.getValue().getCurrentValue().getLocationId(), locId4.getName()); NavLocation currentLoc = navigationManager.getModel().getCurrentLocation(); assertEquals(currentLoc.getLocationId(), locId4.getName()); Assert.assertTrue(event.getValue().isFastRewind()); }