@Ignore("Travis does not like this one, rather a shame that") @Test public void addANumericScannable() throws Exception { SWTBotTreeItem item = bot.tree(0).getTreeItem("Experimental Conditions"); item.select(); bot.getDisplay().syncExec(()->viewer.addNode()); SWTBotCCombo combo = bot.ccomboBox(0); assertNotNull(combo); combo.setSelection("a"); assertEquals("a", item.cell(1, 0)); assertEquals("10.0 mm", item.cell(1, 1)); }
@Ignore("Travis does not like this one, rather a shame that") @Test public void addAStringScannable() throws Exception { SWTBotTreeItem item = bot.tree(0).getTreeItem("Experimental Conditions"); item.select(); bot.getDisplay().syncExec(()->viewer.addNode()); SWTBotCCombo combo = bot.ccomboBox(0); assertNotNull(combo); combo.setSelection("portshutter"); assertEquals("portshutter", item.cell(1, 0)); assertEquals("Open", item.cell(1, 1)); }
private void selectComboPathGenerator (SWTBotTableItem tableItem,String path) { DefaultCondition condition = new DefaultCondition() { @Override public boolean test() throws Exception { try { tableItem.click(1); SWTBotCCombo combo = bot.ccomboBoxWithId(ModelPathGenerator.GW4E_LAUNCH_CONFIGURATION_PATH_GENERATOR_ID,ModelPathGenerator.GW4E_LAUNCH_CONFIGURATION_PATH_GENERATOR_COMBO_EDITOR); combo.setSelection(path); return true; } catch (Exception e) { return false; } } @Override public String getFailureMessage() { return "Unable to open the path generator combo"; } }; bot.waitUntil(condition); }
/** * Gets the item count. * * @param control * the control * @return the item count */ private static int getItemCount(final AbstractSWTBotControl<?> control) { int itemCount; if (control instanceof SWTBotCCombo) { itemCount = ((SWTBotCCombo) control).itemCount(); } else if (control instanceof SWTBotList) { itemCount = ((SWTBotList) control).itemCount(); } else if (control instanceof SWTBotCombo) { itemCount = ((SWTBotCombo) control).itemCount(); } else { throw new WrappedException("Control not supported", null); } return itemCount; }
public void setItem(String value) { selectPart(null); selectTab(null, PROPERTIES); SWTBotCCombo combo = bot.ccomboBoxWithId( WIDGET_ID, WIDGET_COMBO_EDGE); combo.setSelection(value); }
public String getItem() { selectPart(null); selectTab(null, PROPERTIES); SWTBotCCombo combo = bot.ccomboBoxWithId( WIDGET_ID, WIDGET_COMBO_EDGE); return combo.getText(); }
@Ignore("Cannot get the click to work...") @Test public void checkValuesTree4() throws Exception { ControlTree ct = getControlTree("control_tree4.xml"); bot.getDisplay().syncExec(()->viewer.setControlTree(ct)); assertEquals(2, bot.tree(0).columnCount()); assertEquals(1, bot.tree(0).rowCount()); assertEquals("Hutch", bot.tree(0).cell(0, 0)); SWTBotTreeItem item = bot.tree(0).getTreeItem("Hutch"); List<String> children = item.getNodes(); assertEquals(Arrays.asList("Port Shutter"), children); assertEquals("Port Shutter", item.cell(0, 0)); assertEquals("Open", item.cell(0, 1)); SWTBotTreeItem node = item.getNode("Port Shutter"); node.click(1); // Cannot get the click to work... SWTBotCCombo combo = bot.ccomboBox(0); combo.setSelection(1); // Closed bot.getDisplay().syncExec(()->viewer.applyEditorValue()); assertEquals("Closed", item.cell(0, 1)); node.click(1); combo = bot.ccomboBox(0); combo.setSelection(0); // Open bot.getDisplay().syncExec(()->viewer.applyEditorValue()); assertEquals("Open", item.cell(0, 1)); }
/** * Returns the full text of the first CcomboItem found with the given prefix. * <p> * <em>Note</em>: Throws an AssertionError if the item could not be found. * </p> * * @param ccombo * the ccomboBox to search in, must not be {@code null} * @param prefix * the prefix of the item to search for, must not be {@code null} * @return the full name of the item as string, never {@code null} */ public static String getCcomboItemText(final SWTBotCCombo ccombo, final String prefix) { Assert.isNotNull(ccombo, "ccombo"); Assert.isNotNull(prefix, "prefix"); for (String ccomboItem : ccombo.items()) { if (ccomboItem.startsWith(prefix)) { return ccomboItem; } } throw new AssertionFailedException(NLS.bind("Must have a CcomboItem named ''{0}''.", prefix)); }