/** * Closes the splash screen associated with the given place request, if any. Internally, this method should be * invoked every time a part or perspective is removed from the workbench (cleaning up after the corresponding * earlier call to {@link #addSplashScreenFor(PlaceRequest)}. * @param place the place whose opening may have triggered a splash screen to launch. Must not be null. */ private void closeSplashScreen(final PlaceRequest place) { SplashScreenActivity splashScreenActivity = availableSplashScreens.remove(place.getIdentifier()); if (splashScreenActivity != null) { try { splashScreenActivity.closeIfOpen(); } catch (Exception ex) { lifecycleErrorHandler.handle(splashScreenActivity, LifecyclePhase.CLOSE, ex); } activityManager.destroyActivity(splashScreenActivity); newSplashScreenActiveEvent.fire(new NewSplashScreenActiveEvent()); } }
@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); }
verify(splashScreenActivity1).closeIfOpen(); verify(splashScreenActivity2).closeIfOpen();
verify(splashScreenActivity1).closeIfOpen(); verify(splashScreenActivity2).closeIfOpen();