Bug 329482 Uninstantiated part may be rendered when closing another part in the same stack
1. Activate the 'Javadoc' view. 2. Activate the 'Package Explorer' view. 3. Shutdown. 4. Restart. 5. Ctrl+3 > Properties 6. Hide the 'Properties' view. 7. Now the 'Problems' view is the selected element. It should be the 'Javadoc' view.
tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/application/EPartServiceTest.java
MPartStack partStack = BasicFactoryImpl.eINSTANCE.createPartStack();
		perspectiveA.getChildren().add(partStack);
		MPart partB = BasicFactoryImpl.eINSTANCE.createPart();
		partStack.getChildren().add(partB);
		MPart partC = BasicFactoryImpl.eINSTANCE.createPart();
		partStack.getChildren().add(partC);
		partStack.setSelectedElement(partC);
		MPerspective perspectiveB = AdvancedFactoryImpl.eINSTANCE
				.createPerspective();
		perspectiveStack.getChildren().add(perspectiveB);
		MPlaceholder areaPlaceholderB = AdvancedFactoryImpl.eINSTANCE
				.createPlaceholder();
		areaPlaceholderB.setRef(area);
		perspectiveB.getChildren().add(areaPlaceholderB);
		perspectiveB.setSelectedElement(areaPlaceholderB);
		initialize(applicationContext, application);
		getEngine().createGui(window);
		EPartService partService = window.getContext().get(EPartService.class);
		partService.activate(partA);
		partService.switchPerspective(perspectiveB);
		partService.hidePart(partA);
		partService.switchPerspective(perspectiveA);
		assertEquals(partC, partService.getActivePart());
	}
	/**
	 * Setup a shared part in two perspectives, perspectiveA and perspectiveB
	 * with the part being in a detached window in perspectiveB's case.
	 * <p>
	 * First activate the part in perspectiveA. Switching to perspectiveB should
	 * not cause any problems.