Java Code Examples for org.eclipse.swtbot.swt.finder.SWTBot#table()
The following examples show how to use
org.eclipse.swtbot.swt.finder.SWTBot#table() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XMLAnalysesManagerPreferencePageTest.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Test the import of valid files */ @Test public void testImportValid() { // Import valid analysis file SWTBot bot = openXMLAnalysesPreferences().bot(); importAnalysis(bot, FILES_IMPORT_VALID.length, getRelativePaths(VALID_FILES_FOLDER, FILES_IMPORT_VALID)); // Check that the "enabled" label is displayed SWTBotTable tablebot = bot.table(0); for (String importedItem : FILES_IMPORT_VALID) { tablebot.getTableItem(importedItem).select(); assertTrue(bot.label("File enabled").isVisible()); } SWTBotUtils.pressOKishButtonInPreferences(bot); }
Example 2
Source File: XMLAnalysesManagerPreferencePageTest.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Test the edit function */ @Test public void testEdit() { // Import valid analysis files SWTBot bot = openXMLAnalysesPreferences().bot(); importAnalysis(bot, FILES_EDIT.length, getRelativePaths(VALID_FILES_FOLDER, FILES_EDIT)); // Open the editor SWTBotTable tablebot = bot.table(0); tablebot.select(FILES_EDIT); bot.button("Edit...").click(); SWTBotUtils.pressOKishButtonInPreferences(bot); // Check that the editors were opened // No need to actually check that they are active for (String editFile : FILES_EDIT) { fBot.editorByTitle(editFile + EXTENSION).isActive(); } }
Example 3
Source File: XMLAnalysesManagerPreferencePageTest.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Test the invalid file label */ @Test public void testInvalidLabel() { // Import invalid analysis file manually (otherwise it is rejected) XmlUtils.addXmlFile(Activator.getAbsolutePath(new Path(TEST_FILES_FOLDER + INVALID_FILES_FOLDER + FILE_IMPORT_INVALID + EXTENSION)).toFile()); XmlAnalysisModuleSource.notifyModuleChange(); // Check that the "invalid" label displayed // and that the checkbox was unchecked as a result SWTBot bot = openXMLAnalysesPreferences().bot(); SWTBotTable tablebot = bot.table(0); SWTBotTableItem tableItem = tablebot.getTableItem(FILE_IMPORT_INVALID); tableItem.select(); assertNotNull(bot.label("Invalid file")); assertFalse(tableItem.isChecked()); SWTBotUtils.pressOKishButtonInPreferences(bot); }
Example 4
Source File: XMLAnalysesManagerPreferencePageTest.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Test the export function */ @Test public void testExport() { // Import valid analysis file SWTBot bot = openXMLAnalysesPreferences().bot(); final String fileNameXml = FILE_EXPORT + EXTENSION; importAnalysis(bot, 1, TEST_FILES_FOLDER + VALID_FILES_FOLDER + fileNameXml); // Setup target folder File targetDirectory = new File(TEMP_DIRECTORY); DirectoryDialogFactory.setOverridePath(targetDirectory.getAbsolutePath()); // Export SWTBotTable tableBot = bot.table(0); tableBot.select(FILE_EXPORT); bot.button("Export").click(); // Check that the file was created File targetFile = new File(targetDirectory, fileNameXml); assertTrue(targetFile.toString(), targetFile.exists()); SWTBotUtils.pressOKishButtonInPreferences(bot); }
Example 5
Source File: XMLAnalysesManagerPreferencePageTest.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * After each test, delete all analyses */ @After public void after() { fBot.closeAllEditors(); SWTBot bot = openXMLAnalysesPreferences().bot(); SWTBotTable tableBot = bot.table(0); // Delete existing analysis files, if any int rowsCount = tableBot.rowCount(); if (rowsCount > 0) { String[] itemNames = new String[rowsCount]; for (int i = 0; i < rowsCount; ++i) { itemNames[i] = tableBot.getTableItem(i).getText(); } tableBot.select(itemNames); bot.button("Delete").click(); SWTBotShell deleteShell = bot.shell("Delete XML file(s)").activate(); deleteShell.bot().button("Yes").click(); } SWTBotUtils.pressOKishButtonInPreferences(bot); }
Example 6
Source File: XMLAnalysesManagerPreferencePageTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Test the deletion of files */ @Test public void testDelete() { // Import valid analysis file SWTBot bot = openXMLAnalysesPreferences().bot(); importAnalysis(bot, FILES_DELETE.length, getRelativePaths(VALID_FILES_FOLDER, FILES_DELETE)); SWTBotTable tablebot = bot.table(0); // Open editor for first file tablebot.select(FILES_DELETE[0]); bot.button("Edit...").click(); // Delete files tablebot.select(FILES_DELETE); bot.button("Delete").click(); // Check that the confirmation pop-up is displayed SWTBotShell deleteShell = bot.shell("Delete XML file(s)").activate(); deleteShell.bot().button("Yes").click(); // Check that the files do not exist anymore for (String deleteFile : FILES_DELETE) { assertFalse(deleteFile, tablebot.containsItem(deleteFile)); } // Check that the opened editor was closed fBot.editors().forEach(editor -> { if (editor != null) { if (editor.getTitle().equals(FILES_DELETE[0] + EXTENSION)) { fail("Editor is still open: " + FILES_DELETE[0] + EXTENSION); } } }); SWTBotUtils.pressOKishButtonInPreferences(bot); }
Example 7
Source File: SWTBotImportWizardUtils.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * While in the import wizard, select an item in the file selection control. * The item can be a folder in the left tree or a file in the right table. * The item will be checked. * * @param bot * the SWTBot * @param treePath * the path to the item, ending with a file or folder */ public static void selectItem(SWTBot bot, String... treePath) { SWTBotTree tree = bot.tree(); bot.waitUntil(Conditions.widgetIsEnabled(tree)); if (treePath.length == 0) { return; } if (treePath.length == 1) { SWTBotTreeItem rootNode = SWTBotUtils.getTreeItem(bot, tree, treePath); rootNode.select(); rootNode.check(); return; } String[] parentPath = Arrays.copyOf(treePath, treePath.length - 1); String itemName = treePath[treePath.length - 1]; SWTBotTreeItem folderNode = SWTBotUtils.getTreeItem(bot, tree, parentPath); folderNode.expand(); if (folderNode.getNodes().contains(itemName)) { folderNode = folderNode.getNode(itemName); folderNode.select(); folderNode.check(); } else { folderNode.select(); SWTBotTable fileTable = bot.table(); bot.waitUntil(Conditions.widgetIsEnabled(fileTable)); bot.waitUntil(ConditionHelpers.isTableItemAvailable(itemName, fileTable)); SWTBotTableItem tableItem = fileTable.getTableItem(itemName); tableItem.check(); } }
Example 8
Source File: XMLAnalysesManagerPreferencePageTest.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Test the check/uncheck buttons */ @Test public void testCheckButtons() { SWTBot bot = openXMLAnalysesPreferences().bot(); SWTBotTable tableBot = bot.table(0); // Delete existing analysis files, if any int rowsCount = tableBot.rowCount(); if (rowsCount > 0) { String[] itemNames = new String[rowsCount]; for (int i = 0; i < rowsCount; ++i) { itemNames[i] = tableBot.getTableItem(i).getText(); } tableBot.select(itemNames); bot.button("Delete").click(); SWTBotShell deleteShell = bot.shell("Delete XML file(s)").activate(); deleteShell.bot().button("Yes").click(); } // Import files int preRowCount = tableBot.rowCount(); importAnalysis(bot, FILES_BUTTONS.length, getRelativePaths(VALID_FILES_FOLDER, FILES_BUTTONS)); int postRowCount = tableBot.rowCount(); assertEquals(preRowCount + FILES_BUTTONS.length, postRowCount); // Uncheck selected int preCheckCount = SWTBotUtils.getTableCheckedItemCount(tableBot); int uncheckCount = 2; String[] toUncheck = Arrays.copyOfRange(FILES_BUTTONS, 0, uncheckCount); tableBot.select(toUncheck); bot.button(UNCHECK_SELECTED).click(); int postCheckCount = SWTBotUtils.getTableCheckedItemCount(tableBot); assertEquals(UNCHECK_SELECTED, preCheckCount - uncheckCount, postCheckCount); // Check selected tableBot.select(toUncheck); bot.button(CHECK_SELECTED).click(); postCheckCount = SWTBotUtils.getTableCheckedItemCount(tableBot); assertEquals(CHECK_SELECTED, preCheckCount, postCheckCount); // Uncheck all bot.button(UNCHECK_ALL).click(); postCheckCount = SWTBotUtils.getTableCheckedItemCount(tableBot); assertEquals(UNCHECK_ALL, 0, postCheckCount); // Check all bot.button(CHECK_ALL).click(); postCheckCount = SWTBotUtils.getTableCheckedItemCount(tableBot); assertEquals(CHECK_ALL, postRowCount, postCheckCount); SWTBotUtils.pressOKishButtonInPreferences(bot); }
Example 9
Source File: StandardImportGzipTraceTest.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Import a gzip trace */ @Test public void testGzipImport() { final String traceType = "Test trace : TMF Tests"; final String tracesNode = "Traces [1]"; final SWTWorkbenchBot bot = getSWTBot(); /* * Actual importing */ openImportWizard(); SWTBotImportWizardUtils.selectImportFromArchive(bot, fGzipTrace.getAbsolutePath()); SWTBotImportWizardUtils.selectFolder(bot, true, ROOT_FOLDER); SWTBotCheckBox checkBox = bot.checkBox(Messages.ImportTraceWizard_CreateLinksInWorkspace); assertFalse(checkBox.isEnabled()); SWTBotCombo comboBox = bot.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 = bot.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. */ SWTBotTreeItem treeItem = SWTBotUtils.getTreeItem(projectExplorer.bot(), tree, PROJECT_NAME, tracesNode, traceName); treeItem.doubleClick(); WaitUtils.waitForJobs(); /* * Check results */ SWTBot editorBot = SWTBotUtils.activeEventsEditor(bot).bot(); SWTBotTable editorTable = editorBot.table(); final String expectedContent1 = "Type-1"; final String expectedContent2 = ""; editorBot.waitUntil(ConditionHelpers.isTableCellFilled(editorTable, expectedContent1, 2, 2)); editorBot.waitUntil(ConditionHelpers.isTableCellFilled(editorTable, expectedContent2, 1, 0)); String c22 = editorTable.cell(2, 2); String c10 = editorTable.cell(1, 0); assertEquals(expectedContent1, c22); assertEquals(expectedContent2, c10); }
Example 10
Source File: FlameChartViewTest.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Test manipulating valid and invalid mapping files (add, remove and change * priority of files) * * @throws IOException * Missing file */ @Test public void testManipulatingMappingFiles() throws IOException { // 1- Open valid mapping files and invalid mapping file URL mapUrlA = CtfTmfTestTraceUtils.class.getResource("cyg-profile-mapping.txt"); URL mapUrlB = CtfTmfTestTraceUtils.class.getResource("dummy-mapping.txt"); URL mapUrlC = CtfTmfTestTraceUtils.class.getResource("invalid-cyg-profile-mapping.txt"); URL mapUrlD = CtfTmfTestTraceUtils.class.getResource("random.out"); URL mapUrlE = CtfTmfTestTraceUtils.class.getResource("win32Random.exe"); String absoluteFileA = FileLocator.toFileURL(mapUrlA).getFile(); String absoluteFileB = FileLocator.toFileURL(mapUrlB).getFile(); String absoluteFileC = FileLocator.toFileURL(mapUrlC).getFile(); String absoluteFileD = FileLocator.toFileURL(mapUrlD).getFile(); String absoluteFileE = FileLocator.toFileURL(mapUrlE).getFile(); String[] overrideFiles = { absoluteFileA, absoluteFileA, absoluteFileB, absoluteFileC, absoluteFileD, absoluteFileE }; TmfFileDialogFactory.setOverrideFiles(overrideFiles); SWTBotShell shell = openSymbolProviderDialog(); final SWTBot symbolDialog = shell.bot(); symbolDialog.button("Add...").click(); final SWTBot errorDialog = sfBot.shell("Import failure").bot(); errorDialog.button("OK").click(); final SWTBotTable table = symbolDialog.table(); assertEquals(4, table.rowCount()); assertEquals(absoluteFileA, table.getTableItem(0).getText()); assertEquals(absoluteFileB, table.getTableItem(1).getText()); assertEquals(absoluteFileD, table.getTableItem(2).getText()); assertEquals(absoluteFileE, table.getTableItem(3).getText()); // 2- Change priority of mapping files table.select(0); symbolDialog.button("Down").click().click().click(); assertEquals(absoluteFileB, table.getTableItem(0).getText()); assertEquals(absoluteFileD, table.getTableItem(1).getText()); assertEquals(absoluteFileE, table.getTableItem(2).getText()); assertEquals(absoluteFileA, table.getTableItem(3).getText()); symbolDialog.button("Up").click().click().click(); assertEquals(absoluteFileA, table.getTableItem(0).getText()); assertEquals(absoluteFileB, table.getTableItem(1).getText()); assertEquals(absoluteFileD, table.getTableItem(2).getText()); assertEquals(absoluteFileE, table.getTableItem(3).getText()); // 3- Remove multiple mapping files table.select(0, 1); symbolDialog.button("Remove").click(); assertEquals(2, table.rowCount()); // 4- Close symbol provider dialog symbolDialog.button("Cancel").click(); }
Example 11
Source File: SWTBotImportWizardUtils.java From tracecompass with Eclipse Public License 2.0 | 3 votes |
/** * While in the import wizard, select a file in the file selection tree. * * @param bot * the SWTBot * @param fileName * the name of the file to select * @param folderTreePath * the path to the parent folder in the tree */ public static void selectFile(SWTBot bot, String fileName, String... folderTreePath) { selectFolder(bot, false, folderTreePath); SWTBotTable fileTable = bot.table(); bot.waitUntil(Conditions.widgetIsEnabled(fileTable)); bot.waitUntil(ConditionHelpers.isTableItemAvailable(fileName, fileTable)); SWTBotTableItem tableItem = fileTable.getTableItem(fileName); tableItem.check(); }