private SplashScreenActivity makeSplashScreenThatIntercepts(final PlaceRequest place, final boolean enabled) { String splashActivityName = place.getIdentifier() + "!Splash"; SplashScreenActivity splashScreenActivity = mock(SplashScreenActivity.class); when(splashScreenActivity.isEnabled()).thenReturn(enabled); when(splashScreenActivity.intercept(place)).thenReturn(true); when(splashScreenActivity.getPlace()).thenReturn(new DefaultPlaceRequest(splashActivityName)); makeSingletonBean(SplashScreenActivity.class, splashScreenActivity); return splashScreenActivity; }
private SplashScreenActivity makeSplashScreenThatIntercepts(final PlaceRequest place, final boolean enabled) { String splashActivityName = place.getIdentifier() + "!Splash"; SplashScreenActivity splashScreenActivity = mock(SplashScreenActivity.class); when(splashScreenActivity.isEnabled()).thenReturn(enabled); when(splashScreenActivity.intercept(place)).thenReturn(true); when(splashScreenActivity.getPlace()).thenReturn(new DefaultPlaceRequest(splashActivityName)); makeSingletonBean(SplashScreenActivity.class, splashScreenActivity); return splashScreenActivity; }
@Test public void shouldNotGetConfusedAboutSplashScreensWithSamePlaceAsTheirScreen() throws Exception { List<SplashScreenActivity> splashScreenList = new ArrayList<SplashScreenActivity>(); SplashScreenActivity expectedSplashScreenActivity = makeEnabledSplashScreenThatIntercepts(kansas); when(expectedSplashScreenActivity.getPlace()).thenReturn(kansas); splashScreenList.add(expectedSplashScreenActivity); when(activityBeansCache.getSplashScreens()).thenReturn(splashScreenList); // this loads the regular kansas activity (not the splash screen) into the activityBeansCache activityManager.getActivity(kansas); SplashScreenActivity splashScreenActivity = activityManager.getSplashScreenInterceptor(kansas); // this must not get confused even though expectedSplashScreenActivity and kansasActivity both have the same PlaceRequest activityManager.destroyActivity(splashScreenActivity); verify(expectedSplashScreenActivity, times(1)).onShutdown(); assertFalse(activityManager.isStarted(expectedSplashScreenActivity)); // never try to destroy singleton beans! verify(iocManager, never()).destroyBean(expectedSplashScreenActivity); }
@Test public void shouldNotGetConfusedAboutSplashScreensWithSamePlaceAsTheirScreen() throws Exception { List<SplashScreenActivity> splashScreenList = new ArrayList<SplashScreenActivity>(); SplashScreenActivity expectedSplashScreenActivity = makeEnabledSplashScreenThatIntercepts(kansas); when(expectedSplashScreenActivity.getPlace()).thenReturn(kansas); splashScreenList.add(expectedSplashScreenActivity); when(activityBeansCache.getSplashScreens()).thenReturn(splashScreenList); // this loads the regular kansas activity (not the splash screen) into the activityBeansCache activityManager.getActivity(kansas); SplashScreenActivity splashScreenActivity = activityManager.getSplashScreenInterceptor(kansas); // this must not get confused even though expectedSplashScreenActivity and kansasActivity both have the same PlaceRequest activityManager.destroyActivity(splashScreenActivity); verify(expectedSplashScreenActivity, times(1)).onShutdown(); assertFalse(activityManager.isStarted(expectedSplashScreenActivity)); // never try to destroy singleton beans! verify(iocManager, never()).destroyBean(expectedSplashScreenActivity); }