private void importFinish() { SWTBotShell shell = fBot.activeShell(); final SWTBotButton finishButton = fBot.button("Finish"); finishButton.click(); fBot.waitUntil(Conditions.shellCloses(shell)); SWTBotUtils.waitForJobs(); }
public static void continueInstall(final SWTWorkbenchBot bot, final String shellTitle) throws InstallFailureException { try { bot.radio(0).click(); bot.button("Finish").click(); // wait for Security pop-up, or install finished. final SWTBotShell shell = bot.shell(shellTitle); bot.waitWhile( new ICondition() { @Override public boolean test() throws Exception { return shell.isActive(); } @Override public void init(SWTBot bot) {} @Override public String getFailureMessage() { return null; } }, installationTimeout); if (bot.activeShell().getText().equals("Security Warning")) { bot.button("OK").click(); System.err.println("OK clicked"); bot.waitUntil( new ICondition() { @Override public boolean test() throws Exception { try { boolean stillOpen = bot.shell(shellTitle).isOpen(); System.err.println("still open? " + stillOpen); return !stillOpen; } catch (WidgetNotFoundException ex) { System.err.println("no shell"); // Shell already closed return true; } } @Override public void init(SWTBot bot) {} @Override public String getFailureMessage() { return null; } }, installationTimeout); // 15 more minutes } SWTBot restartShellBot = bot.shell("Software Updates").bot(); // Don't restart in test, test executor will do it. try { // Eclipse 4.2 => "No" restartShellBot.button("No").click(); } catch (WidgetNotFoundException ex) { // Eclipse 3.7.x => "Not now" restartShellBot.button("Not Now").click(); } } catch (Exception ex) { String installDesc = bot.text().getText(); if (installDesc == null || installDesc.isEmpty()) { throw new RuntimeException("Internal error", ex); } throw new InstallFailureException(installDesc); } }
/** * test opening a trace, importing * * @throws IOException won't happen */ @Test public void test() throws IOException { File f = File.createTempFile("temp", ".xml").getCanonicalFile(); try (FileWriter fw = new FileWriter(f)) { fw.write(TRACE_CONTENT); } File exportPackage = new File(EXPORT_LOCATION); if (exportPackage.exists()) { exportPackage.delete(); } assertFalse( "File: " + EXPORT_LOCATION + " already present, aborting test", exportPackage.exists()); assertTrue("Trace :" + f.getAbsolutePath() + " does not exist, aborting test", f.exists()); SWTBotUtils.createProject(PROJECT_NAME); SWTBotUtils.openTrace(PROJECT_NAME, f.getAbsolutePath(), XMLSTUB_ID); WaitUtils.waitForJobs(); ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace(); assertNotNull(trace); assertEquals( "Incorrect opened trace!", f.getAbsolutePath(), (new File(trace.getPath())).getAbsolutePath()); SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); assertNotNull("Cannot find " + PROJECT_EXPLORER, projectExplorerBot); projectExplorerBot.show(); SWTBotTreeItem treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); treeItem.contextMenu(EXPORT_TRACE_PACKAGE).click(); fBot.waitUntil(Conditions.shellIsActive(EXPORT_TRACE_PACKAGE_TITLE)); SWTBot shellBot = fBot.activeShell().bot(); shellBot.button(DESELECT_ALL).click(); SWTBotTreeItem[] items = fBot.tree().getAllItems(); for (SWTBotTreeItem item : items) { assertEquals(item.isChecked(), false); } shellBot.button(SELECT_ALL).click(); for (SWTBotTreeItem item : items) { assertEquals(item.isChecked(), true); } shellBot.radio(SAVE_IN_TAR_FORMAT).click(); shellBot.radio(SAVE_IN_ZIP_FORMAT).click(); shellBot.checkBox(COMPRESS_THE_CONTENTS_OF_THE_FILE).click(); shellBot.checkBox(COMPRESS_THE_CONTENTS_OF_THE_FILE).click(); shellBot.comboBox().setText(EXPORT_LOCATION); SWTBotShell shell = fBot.activeShell(); shellBot.button(FINISH).click(); // finished exporting WaitUtils.waitForJobs(); fBot.waitUntil(Conditions.shellCloses(shell)); fBot = new SWTWorkbenchBot(); exportPackage = new File(EXPORT_LOCATION); assertTrue("Exported package", exportPackage.exists()); // Fixme: determine why exportPackageSize is different on different machines // assertEquals("Exported package size check", PACKAGE_SIZE, exportPackage.length()); // import treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); treeItem.contextMenu(IMPORT_TRACE_PACKAGE).click(); fBot.waitUntil(Conditions.shellIsActive(IMPORT_TRACE_PACKAGE_TITLE)); shellBot = fBot.activeShell().bot(); shellBot.comboBox().setText(EXPORT_LOCATION); shellBot.comboBox().typeText("\n"); shellBot.button(SELECT_ALL).click(); shell = fBot.activeShell(); shellBot.button(FINISH).click(); fBot.button("Yes To All").click(); fBot.waitUntil(Conditions.shellCloses(shell)); fBot = new SWTWorkbenchBot(); SWTBotUtils.openEditor(fBot, PROJECT_NAME, new Path(f.getName())); trace = TmfTraceManager.getInstance().getActiveTrace(); assertNotNull(trace); assertEquals("Test if import matches", f.getName(), trace.getName()); assertFalse("Test if import files don't match", f.getAbsolutePath().equals(trace.getPath())); SWTBotUtils.deleteProject(PROJECT_NAME, fBot); WaitUtils.waitForJobs(); }