/** * Source values for a column binding for a simple feature after the previous column has been * deleted. */ @Test public void testSimpleColumnBindingAfterDelete() { postMouse(myTable, 0 + myViewerBinding.getFirstTableColumnOffset(), 0); final IColumnBindingCellInformation ci = myViewerBinding.getCell(0, myViewerBinding.getList().get(1)); assertNotNull(ci); /* * When the element is deleted, the current selected cell is changed, and this must be * monitored. */ final MySourceProviderListener listener = new MySourceProviderListener(); try { myProvider.addSourceProviderListener(listener); myContact1.setShop(null); yield(); } finally { myProvider.removeSourceProviderListener(listener); } assertSource(Constants.SOURCES_THE_MANAGER, IManager.Factory.getManager()); assertSource(Constants.SOURCES_ACTIVE_CONTEXT, myContext); assertSource(Constants.SOURCES_ACTIVE_CONTAINER_BINDING, myViewerBinding); assertSource(Constants.SOURCES_ACTIVE_BINDING, ci.getLabelBinding()); assertSource(Constants.SOURCES_ACTIVE_BINDING_RO, false); assertSource(Constants.SOURCES_ACTIVE_BINDING_TYPE, ""); assertSource(Constants.SOURCES_ACTIVE_BINDING_MODEL_OBJECT, myContact2); assertSource( Constants.SOURCES_ACTIVE_BINDING_FEATURE, IMOAOPackage.Literals.NAMED_OBJECT__NAME); assertSource(Constants.SOURCES_ACTIVE_BINDING_VALUE, myContact2.getName()); assertSource(Constants.SOURCES_ACTIVE_BINDING_VALUE_DISPLAY, myContact2.getName()); }
/** * Tests that the names in the current state are exactly the same as the ones in the reported * sources. */ @Test public void testNames() { final Map<String, Object> currentState = myProvider.getCurrentState(); final List<String> providedSourceNames = Arrays.asList(myProvider.getProvidedSourceNames()); for (final String n : providedSourceNames) { assertTrue("Variable " + n, currentState.containsKey(n)); } for (final String n : currentState.keySet()) { assertTrue("Variable " + n, providedSourceNames.contains(n)); } assertEquals(providedSourceNames.size(), currentState.size()); }
/** * Tests that the {@link ISourceProviderService} return the correct source provider for all the * sources offered. */ @Test public void testISourceProviderServiceNames() { final Map<String, Object> currentState = myProvider.getCurrentState(); final IServiceLocator locator = myContext.getServiceLocator(); final ISourceProviderService sourceProviders = (ISourceProviderService) locator.getService(ISourceProviderService.class); for (final String n : myProvider.getProvidedSourceNames()) { assertEquals( "Wrong source provider for " + n, myProvider, sourceProviders.getSourceProvider(n)); } }
/** Tests that the services extension point for {@link BindingSourceProvider} is correct. */ @Test public void testServicesExtension() { boolean found = false; final Map<String, Object> currentState = myProvider.getCurrentState(); final List<String> providedSourceNames = Arrays.asList(myProvider.getProvidedSourceNames()); final IExtensionRegistry registry = Platform.getExtensionRegistry(); for (final IConfigurationElement ce : registry.getConfigurationElementsFor("org.eclipse.ui.services")) { if (!ce.getContributor().getName().equals(Activator.ID)) { continue; } assertEquals("sourceProvider", ce.getName()); if (!ce.getAttribute("provider").equals(BindingSourceProvider.class.getName())) { continue; } /* * Only one declaration */ assertTrue(!found); found = true; final IConfigurationElement[] children = ce.getChildren("variable"); final List<String> childrenVariables = new ArrayList<String>(); for (final IConfigurationElement cce : children) { final String name = cce.getAttribute("name"); assertFalse(name + " listed twice", childrenVariables.contains(name)); childrenVariables.add(name); assertTrue(name + " not in current state", currentState.containsKey(name)); if (name.equals(Constants.SOURCES_THE_MANAGER)) { assertEquals(name + " priority", "workbench", cce.getAttribute("priorityLevel")); } else { assertEquals(name + " priority", "activeSite", cce.getAttribute("priorityLevel")); } } for (final String name : childrenVariables) { assertTrue(name + " not in provider names", providedSourceNames.contains(name)); } assertEquals(providedSourceNames.size(), children.length); } assertTrue(found); }
public void assertSource(String name, Object value) { final Map<String, Object> currentState = myProvider.getCurrentState(); assertEquals("variable " + name, value, currentState.get(name)); }