/** * Test the method on a model with only one folder. Test method for {@link * org.eclipse.papyrus.infra.core.sasheditor.internal.SashWindowsContainer#getActiveEditor()}. Use * new implementation to populate contentProvider * * @throws PagesModelException */ @Test public void testGetVisiblePagesOneFoler() throws PagesModelException { // Create populated content provider SimpleSashWindowsContentProvider contentProvider = new SimpleSashWindowsContentProvider(); SimpleSashWindowContentProviderUtils helper = new SimpleSashWindowContentProviderUtils(contentProvider); // define how to populate contentProvider IModelExp expr = folder("f1", page("p11"), page("p12"), page("p13")); // Try to create the model helper.createModel(expr); // Get the references Map<String, Object> models = helper.queryModel(expr); // Create the container SashWindowsContainer container = createSashWindowsContainer(contentProvider); // Get visible pages List<IPage> pages = container.getVisiblePages(); // Build a list of raw models List<Object> visibleModels = new ArrayList<Object>(); for (IPage page : pages) { visibleModels.add(page.getRawModel()); } assertEquals("1 pages visible", 1, pages.size()); assertTrue("contains active page from folder 1", visibleModels.contains(models.get("p11"))); // Check orders assertEquals(models.get("p11"), pages.get(0).getRawModel()); }
/** * Test the lookup of a page by its raw model Test method for {@link * SashWindowsContainer#lookupModelPage(Object)} */ @Test public void testlookupModelPage() { // Create SimpleSashWindowsContentProvider contentProvider = new SimpleSashWindowsContentProvider(); // Create pages and add them to the default folder List<IPageModel> models = new ArrayList<IPageModel>(); for (int i = 0; i < 2; i++) { IPageModel newModel = new MessagePartModel("model" + i); contentProvider.addPage(newModel); models.add(newModel); } // Create new folder ITabFolderModel folder = contentProvider.getCurrentTabFolder(); contentProvider.createFolder(folder, 1, folder, SWT.TOP); // Get the active editor SashWindowsContainer container = createSashWindowsContainer(contentProvider); Object model = models.get(1); IPage foundPage = container.lookupModelPage(model); assertEquals("Corresponding page is found", foundPage.getRawModel(), model); }