/** Test Class setup */ @BeforeClass public static void init() { SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; SWTBotUtils.initialize(); Thread.currentThread().setName(SWT_BOT_THREAD_NAME); // for the debugger /* set up for swtbot */ SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */ fLogger.addAppender(new ConsoleAppender(new SimpleLayout())); fBot = new SWTWorkbenchBot(); SWTBotUtils.closeView(WELCOME_NAME, fBot); SWTBotUtils.switchToTracingPerspective(); /* finish waiting for eclipse to load */ WaitUtils.waitForJobs(); }
/** * 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(); }