@Test public void checkApply() throws Exception { assertEquals(config.getDescription(), bot.table(0).cell(1, 1)); bot.table(0).click(1, 1); SWTBotText text = bot.text(0); assertNotNull(text); assertEquals("Hello World", text.getText()); assertEquals("Hello World", config.getDescription()); text.setText("Something else"); assertEquals("Hello World", config.getDescription()); assertEquals("Something else", text.getText()); text.display.syncExec(()->viewer.applyEditorValue()); assertEquals("Something else", config.getDescription()); assertEquals("Something else", bot.table(0).cell(1, 1)); }
public void validateRun (String configurationName,String projectName,String filepath,boolean printUnvisited,boolean verbose,String startElement,String generator) { SWTBotShell shell = openExistingRun (configurationName); SWTBotText projectText = shell.bot().textWithId(GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_TEXT_ID_PROJECT); assertEquals("Wrong project name",projectName,projectText.getText()); SWTBotText modelText = shell.bot().textWithId(GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_TEXT_ID_MODEL); assertEquals("Wrong model name",filepath,modelText.getText()); SWTBotCheckBox verboseButton = shell.bot().checkBoxWithId(GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_BUTTON_ID_VERBOSE); assertEquals("Wrong verbose value",verbose,verboseButton.isChecked()); SWTBotCheckBox unvisitedButton = shell.bot().checkBoxWithId(GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_BUTTON_ID_PRINT_UNVISITED); assertEquals("Wrong verbose value",verbose,unvisitedButton.isChecked()); SWTBotText startElementText = shell.bot().textWithId(GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_TEXT_ID_START_ELEMENT); assertEquals("Wrong start element",startElement,startElementText.getText()); SWTBotCombo generatorCombo = shell.bot().comboBoxWithId(GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_COMBO_PATH_GENERATOR_ID_MODEL); assertEquals("Wrong generator value",generator,generatorCombo.getText()); SWTBotButton closeButton = bot.button("Close"); closeButton.click(); bot.waitUntil(Conditions.shellCloses(shell)); }
private void addFourOrdersToOrdersOverview() { SWTBotView view = wbBot.partById(BaseSWTBotTest.PART_ID_ORDER_OVERVIEW); view.toolbarButton("Search Order").click(); SWTBotText text = bot.textWithLabel("&Order Number"); text.typeText("Order"); bot.buttonWithTooltip("Start Search").click(); // Select Item in Table SWTBotTable table = bot.table(); totalPersistedOrders = table.rowCount(); table.click(0, 5); bot.sleep(100); table.click(1, 5); bot.sleep(100); table.click(3, 5); bot.sleep(100); table.click(5, 5); bot.sleep(100); // click Finish bot.button("OK").click(); }
public static String getTheProgramArgsTextBox(SWTWorkbenchBot bot) { SwtBotUtils.print("Retrieve Args"); // When I open debug configuration SwtBotMenuActions.openDebugConfiguration(bot); // Focus on the Arguments Tab bot.cTabItem("Arguments").activate().setFocus(); // Get the program arguments SWTBotText programArgs = bot.textInGroup("Program arguments:"); String text = programArgs.getText(); // And close the debug configuration dialog bot.button("Close").click(); // And closing may cause a save change dialog SwtBotProjectDebug.closeSaveChangesDialogIfNeedBe(bot); SwtBotUtils.print("Retrieved Args"); return text; }
/** * 跳到指定文本段 * @param segNum * 文本段行号 */ public void gotoSeg(int segNum) { getNatTable(); nattable.click(1, 1); int targetRowIndex; if (isHorizontalLayout()) { targetRowIndex = segNum - 1; } else { targetRowIndex = (segNum - 1) * 2; } int selectedRowIndex = nattable.indexOfSelectedRow(positionOfTargetTextColumn()); // 先判断指定文本段是否已经被选中,若未被选中才继续 if (segNum != 1 && targetRowIndex != selectedRowIndex) { SWTBotText text = editorBot.text(lineNumLastValue); text.setText(String.valueOf(segNum)); text.pressShortcut(Keystrokes.LF); lineNumLastValue = String.valueOf(segNum); // 确认选中了指定文本段 bot.waitUntil(new IsSegmentSelected(this, targetRowIndex)); } }
@Test(expected=Exception.class) public void checkNameIneditable() throws Exception { // stage_x is mm and T is K. This tests picking up the units from the scannable! assertEquals(bbox.getFastAxisName(), bot.table(0).cell(0, 1)); bot.table(0).click(0, 1); // Make the file editor // This does pass if fast axis name is editable, I checked by doing that in BoundingBox. SWTBotText text = bot.performWithTimeout(()->bot.text(0), 500); assertNull(text); }
@Test public void checkSettingFastValue() throws Exception { // stage_x is mm and T is K. This tests picking up the units from the scannable! assertEquals(bbox.getFastAxisStart()+" mm", bot.table(0).cell(1, 1)); bot.table(0).click(1, 1); // Make the file editor SWTBotText text = bot.text(0); assertNotNull(text); text.setText("10"); text.display.syncExec(()->viewer.applyEditorValue()); assertEquals("10.0 mm", bbox.getFastAxisStart()+" mm"); }
protected void focusOut(SWTBotGefEditPart part,SWTBotText text,String tab ) { editor.setFocus(); selectPart(part); selectTab(part, tab); try { text.setFocus(); } catch (Throwable e) { } }
public void setSharedName(SWTBotGefEditPart part, String sharedname, boolean enabled) { selectPart(part); SWTBotText text = botView.bot().textWithId(VertexDefaultSection.WIDGET_ID, VertexDefaultSection.WIDGET_TEXT_SHAREDNAME); if (enabled) { text.setText(sharedname); editor.setFocus(); text.setFocus(); } else { TestCase.assertFalse("Text should be disabled", text.isEnabled()); } }
public void setRequirement(SWTBotGefEditPart part, String requirement) { selectPart(part); SWTBotText text = botView.bot().textWithId(VertexDefaultSection.WIDGET_ID, VertexDefaultSection.WIDGET_TEXT_REQUIREMENTS); text.setText(requirement); editor.setFocus(); text.setFocus(); }
public void setWeight(SWTBotGefEditPart part, double value) { selectPart(part); selectTab(part, PROPERTIES); final SWTBotText text = botView.bot().textWithId(WIDGET_ID,WIDGET_TEXT_WEIGHT); text.setText(value+""); Display.getDefault().asyncExec(new Runnable () { @Override public void run() { //SWTBotText text = botView.bot().textWithId(WIDGET_ID,WIDGET_TEXT_WEIGHT); text.widget.notifyListeners(SWT.FocusOut, createFocusEvent((Control)text.widget)); } }); }
public String getWeight(SWTBotGefEditPart part) { selectPart(part); SWTBotText text = botView.bot().textWithId(WIDGET_ID,WIDGET_TEXT_DESCRIPTION); String s = text.getText(); if (s==null) return ""; return s; }
public boolean hasRequirements (Set<String> requirements) { SWTBotText st = bot.textWithId(GraphModelPropertyPage.GW4E_FILE_REQUIREMENT_TEXT_ID,GraphModelPropertyPage.GW4E_FILE_REQUIREMENT_TEXT_ID); String currentText = st.getText(); for (String req : requirements) { if (currentText.indexOf(req)!=-1) continue; return false; } return true; }
public boolean hasMethods (Set<String> methods) { SWTBotText st = bot.textWithId(GraphModelPropertyPage.GW4E_FILE_METHODS_TEXT_ID,GraphModelPropertyPage.GW4E_FILE_METHODS_TEXT_ID); String currentText = st.getText(); for (String method : methods) { if (currentText.indexOf(method)!=-1) continue; return false; } return true; }
public void refactorModelName (String newName,String [] nodes) { SWTBotTree tree = getProjectTree(); SWTBotTreeItem item = tree.expandNode(nodes); item.select(); item.setFocus(); SWTBotMenu menu = item.contextMenu("Refactor").contextMenu("Rename..."); menu.click(); bot.waitUntil(Conditions.shellIsActive("Rename Resource")); SWTBotShell shell = bot.shell("Rename Resource"); SWTBotText text = shell.bot().textWithLabel("New name:"); text.setText(newName); ICondition condition = new DefaultCondition () { @Override public boolean test() throws Exception { return shell.bot().button("OK").isEnabled(); } @Override public String getFailureMessage() { return "OK button not enabled"; } }; bot.waitUntil(condition); shell.bot().button("OK").click(); bot.waitUntil(Conditions.shellCloses(shell)); }
public void refactorRenameFolder (String [] nodes, String name) { SWTBotTree tree = getProjectTree(); SWTBotTreeItem item = tree.expandNode(nodes); item.select(); item.setFocus(); SWTBotMenu menu = item.contextMenu("Refactor").contextMenu("Rename..."); menu.click(); bot.waitUntil(Conditions.shellIsActive("Rename Package")); SWTBotShell shell = bot.shell("Rename Package"); SWTBotText text = shell.bot().textWithLabel("New name:"); text.setText(name); ICondition condition = new DefaultCondition () { @Override public boolean test() throws Exception { return shell.bot().button("OK").isEnabled(); } @Override public String getFailureMessage() { return "OK button not enabled"; } }; bot.waitUntil(condition); shell.bot().button("OK").click(); bot.waitUntil(Conditions.shellCloses(shell), 30 * 1000); }
/** * */ public void enterOrderNumber(final String orderNumber) { SWTBotText text = bot.textWithLabel("&Order Number"); text.typeText(orderNumber); bot.sleep(100); scenariooWriterHelper.writeStep("order_number_entered", PageName.SEARCH_DIALOG, screenshot()); }
private void createOrderTemp() { // add new Order, As we don't want to interfere with other test cases bot.toolbarButtonWithTooltip("Create Order").click(); SWTBotText text = bot.textWithLabel("&Order Number"); text.typeText(ORDER_NUMBER_TEMP); bot.button("Next >").click(); bot.buttonWithTooltip("Add Position").click(); // Select Item in Table SWTBotTable table = bot.table(); // Position Amount table.click(0, 4); bot.sleep(100); bot.text(1).setText("2"); // Select Item bot.table().click(0, 2); bot.sleep(100); bot.ccomboBox(0).setSelection(13); // loose Focus table.click(0, 3); bot.sleep(100); // click Finish bot.button("Finish").click(); bot.sleep(500); LOGGER.info("\n" + "-----------------------------------------------------------------\n" + "create temp order rule : order " + ORDER_NUMBER_TEMP + " created.\n" + "-----------------------------------------------------------------\n\n"); }
private void enterOrderNumberAndGenerateDocu() { SWTBotText text = bot.textWithLabel("&Order Number"); text.setText(""); text.typeText(TARGET_ORDER_NUMBER); bot.sleep(100); scenariooWriterHelper.writeStep("order_number_entered", PageName.ORDER_DETAIL, screenshot()); }
/** * Checks that the widget denies changes when the spinner's associated text * widget is set to an invalid time. */ @Test public void checkTextRejectsInvalidInput() { // Get the text widget. We will try feeding it invalid times. SWTBotText widget = getTimeText(); // Create a list of invalid times. List<String> invalidTimes = new ArrayList<String>(); invalidTimes.add(""); invalidTimes.add("infinite improbability"); invalidTimes.add(" "); // Get the initial time. final AtomicReference<Double> time = new AtomicReference<Double>(); getDisplay().syncExec(new Runnable() { @Override public void run() { time.set(timeComposite.getTime()); } }); final double initialTime = time.get(); for (String invalidTime : invalidTimes) { // Try setting an invalid time string. widget.selectAll(); widget.typeText(invalidTime + SWT.CR + SWT.LF); getDisplay().syncExec(new Runnable() { @Override public void run() { time.set(timeComposite.getTime()); } }); // Ensure that the time did not change. assertEquals(initialTime, time.get(), epsilon); } return; }
/** * Checks whether the preferences are displayed correctly. */ @Test public void testPreferences() { openFeedbackPreferencePage(); final SWTBotText text = bot.textWithLabel(LABELS__FEEDBACK_HANDLER_URL); assertThat(text.getText()).isEqualTo(DEFAULT_VALUES__FEEDBACK_HANDLER_URL); text.setText(SAMPLE_FEEDBACK_HANDLER_URL); pressOk(); final String feedbackHandlerUrl = FeedbackPreferences.getString(FeedbackPreferences.FEEDBACK_HANDLER__URL); assertThat(feedbackHandlerUrl).isEqualTo(SAMPLE_FEEDBACK_HANDLER_URL); }
/** * @return 文本框:TMX/TBX 文件; */ public SWTBotText txtWLblFile() { if (importType.equals(TMX)) { return dialogBot.textWithLabel(TsUIConstants.getString("txtWLblTMXFile")); } else { return dialogBot.textWithLabel(TsUIConstants.getString("txtWLblTBXFile")); } }
/** * @return 文本信息:提示文件错误; */ public SWTBotText msgFileError() { if (importType.equals(TMX)) { return dialogBot.text(TsUIConstants.getString("txtTMXFileError")); } else { return dialogBot.text(TsUIConstants.getString("txtTBXFileError")); } }
/** * @return 文本信息:用户取消了导入操作; */ public SWTBotText msgCancelImport() { if (importType.equals(TMX)) { return dialogBot.text(TsUIConstants.getString("txtCancelImportTMX")); } else { return dialogBot.text(TsUIConstants.getString("txtCancelImportTBX")); } }
private void createLocalProject() { final int localProjectsSize = ESWorkspaceProvider.INSTANCE.getWorkspace().getLocalProjects().size(); UIThreadRunnable.asyncExec(new VoidResult() { public void run() { final UICreateLocalProjectController localProjectController = new UICreateLocalProjectController( bot.getDisplay().getActiveShell()); localProject = localProjectController.execute(); } }); final SWTBotText text = bot.text(0); text.setText("quux"); final SWTBotButton button = bot.button("OK"); button.click(); bot.waitUntil(new DefaultCondition() { // BEGIN SUPRESS CATCH EXCEPTION public boolean test() throws Exception { return localProjectsSize + 1 == ESWorkspaceProvider.INSTANCE.getWorkspace().getLocalProjects().size(); } // END SURPRESS CATCH EXCEPTION public String getFailureMessage() { return "Create local project did not succeed."; } }); }
@Override @Test public void testController() throws ESException { final int remoteProjectsSize = server.getRemoteProjects(usersession).size(); UIThreadRunnable.asyncExec(new VoidResult() { public void run() { createRemoteProjectController = new UICreateRemoteProjectController( bot.getDisplay().getActiveShell(), usersession); createRemoteProjectController.execute(); } }); final SWTBotText text = bot.text(0); text.setText("foo"); final SWTBotButton okButton = bot.button("OK"); okButton.click(); bot.waitUntil(new DefaultCondition() { // BEGIN SUPRESS CATCH EXCEPTION public boolean test() throws Exception { return server.getRemoteProjects(usersession).size() == remoteProjectsSize + 1; } // END SUPRESS CATCH EXCEPTION public String getFailureMessage() { return "Create remote project did not succeed."; } }, timeout()); assertEquals(remoteProjectsSize + 1, server.getRemoteProjects(usersession).size()); }
@Test public void checkFilePath() throws Exception { assertEquals(config.getMicroscopeImage(), bot.table(0).cell(0, 1)); bot.table(0).click(0, 1); // Make the file editor SWTBotText text = bot.text(0); assertNotNull(text); assertEquals(config.getMicroscopeImage(), text.getText()); text.setText("Invalid Path"); Color red = new Color(bot.getDisplay(), 255, 0, 0, 255); assertEquals(red, text.foregroundColor()); File file = File.createTempFile("a_testFile", ".txt"); file.deleteOnExit(); text.setText(file.getAbsolutePath()); Color black = new Color(bot.getDisplay(), 0, 0, 0, 255); assertEquals(black, text.foregroundColor()); }
@Test public void checkFastStart() throws Exception { assertEquals(String.valueOf(config.getFastAxisStart())+" mm", bot.table(0).cell(3, 1)); bot.table(0).click(3, 1); // Make the file editor SWTBotText text = bot.text(0); assertNotNull(text); assertEquals(String.valueOf(config.getFastAxisStart()), text.getText()); Color red = new Color(bot.getDisplay(), 255, 0, 0, 255); Color black = new Color(bot.getDisplay(), 0, 0, 0, 255); assertEquals(black, text.foregroundColor()); text.setText("-2000"); assertEquals(red, text.foregroundColor()); text.setText("1"); assertEquals(black, text.foregroundColor()); text.setText("1001"); assertEquals(red, text.foregroundColor()); }
public String getNameText () { SWTBotText text= botView.bot().textWithId(OutLineComposite.GW_WIDGET_ID, OutLineComposite.GW_OUTLINE_NAME_TEXT); return text.getText(); }
public void setNameText (String value) { SWTBotText text= botView.bot().textWithId(OutLineComposite.GW_WIDGET_ID, OutLineComposite.GW_OUTLINE_NAME_TEXT); text.setText(value); }
public String getDescriptionText () { SWTBotText text= botView.bot().textWithId(OutLineComposite.GW_WIDGET_ID, OutLineComposite.GW_OUTLINE_DESCRIPTION_TEXT); return text.getText(); }
public void setDescriptionText (String value) { SWTBotText text= botView.bot().textWithId(OutLineComposite.GW_WIDGET_ID, OutLineComposite.GW_OUTLINE_DESCRIPTION_TEXT); text.setText(value); }
public String getRequirementText () { SWTBotText text= botView.bot().textWithId(OutLineComposite.GW_WIDGET_ID, OutLineComposite.GW_OUTLINE_REQUIREMENT_TEXT); return text.getText(); }
public void setRequirementText (String value) { SWTBotText text= botView.bot().textWithId(OutLineComposite.GW_WIDGET_ID, OutLineComposite.GW_OUTLINE_REQUIREMENT_TEXT); text.setText(value); }
public String getWeightText () { SWTBotText text= botView.bot().textWithId(OutLineComposite.GW_WIDGET_ID, OutLineComposite.GW_OUTLINE_WEIGHT_TEXT); return text.getText(); }
public void setWeightText (String value) { SWTBotText text= botView.bot().textWithId(OutLineComposite.GW_WIDGET_ID, OutLineComposite.GW_OUTLINE_WEIGHT_TEXT); text.setText(value); }