Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 295003 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/e4/ui/tests/application/EPartServiceTest.java (+53 lines)
Lines 633-638 Link Here
633
		assertEquals(partBackB, partServiceB.getActivePart());
633
		assertEquals(partBackB, partServiceB.getActivePart());
634
	}
634
	}
635
635
636
	public void testSwitchWindows() {
637
		// create an application with two windows
638
		MApplication application = MApplicationFactory.eINSTANCE
639
				.createApplication();
640
		MWindow window1 = MApplicationFactory.eINSTANCE.createWindow();
641
		MWindow window2 = MApplicationFactory.eINSTANCE.createWindow();
642
		application.getChildren().add(window1);
643
		application.getChildren().add(window2);
644
645
		// place a part in the first window
646
		MPart part = MApplicationFactory.eINSTANCE.createPart();
647
		window1.getChildren().add(part);
648
649
		// setup the context
650
		applicationContext.set(MApplication.class.getName(), application);
651
		application.setContext(applicationContext);
652
653
		// render the windows
654
		engine.createGui(window1);
655
		engine.createGui(window2);
656
657
		EPartService windowService1 = (EPartService) window1.getContext().get(
658
				EPartService.class.getName());
659
		EPartService windowService2 = (EPartService) window2.getContext().get(
660
				EPartService.class.getName());
661
662
		assertNotNull(windowService1);
663
		assertNotNull(windowService2);
664
665
		assertNull("There should be nothing active in the first window",
666
				windowService1.getActivePart());
667
		assertNull("There should be nothing active in the second window",
668
				windowService2.getActivePart());
669
670
		// activate the part
671
		windowService1.activate(part);
672
673
		assertEquals("The part should have been activated", part,
674
				windowService1.getActivePart());
675
		assertNull("The second window has no parts, this should be null",
676
				windowService2.getActivePart());
677
678
		// now move the part over from the first window to the second window
679
		window2.getChildren().add(part);
680
		// activate the part
681
		windowService2.activate(part);
682
683
		assertNull("No parts in this window, this should be null",
684
				windowService1.getActivePart());
685
		assertEquals("We activated it just now, this should be active", part,
686
				windowService2.getActivePart());
687
	}
688
636
	private MApplication createApplication(String partId) {
689
	private MApplication createApplication(String partId) {
637
		return createApplication(new String[] { partId });
690
		return createApplication(new String[] { partId });
638
	}
691
	}

Return to bug 295003