Java Code Examples for org.eclipse.swtbot.swt.finder.widgets.SWTBotTable#cell()

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotTable#cell() . 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: SwtBotTestingUtilities.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Click on all table cells in column {@code col} with the contents {@code value}. Selection
 * should be the last cell clicked upon.
 */
public static void clickOnTableCellValue(SWTBotTable table, int col, String value) {
  String column = table.columns().get(col);
  for (int row = 0; row < table.rowCount(); row++) {
    String cellValue = table.cell(row, column);
    if (cellValue.equals(value)) {
      table.click(row, col);
      break;
    }
  }
}
 
Example 2
Source File: ConditionHelpers.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Wait till table cell has a given content.
 *
 * @param table
 *            the table bot reference
 * @param content
 *            the content to check
 * @param row
 *            the row of the cell
 * @param column
 *            the column of the cell
 * @return ICondition for verification
 */
public static ICondition isTableCellFilled(final SWTBotTable table,
        final String content, final int row, final int column) {
    return new SWTBotTestCondition() {
        String actual;
        Exception exception;
        @Override
        public boolean test() throws Exception {
            try {
                exception = null;
                actual = table.cell(row, column);
                if (actual == null) {
                    return false;
                }
                return actual.contains(content);
            } catch (Exception e) {
                exception = e;
            }
            return false;
        }

        @Override
        public String getFailureMessage() {
            if (exception != null) {
                return ExceptionUtils.getStackTrace(exception);
            }
            if (actual == null) {
                return NLS.bind("Cell absent, expected: ''{0}''", content);
            }
            return NLS.bind("Cell content: ''{0}'' expected: ''{1}''", actual, content);
        }
    };
}
 
Example 3
Source File: FilterViewerTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static String applyFilter(SWTWorkbenchBot bot, final String filterName) {
    WaitUtils.waitForJobs();
    final SWTBotTable eventsTable = SWTBotUtils.activeEventsEditor(bot).bot().table();
    SWTBotTableItem tableItem = eventsTable.getTableItem(2);
    tableItem.contextMenu(filterName).click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(eventsTable, "/100", 1, 1));
    return eventsTable.cell(1, 1);
}
 
Example 4
Source File: SwtBotUtils.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public static void clickOnTableCellValue(SWTBotTable table, int col, String value) {
  String column = table.columns().get(col);
  for (int row = 0; row < table.rowCount(); row++) {
    String cellValue = table.cell(row, column);
    if (cellValue.equals(value)) {
      table.click(row, col);
      break;
    }
  }
}
 
Example 5
Source File: StandardImportGzipTraceTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * 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 6
Source File: TestTraceOffsetting.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test offsetting by 99 ns
 */
@Test
public void testOffsetting() {
    // Skip this test on Mac OS X 10.11.1 because of bug 481611
    // FIXME: Remove this work around once bug 481611 is fixed
    MacOsVersion macOsVersion = MacOsVersion.getMacOsVersion();
    boolean macBugPresent = macOsVersion != null && macOsVersion.compareTo(new MacOsVersion(10, 11, 1)) >= 0;
    assumeTrue(!macBugPresent);

    SWTBotUtils.createProject(PROJET_NAME);
    SWTBotTreeItem traceFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJET_NAME);
    SWTBotUtils.openTrace(PROJET_NAME, fLocation.getAbsolutePath(), "org.eclipse.linuxtools.tmf.core.tests.xmlstub");
    SWTBotEditor editor = fBot.editorByTitle(fLocation.getName());
    SWTBotTable eventsTableBot = editor.bot().table();
    String timestamp = eventsTableBot.cell(1, 1);
    assertEquals("19:00:00.000 000 000", timestamp);
    SWTBotTreeItem traceItem = SWTBotUtils.getTraceProjectItem(fBot, traceFolderItem, fLocation.getName());
    traceItem.select();
    traceItem.contextMenu("Apply Time Offset...").click();
    WaitUtils.waitForJobs();
    // set offset to 99 ns
    SWTBotShell shell = fBot.shell("Apply time offset");
    shell.setFocus();
    SWTBotTreeItem[] allItems = fBot.tree().getAllItems();
    final SWTBotTreeItem swtBotTreeItem = allItems[0];
    swtBotTreeItem.select();
    swtBotTreeItem.click(1);
    // Press shortcuts on the cell editor
    SWTBotText text = shell.bot().text(1);
    text.pressShortcut(KeyStroke.getInstance('9'));
    text.pressShortcut(KeyStroke.getInstance('9'));
    text.pressShortcut(KeyStroke.getInstance('\n'));
    WaitUtils.waitForJobs();
    fBot.button("OK").click();

    // wait for trace to close
    fBot.waitWhile(ConditionHelpers.isEditorOpened(fBot, fLocation.getName()));

    // re-open trace
    SWTBotUtils.openTrace(PROJET_NAME, fLocation.getAbsolutePath(), "org.eclipse.linuxtools.tmf.core.tests.xmlstub");
    editor = fBot.editorByTitle(fLocation.getName());
    eventsTableBot = editor.bot().table();
    timestamp = eventsTableBot.cell(1, 1);
    assertEquals("19:01:39.000 000 000", timestamp);
    SWTBotUtils.deleteProject(PROJET_NAME, fBot);
}
 
Example 7
Source File: CollapseEventsInTableTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Main test case
 */
@Test
public void test() {
    SWTBotUtils.createProject(TRACE_PROJECT_NAME);
    SWTBotUtils.openTrace(TRACE_PROJECT_NAME, fTestFile.getAbsolutePath(), COLLAPSE_TRACE_TYPE);
    SWTBotEditor editorBot = SWTBotUtils.activateEditor(fBot, fTestFile.getName());

    SWTBotTable tableBot = editorBot.bot().table();

    /* Maximize editor area */
    SWTBotUtils.maximize(editorBot.getReference(), tableBot);
    tableBot.click(1, 0);

    /* Collapse Events */
    SWTBotMenu menuBot = tableBot.contextMenu("Collapse Events");
    menuBot.click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "7/22", 1, 1));

    String cell = tableBot.cell(1, 1);
    assertEquals("filterString", "7/22", cell);

    /* Verify first collapsed event */
    cell = tableBot.cell(7, 0);
    assertEquals("1st repeatCount", "+14", cell);
    cell = tableBot.cell(7, 1);
    assertEquals("1st Timestamp", "Jan 1 06:06:06", cell);
    cell = tableBot.cell(7, 2);
    assertEquals("1st Host", "HostF", cell);
    cell = tableBot.cell(7, 3);
    assertEquals("1st Logger", "LoggerF", cell);
    cell = tableBot.cell(7, 4);
    assertEquals("1st File", "SourceFile", cell);
    cell = tableBot.cell(7, 5);
    assertEquals("1st Line", "9", cell);
    cell = tableBot.cell(7, 6);
    assertEquals("1st Message", "Message F", cell);

    /* Verify second collapsed event */
    cell = tableBot.cell(8, 0);
    assertEquals("2nd repeatCount", "+1", cell);
    cell = tableBot.cell(8, 1);
    assertEquals("2nd Timestamp", "Jan 1 06:06:21", cell);
    cell = tableBot.cell(8, 2);
    assertEquals("2nd Host", "HostF", cell);
    cell = tableBot.cell(8, 3);
    assertEquals("2nd Logger", "LoggerF", cell);
    cell = tableBot.cell(8, 4);
    assertEquals("2nd File", "SourceFile", cell);
    cell = tableBot.cell(8, 5);
    assertEquals("2nd Line", "10", cell);
    cell = tableBot.cell(8, 6);
    assertEquals("2nd Message", "Message D", cell);

    /* Clear Filter */
    menuBot = tableBot.contextMenu("Clear Filters");
    menuBot.click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "Jan 1 01:01:01", 1, 1));
    assertEquals("Timestamp", "Jan 1 01:01:01", tableBot.cell(1, 1));

    SWTBotUtils.maximize(editorBot.getReference(), tableBot);

    fBot.closeAllEditors();
    SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, fBot);
}