/** * Returns true if runtimeName Server Runtime is defined * * @param bot * @param runtimeName * @return */ public static boolean isServerRuntimeDefined(SWTWorkbenchBot bot, String runtimeName) { boolean serverRuntimeNotDefined = true; bot.menu(IDELabel.Menu.WINDOW).menu(IDELabel.Menu.PREFERENCES).click(); bot.shell(IDELabel.Shell.PREFERENCES).activate(); bot.tree() .expandNode(IDELabel.PreferencesDialog.SERVER_GROUP) .select(PreferencesDialog.RUNTIME_ENVIRONMENTS); SWTBotTable tbRuntimeEnvironments = bot.table(); int numRows = tbRuntimeEnvironments.rowCount(); if (numRows > 0) { int currentRow = 0; while (serverRuntimeNotDefined && currentRow < numRows) { if (tbRuntimeEnvironments.cell(currentRow, 0).equalsIgnoreCase(runtimeName)) { serverRuntimeNotDefined = false; } else { currentRow++; } } } bot.button(IDELabel.Button.OK).click(); return !serverRuntimeNotDefined; }
/** * Returns string representing version of defined Server Runtime on rowIndex position in Defined * Server Runtime table * * @param bot * @param rowIndex * @return null when no server runtime is specified, "unknown when not possible to determine * server runtime version" or server runtime version */ public static String getDefinedServerRuntimeVersion(SWTWorkbenchBot bot, int rowIndex) { String result = null; bot.menu(IDELabel.Menu.WINDOW).menu(IDELabel.Menu.PREFERENCES).click(); bot.shell(IDELabel.Shell.PREFERENCES).activate(); bot.tree() .expandNode(IDELabel.PreferencesDialog.SERVER_GROUP) .select(PreferencesDialog.RUNTIME_ENVIRONMENTS); SWTBotTable serverRuntimesTable = bot.table(); if (serverRuntimesTable.rowCount() > rowIndex) { String[] splitServerRuntimeType = serverRuntimesTable.cell(rowIndex, 1).split(" "); int index = 0; while (index < splitServerRuntimeType.length && result == null) { if (splitServerRuntimeType[index].length() > 0 && splitServerRuntimeType[index].charAt(0) >= '0' && splitServerRuntimeType[index].charAt(0) <= '9') { result = splitServerRuntimeType[index].trim(); } else { index++; } } } bot.button(IDELabel.Button.OK).click(); return result; }
/** Import a gzip trace */ @Test public void testGzipImport() { final String traceType = "Test trace : TMF Tests"; final String tracesNode = "Traces [1]"; /* * Actual importing */ openImportWizard(); selectImportFromArchive(fGzipTrace.getAbsolutePath()); selectFolder(ROOT_FOLDER); SWTBotCheckBox checkBox = fBot.checkBox(Messages.ImportTraceWizard_CreateLinksInWorkspace); assertFalse(checkBox.isEnabled()); SWTBotCombo comboBox = fBot.comboBoxWithLabel(Messages.ImportTraceWizard_TraceType); comboBox.setSelection(traceType); importFinish(); /* * Remove .gz extension */ assertNotNull(fGzipTrace); String name = fGzipTrace.getName(); assertNotNull(name); assertTrue(name.length() > 3); String traceName = name.substring(0, name.length() - 3); assertNotNull(traceName); assertFalse(traceName.isEmpty()); /* * Open trace */ SWTBotView projectExplorer = fBot.viewById(IPageLayout.ID_PROJECT_EXPLORER); projectExplorer.setFocus(); final SWTBotTree tree = projectExplorer.bot().tree(); /* * This appears to be problematic due to the length of the file name and * the resolution in our CI. */ tree.expandNode(PROJECT_NAME, true); SWTBotTreeItem treeItem = tree.getTreeItem(PROJECT_NAME); fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(tracesNode, treeItem)); treeItem = treeItem.getNode(tracesNode); fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(traceName, treeItem)); treeItem = treeItem.getNode(traceName); treeItem.doubleClick(); SWTBotUtils.waitForJobs(); /* * Check results */ SWTBotTable editor = fBot.activeEditor().bot().table(); String c22 = editor.cell(2, 2); String c10 = editor.cell(1, 0); assertEquals("Type-1", c22); assertEquals("", c10); }