/** * Finds and opens the splash screen for the given place, if such a splash screen exists. The splash screen might * not actually display; each splash screen keeps track of its own preference setting for whether or not the user * wants to see it. * <p/> * Whether or not it chooses to display itself, the splash screen will be recorded in * {@link #availableSplashScreens} for lookup (for example, see {@link SplashScreenMenuPresenter}) and later disposal. * Internally, this method should be called every time any part or perspective is added to the workbench, and called * again when that part or perspective is removed. * @param place the place that has just been added to the workbench. Must not be null. */ private void addSplashScreenFor(final PlaceRequest place) { final SplashScreenActivity splashScreen = activityManager.getSplashScreenInterceptor(place); if (splashScreen != null) { availableSplashScreens.put(place.getIdentifier(), splashScreen); try { splashScreen.onOpen(); } catch (Exception ex) { availableSplashScreens.remove(place.getIdentifier()); lifecycleErrorHandler.handle(splashScreen, LifecyclePhase.OPEN, ex); activityManager.destroyActivity(splashScreen); return; } } newSplashScreenActiveEvent.fire(new NewSplashScreenActiveEvent()); }
/** * Ensures that splash screens can't be launched on their own (they should only launch as a side effect of launching * a place that they intercept). This test came from the original test suite, and may not be all that relevant * anymore: it assumes that the ActivityManager might resolve a PlaceRequest to a SplashScreenActivity, and this is * currently not in the ActivityManager contract. */ @Test public void testSplashScreenActivityShouldNotLaunchOnItsOwn() throws Exception { final PlaceRequest somewhere = new DefaultPlaceRequest("Somewhere"); final SplashScreenActivity splashScreenActivity = mock(SplashScreenActivity.class); when(activityManager.getActivities(somewhere)).thenReturn(singleton((Activity) splashScreenActivity)); placeManager.goTo(somewhere); verify(splashScreenActivity, never()).onStartup(eq(somewhere)); verify(splashScreenActivity, never()).onOpen(); verify(newSplashScreenActiveEvent, never()).fire(any(NewSplashScreenActiveEvent.class)); assertFalse(placeManager.getActiveSplashScreens().contains(splashScreenActivity)); }
/** * Ensures that splash screens can't be launched on their own (they should only launch as a side effect of launching * a place that they intercept). This test came from the original test suite, and may not be all that relevant * anymore: it assumes that the ActivityManager might resolve a PlaceRequest to a SplashScreenActivity, and this is * currently not in the ActivityManager contract. */ @Test public void testSplashScreenActivityShouldNotLaunchOnItsOwn() throws Exception { final PlaceRequest somewhere = new DefaultPlaceRequest("Somewhere"); final SplashScreenActivity splashScreenActivity = mock(SplashScreenActivity.class); when(activityManager.getActivities(somewhere)).thenReturn(singleton((Activity) splashScreenActivity)); placeManager.goTo(somewhere); verify(splashScreenActivity, never()).onStartup(eq(somewhere)); verify(splashScreenActivity, never()).onOpen(); verify(newSplashScreenActiveEvent, never()).fire(any(NewSplashScreenActiveEvent.class)); assertFalse(placeManager.getActiveSplashScreens().contains(splashScreenActivity)); }
@Test public void testPartLaunchWithSplashScreen() throws Exception { PlaceRequest oz = new DefaultPlaceRequest("oz"); WorkbenchScreenActivity ozActivity = mock(WorkbenchScreenActivity.class); when(activityManager.getActivities(oz)).thenReturn(singleton((Activity) ozActivity)); when(ozActivity.isType(ActivityResourceType.SCREEN.name())).thenReturn(true); final SplashScreenActivity lollipopGuildActivity = mock(SplashScreenActivity.class); when(activityManager.getSplashScreenInterceptor(oz)).thenReturn(lollipopGuildActivity); when(lollipopGuildActivity.isType(ActivityResourceType.SPLASH.name())).thenReturn(true); placeManager.goTo(oz, (PanelDefinition) null); assertTrue(placeManager.getActiveSplashScreens().contains(lollipopGuildActivity)); verify(lollipopGuildActivity, never()).onStartup(any(PlaceRequest.class)); InOrder inOrder = inOrder(lollipopGuildActivity, newSplashScreenActiveEvent); inOrder.verify(lollipopGuildActivity).onOpen(); inOrder.verify(newSplashScreenActiveEvent).fire(any(NewSplashScreenActiveEvent.class)); }
@Test public void testPartLaunchWithSplashScreen() throws Exception { PlaceRequest oz = new DefaultPlaceRequest("oz"); WorkbenchScreenActivity ozActivity = mock(WorkbenchScreenActivity.class); when(activityManager.getActivities(oz)).thenReturn(singleton((Activity) ozActivity)); when(ozActivity.isType(ActivityResourceType.SCREEN.name())).thenReturn(true); final SplashScreenActivity lollipopGuildActivity = mock(SplashScreenActivity.class); when(activityManager.getSplashScreenInterceptor(oz)).thenReturn(lollipopGuildActivity); when(lollipopGuildActivity.isType(ActivityResourceType.SPLASH.name())).thenReturn(true); placeManager.goTo(oz, (PanelDefinition) null); assertTrue(placeManager.getActiveSplashScreens().contains(lollipopGuildActivity)); verify(lollipopGuildActivity, never()).onStartup(any(PlaceRequest.class)); InOrder inOrder = inOrder(lollipopGuildActivity, newSplashScreenActiveEvent); inOrder.verify(lollipopGuildActivity).onOpen(); inOrder.verify(newSplashScreenActiveEvent).fire(any(NewSplashScreenActiveEvent.class)); }
inOrder.verify(splashScreenActivity).onOpen(); inOrder.verify(newSplashScreenActiveEvent).fire(any(NewSplashScreenActiveEvent.class));
inOrder.verify(splashScreenActivity).onOpen(); inOrder.verify(newSplashScreenActiveEvent).fire(any(NewSplashScreenActiveEvent.class));