/** * 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()); }
@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)); }
@Test public void testProperSplashScreenShutdownOnPartClose() throws Exception { PlaceRequest oz = new DefaultPlaceRequest("oz"); WorkbenchScreenActivity ozActivity = mock(WorkbenchScreenActivity.class); when(activityManager.getActivities(oz)).thenReturn(singleton((Activity) ozActivity)); final SplashScreenActivity lollipopGuildActivity = mock(SplashScreenActivity.class); when(lollipopGuildActivity.isType(ActivityResourceType.SPLASH.name())).thenReturn(true); when(activityManager.getSplashScreenInterceptor(oz)).thenReturn(lollipopGuildActivity); when(ozActivity.isType(ActivityResourceType.SCREEN.name())).thenReturn(true); placeManager.goTo(oz, (PanelDefinition) null); placeManager.closePlace(oz); assertTrue(placeManager.getActiveSplashScreens().isEmpty()); verify(lollipopGuildActivity).closeIfOpen(); // splash screens are Application Scoped, but we still "destroy" them (activity manager will call their onShutdown) verify(activityManager).destroyActivity(lollipopGuildActivity); }
@Test public void testProperSplashScreenShutdownOnPartClose() throws Exception { PlaceRequest oz = new DefaultPlaceRequest("oz"); WorkbenchScreenActivity ozActivity = mock(WorkbenchScreenActivity.class); when(activityManager.getActivities(oz)).thenReturn(singleton((Activity) ozActivity)); final SplashScreenActivity lollipopGuildActivity = mock(SplashScreenActivity.class); when(lollipopGuildActivity.isType(ActivityResourceType.SPLASH.name())).thenReturn(true); when(activityManager.getSplashScreenInterceptor(oz)).thenReturn(lollipopGuildActivity); when(ozActivity.isType(ActivityResourceType.SCREEN.name())).thenReturn(true); placeManager.goTo(oz, (PanelDefinition) null); placeManager.closePlace(oz); assertTrue(placeManager.getActiveSplashScreens().isEmpty()); verify(lollipopGuildActivity).closeIfOpen(); // splash screens are Application Scoped, but we still "destroy" them (activity manager will call their onShutdown) verify(activityManager).destroyActivity(lollipopGuildActivity); }
when(activityManager.getSplashScreenInterceptor(perspectivePlace)).thenReturn(splashScreenActivity); when(perspectiveActivity.isType(ActivityResourceType.PERSPECTIVE.name())).thenReturn(true); when(splashScreenActivity.isType(ActivityResourceType.SPLASH.name())).thenReturn(true);
when(activityManager.getSplashScreenInterceptor(perspectivePlace)).thenReturn(splashScreenActivity); when(perspectiveActivity.isType(ActivityResourceType.PERSPECTIVE.name())).thenReturn(true); when(splashScreenActivity.isType(ActivityResourceType.SPLASH.name())).thenReturn(true);
when(activityManager.getSplashScreenInterceptor(perspectivePlace)).thenReturn(splashScreenActivity1); when(splashScreenActivity1.isType(ActivityResourceType.SPLASH.name())).thenReturn(true); when(activityManager.getSplashScreenInterceptor(kansas)).thenReturn(splashScreenActivity2); when(activityManager.getActivities(kansas)).thenReturn(singleton((Activity) kansasActivity)); when(splashScreenActivity2.isType(ActivityResourceType.SPLASH.name())).thenReturn(true);
when(activityManager.getSplashScreenInterceptor(perspectivePlace)).thenReturn(splashScreenActivity1); when(splashScreenActivity1.isType(ActivityResourceType.SPLASH.name())).thenReturn(true); when(activityManager.getSplashScreenInterceptor(kansas)).thenReturn(splashScreenActivity2); when(activityManager.getActivities(kansas)).thenReturn(singleton((Activity) kansasActivity)); when(splashScreenActivity2.isType(ActivityResourceType.SPLASH.name())).thenReturn(true);