org.eclipse.swtbot.swt.finder.widgets.SWTBotTable Java Examples

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotTable. 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 vote down vote up
/**
 * 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 #2
Source File: SWTBotTestUtil.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param bot
 * @param variableName
 */
public static void setVariableExpression(final SWTGefBot bot, final String variableName) {
    bot.waitUntil(Conditions.shellIsActive(editExpression));
    bot.tableWithLabel(expressionTypeLabel).select("Variable");
    bot.sleep(1000);
    // select the variable
    final SWTBotTable tableVar = bot.table(1);
    for (int i = 0; i < tableVar.rowCount(); i++) {
        final SWTBotTableItem tableItem = tableVar.getTableItem(i);
        if (tableItem.getText().startsWith(variableName + " --")) {
            tableItem.select();
            break;
        }
    }
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.OK_LABEL)));
    bot.button(IDialogConstants.OK_LABEL).click();
}
 
Example #3
Source File: SwtBotControlUtils.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Wait for table items.
 *
 * @param table
 *          the table
 * @param timeout
 *          the timeout
 */

@SuppressWarnings("PMD.ConfusingTernary")
public static void waitForTableItems(final SWTBotTable table, final int timeout) {
  final long endTimeMillis = System.currentTimeMillis() + timeout;
  while (System.currentTimeMillis() < endTimeMillis) {
    if (table.getTableItem(0) != null) {
      return;
    } else {
      try {
        Thread.sleep(THREAD_SLEEP_TIME);
      } catch (InterruptedException e) {
        e.fillInStackTrace();
      }
    }
  }
}
 
Example #4
Source File: BotBdmModelEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public BotBdmModelEditor addAttribute(String packageName, String businessObject, String attribute, String type) {
    SWTBotTable attributeTable = getAttributeTable(packageName, businessObject);
    attributeTable.unselect();
    bot.waitUntil(new DefaultCondition() {

        @Override
        public boolean test() throws Exception {
            return attributeTable.selectionCount() == 0;
        }

        @Override
        public String getFailureMessage() {
            return "Attribute table should have no selection";
        }
    });
    bot.toolbarButtonWithId(AttributeEditionControl.ADD_ATTRIBUTE_BUTTON_ID).click();
    SWTBotText botText = bot.textWithId(SWTBOT_ID_ATTRIBUTE_NAME_TEXTEDITOR);
    botText.setText(attribute);
    botText.pressShortcut(Keystrokes.CR);

    setType(packageName, businessObject, attributeTable.getTableItem(attribute), type, attributeTable);
    return this;
}
 
Example #5
Source File: SWTBotCustomChartUtils.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Select the chart type from the dialog maker.
 *
 * The chart maker dialog must have been opened by the caller, this method
 * will put focus on the dialog.
 *
 * @param bot
 *            The SWT workbench bot to use
 * @param chartType
 *            The type of chart to select
 */
public static void selectChartType(SWTWorkbenchBot bot, ChartType chartType) {
    ensureDialogFocus(bot);
    int index = 0;
    switch (chartType) {
    case BAR_CHART:
        index = 0;
        break;
    case SCATTER_CHART:
        index = 1;
        break;
    case PIE_CHART:
    default:
        throw new IllegalStateException("Unsupported chart type: " + chartType.name());
    }
    // The chart selection table is the first
    SWTBotTable table = bot.table(CHART_TYPE_TABLE_INDEX);
    // Click on the row corresponding to the chart type
    table.click(index, 0);
}
 
Example #6
Source File: ChartMakerDialogTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private List<IDataChartDescriptor<?, ?>> getDescriptors(int tblIndex) {
    SWTBotTable table = fBot.table(tblIndex);

    List<IDataChartDescriptor<?, ?>> items = UIThreadRunnable.syncExec((Result<@Nullable List<IDataChartDescriptor<?, ?>>>) () -> {
        List<IDataChartDescriptor<?, ?>> list = new ArrayList<>();
        for (TableItem item : table.widget.getItems()) {
            Object data = item.getData();
            if (data instanceof IDataChartDescriptor<?, ?>) {
                IDataChartDescriptor<?, ?> desc = (IDataChartDescriptor<?, ?>) data;
                list.add(desc);
            }
        }
        return list;
    });
    assertNotNull(items);
    return items;
}
 
Example #7
Source File: BotBdmConstraintsEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public BotBdmConstraintsEditor editConstraint(String packageName, String businessObject, String constraintName,
        String... selectFields) {
    selectBusinessObject(packageName, businessObject);
    getConstraintsTable().select(constraintName);
    SWTBotTable constraintsEditionTable = getConstraintsEditionTable();
    List<String> toCheck = Arrays.asList(selectFields);
    for (int i = 0; i < constraintsEditionTable.rowCount(); i++) {
        SWTBotTableItem tableItem = constraintsEditionTable.getTableItem(i);
        if (toCheck.contains(tableItem.getText())) {
            tableItem.check();
        } else {
            tableItem.uncheck();
        }
    }
    return this;
}
 
Example #8
Source File: SegmentTableTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test table with segments that have durations spread into a gaussian
 * (normal) distribution
 * <p>
 * Test table with a gaussian distribution of segments. Duration sort is
 * tested.
 */
@Test
public void gaussianNoiseTest() {
    Random rnd = new Random();
    rnd.setSeed(1234);
    ISegmentStore<@NonNull ISegment> fixture = SegmentStoreFactory.createSegmentStore();
    for (int i = 1; i <= 1000000; i++) {
        int start = Math.abs(rnd.nextInt(100000000));
        final int delta = Math.abs(rnd.nextInt(1000));
        int end = start + delta * delta;
        fixture.add(createSegment(start, end));
    }
    assertNotNull(getTable());
    getTable().updateModel(fixture);
    SWTBotTable tableBot = new SWTBotTable(getTable().getTableViewer().getTable());
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "23,409", 0, 2));
    tableBot.header("Duration").click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "0", 0, 2));
    tableBot.header("Duration").click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "998,001", 0, 2));
}
 
Example #9
Source File: XMLAnalysesManagerPreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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 #10
Source File: SegmentTableTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test table with segments that have durations spread into a random (white
 * noise) distribution
 * <p>
 * Test table with a random distribution of segments. Duration sort is
 * tested.
 */
@Test
public void noiseTest() {
    Random rnd = new Random();
    rnd.setSeed(1234);
    final int size = 1000000;
    ISegmentStore<@NonNull ISegment> fixture = SegmentStoreFactory.createSegmentStore();
    for (int i = 0; i < size; i++) {
        int start = Math.abs(rnd.nextInt(100000000));
        int end = start + Math.abs(rnd.nextInt(1000000));
        fixture.add(createSegment(start, end));
    }
    assertNotNull(getTable());
    getTable().updateModel(fixture);
    SWTBotTable tableBot = new SWTBotTable(getTable().getTableViewer().getTable());
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "374,153", 0, 2));
    tableBot.header("Duration").click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "0", 0, 2));
    tableBot.header("Duration").click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "999,999", 0, 2));
}
 
Example #11
Source File: XMLAnalysesManagerPreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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 #12
Source File: SegmentTableTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test large table
 * <p>
 * Test table with over 9000 segments. Duration sort is tested.
 */
@Test
public void largeTest() {
    final int size = 1000000;
    ISegmentStore<@NonNull ISegment> fixture = SegmentStoreFactory.createSegmentStore();
    for (int i = 0; i < size; i++) {
        fixture.add(createSegment(i, 2 * i));
    }
    assertNotNull(getTable());
    getTable().updateModel(fixture);
    SWTBotTable tableBot = new SWTBotTable(getTable().getTableViewer().getTable());
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "0", 0, 2));
    tableBot.header("Duration").click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "0", 0, 2));
    tableBot.header("Duration").click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "999,999", 0, 2));
}
 
Example #13
Source File: SegmentTableTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test small table
 * <p>
 * Test table with 2 segments. Duration sort is tested.
 */
@Test
public void smallTest() {
    ISegmentStore<@NonNull ISegment> fixture = SegmentStoreFactory.createSegmentStore();
    for (int i = 1; i >= 0; i--) {
        fixture.add(createSegment(i, 2 * i));
    }
    assertNotNull(getTable());
    getTable().updateModel(fixture);
    SWTBotTable tableBot = new SWTBotTable(getTable().getTableViewer().getTable());
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "0", 0, 2));
    tableBot.header("Duration").click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "0", 0, 2));
    tableBot.header("Duration").click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "1", 0, 2));
}
 
Example #14
Source File: SegmentTableTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test a decrementing data structure.
 * <p>
 * Create segments that are progressively shorter and start sooner,
 * effectively the inverse sorted {@link #climbTest()} datastructure. Test
 * that the "duration" column sorts well
 */
@Test
public void decrementingTest() {
    ISegmentStore<@NonNull ISegment> fixture = SegmentStoreFactory.createSegmentStore();
    for (int i = 100; i >= 0; i--) {
        fixture.add(createSegment(i, 2 * i));
    }
    assertNotNull(getTable());
    getTable().updateModel(fixture);
    SWTBotTable tableBot = new SWTBotTable(getTable().getTableViewer().getTable());
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "0", 0, 2));
    tableBot.header("Duration").click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "0", 0, 2));
    tableBot.header("Duration").click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "100", 0, 2));
}
 
Example #15
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Get the number of checked items of a table
 *
 * @param table
 *            The table bot
 * @return The number of checked items
 */
public static int getTableCheckedItemCount(SWTBotTable table) {
    return UIThreadRunnable.syncExec(new IntResult() {

        @Override
        public Integer run() {
            int checked = 0;
            for (TableItem item : table.widget.getItems()) {
                if (item.getChecked()) {
                    checked++;
                }
            }
            return checked;
        }
    });
}
 
Example #16
Source File: AddProjectNatureTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test adding and configuring tracing nature on a C-Project.
 */
@Test
public void testConfigureTracingNature() {
    SWTBotTreeItem projectItem = SWTBotUtils.selectProject(fBot, SOME_PROJECT_NAME);
    projectItem.contextMenu().menu(CONTEXT_MENU_CONFIGURE, CONTEXT_MENU_CONFIGURE_TRACING_NATURE).click();
    WaitUtils.waitForJobs();

    SWTBotTreeItem projectRoot = SWTBotUtils.getTraceProjectItem(fBot, projectItem, TRACING_PROJECT_ROOT_NAME);
    assertEquals(TRACING_PROJECT_ROOT_NAME, projectRoot.getText());
    SWTBotUtils.getTraceProjectItem(fBot, projectRoot, TRACES_FOLDER_NAME);
    SWTBotUtils.getTraceProjectItem(fBot, projectRoot, EXPERIMENTS_FOLDER_NAME);

    SWTBotUtils.openTrace(SOME_PROJECT_NAME, fTestFile.getAbsolutePath(), TRACE_TYPE);
    SWTBotEditor editorBot = SWTBotUtils.activateEditor(fBot, fTestFile.getName());
    SWTBotTable tableBot = editorBot.bot().table();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, FIRST_EVENT_TIME, 1, 1));
    assertEquals("Timestamp", FIRST_EVENT_TIME, tableBot.cell(1, 1));
    fBot.closeAllEditors();
}
 
Example #17
Source File: SystemCallLatencyTableAnalysisTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test with an actual trace, this is more of an integration test than a
 * unit test. This test is a slow one too. If some analyses are not well
 * configured, this test will also generates null pointer exceptions. These
 * are will be logged.
 *
 * @throws IOException
 *             trace not found?
 */
@Test
public void testWithTrace() throws IOException {
    String tracePath = FileUtils.toFile(FileLocator.toFileURL(CtfTestTrace.ARM_64_BIT_HEADER.getTraceURL())).getAbsolutePath();
    SWTBotUtils.closeViewById(PRIMARY_VIEW_ID, fBot);
    SWTBotUtils.createProject(PROJECT_NAME);
    SWTBotUtils.openTrace(PROJECT_NAME, tracePath, TRACE_TYPE);
    WaitUtils.waitForJobs();
    AbstractSegmentStoreTableView tableView = openTable();
    setTableView(tableView);
    AbstractSegmentStoreTableViewer table = tableView.getSegmentStoreViewer();
    assertNotNull(table);
    setTable(table);
    WaitUtils.waitForJobs();
    SWTBotTable tableBot = new SWTBotTable(table.getTableViewer().getTable());
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "24,100", 0, 2));
    tableBot.header("Duration").click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "1,000", 0, 2));
    tableBot.header("Duration").click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "5,904,091,700", 0, 2));
    fBot.closeAllEditors();
    SWTBotUtils.deleteProject(PROJECT_NAME, fBot);
}
 
Example #18
Source File: ColumnHeaderMenuTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test the Show All menu item
 */
@Test
public void testShowAll() {
    final SWTBotTable tableBot = fEditorBot.bot().table();
    SWTBotTableColumn headerBot = tableBot.header("");
    assertVisibleColumns(tableBot.widget, new String[] { "Timestamp", "Host", "Logger", "File", "Line", "Message" });

    headerBot.contextMenu("Timestamp").click();
    headerBot.contextMenu("Host").click();
    headerBot.contextMenu("Logger").click();
    headerBot.contextMenu("File").click();
    headerBot.contextMenu("Line").click();
    headerBot.contextMenu("Message").click();
    assertVisibleColumns(tableBot.widget, new String[] {});

    headerBot.contextMenu("Show All").click();
    assertVisibleColumns(tableBot.widget, new String[] { "Timestamp", "Host", "Logger", "File", "Line", "Message" });
}
 
Example #19
Source File: ColumnHeaderMenuTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test the Show All menu item
 */
@Test
public void testPersistHiding() {
    SWTBotTable tableBot = fEditorBot.bot().table();
    SWTBotTableColumn headerBot = tableBot.header("");
    assertVisibleColumns(tableBot.widget, new String[] { "Timestamp", "Host", "Logger", "File", "Line", "Message" });

    headerBot.contextMenu("Timestamp").click();
    headerBot.contextMenu("Host").click();
    headerBot.contextMenu("Logger").click();
    headerBot.contextMenu("File").click();
    headerBot.contextMenu("Message").click();
    assertVisibleColumns(tableBot.widget, new String[] { "Line" });
    after();

    before();
    tableBot = fEditorBot.bot().table();
    assertVisibleColumns(tableBot.widget, new String[] { "Line" });
    headerBot = tableBot.header("");
    headerBot.contextMenu("Show All").click();
    assertVisibleColumns(tableBot.widget, new String[] { "Timestamp", "Host", "Logger", "File", "Line", "Message" });
}
 
Example #20
Source File: ExportToTsvTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test full export
 *
 * @throws IOException
 *             File not found or such
 */
@Test
public void testExport() throws IOException {
    SWTBotEditor editorBot = fEditorBot;
    assertNotNull(editorBot);
    final SWTBotTable tableBot = editorBot.bot().table();

    tableBot.getTableItem(1).contextMenu(EXPORT_TO_TSV).click();
    File file = new File(fAbsolutePath);
    fBot.waitUntil(new FileLargerThanZeroCondition(file));
    try (BufferedReader br = new BufferedReader(new FileReader(file))) {
        long lines = br.lines().count();
        assertEquals("Line count", 23, lines);
    } finally {
        new File(fAbsolutePath).delete();
    }
}
 
Example #21
Source File: BotContractConstraintRow.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private SWTBotTableItem getTableItem(final SWTBotTable swtBotTable, final int row) {
    Display.getDefault().syncExec(new Runnable() {

        @Override
        public void run() {
            final Table table = swtBotTable.widget;
            tableItem = table.getItem(row);
        }
    });
    return new SWTBotTableItem(tableItem);

}
 
Example #22
Source File: FlameChartViewTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void goToTime(long timestamp) {
    ITmfTimestamp time = TmfTimestamp.fromNanos(timestamp);
    SWTBotTable table = sfBot.activeEditor().bot().table();
    table.setFocus();
    WaitUtils.waitForJobs();
    TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(table.widget, time));
    sfBot.waitUntil(ConditionHelpers.selectionInEventsTable(sfBot, timestamp));
    final SWTBotView viewBot = sfBot.viewById(FlameChartView.ID);
    IWorkbenchPart part = viewBot.getViewReference().getPart(false);
    sfBot.waitUntil(ConditionHelpers.timeGraphIsReadyCondition((AbstractTimeGraphView) part, new TmfTimeRange(time, time), time));
}
 
Example #23
Source File: BotBdmModelEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The attribute type has to be a String!
 */
public BotBdmModelEditor setAttributeLength(String packageName, String businessObject, String attribute,
        String length) {
    SWTBotTable attributeTable = getAttributeTable(packageName, businessObject);
    attributeTable.select(attribute);
    bot.comboBoxWithLabel(Messages.length).setText(length);
    return this;
}
 
Example #24
Source File: SWTBotTestUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static void selectExpressionProposal(final SWTBot bot, final String storageExpressionName,
        final String returnType, final int index) {
    bot.toolbarButtonWithId(SWTBOT_ID_EXPRESSIONVIEWER_DROPDOWN, index).click();
    final SWTBotShell proposalShell = bot.shellWithId(SWTBOT_ID_EXPRESSIONVIEWER_PROPOSAL_SHELL);
    final SWTBot proposalBot = proposalShell.bot();
    final SWTBotTable proposalTAble = proposalBot.tableWithId(SWTBOT_ID_EXPRESSIONVIEWER_PROPOSAL_TABLE);
    final int row = proposalTAble.indexOf(storageExpressionName + " -- " + returnType, 0);
    if (row == -1) {
        throw new WidgetNotFoundException(storageExpressionName + " not found in proposals");
    }
    proposalTAble.select(row);
    proposalTAble.pressShortcut(Keystrokes.CR);
    bot.waitUntil(Conditions.shellCloses(proposalShell));
}
 
Example #25
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 #26
Source File: TableComboTests.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Ensures that the items in the {@link TableCombo} are correctly displayed in
 * the table widget.
 */
@Test
public void testDisplayOfItems() {

	/*
	 * GIVEN a TableCombo with one column and a number of TableItems assigned to the
	 * TableCombo.
	 */
	createTableCombo(shell, 1, 5);

	/*
	 * WHEN the TableCombo gets displayed
	 */
	shell.open();

	/*
	 * THEN the number of rows displayed in the table widget of the TableCombo must
	 * match the number of TableItems.
	 */
	final SWTBot shellBot = new SWTBot(shell);
	final TableCombo tableComboWidget = shellBot.widget(WidgetMatcherFactory.widgetOfType(TableCombo.class));
	final SWTBotTable tableBot = new SWTBotTable(tableComboWidget.getTable());

	assertEquals(
			"Expected the number of items in the table widget of the TableCombo to be the same as the number of TableItems added to the TableCombo",
			5, tableBot.rowCount());

}
 
Example #27
Source File: ExportToTsvTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test export when a filter is applied to the table
 *
 * @throws IOException
 *             File not found or such
 */
@Test
public void testExportWithFilter() throws IOException {
    SWTBotEditor editorBot = fEditorBot;
    assertNotNull(editorBot);
    final SWTBotTable tableBot = editorBot.bot().table();
    tableBot.getTableItem(0).click(3);
    SWTBotText textBot = editorBot.bot().text();
    textBot.typeText("LoggerA|LoggerB|LoggerC");
    textBot.pressShortcut(Keystrokes.CTRL, Keystrokes.CR);
    fBot.waitUntil(Conditions.tableHasRows(tableBot, 6), 5000);

    tableBot.getTableItem(1).contextMenu(EXPORT_TO_TSV).click();
    assertTsvContentsEquals(ImmutableList.of(HEADER_TEXT, EVENT1_TEXT, EVENT2_TEXT, EVENT3_TEXT));
}
 
Example #28
Source File: SWTBotTestUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static List<String> listExpressionProposal(final SWTBot bot, final int index) {
    bot.toolbarButtonWithId(SWTBOT_ID_EXPRESSIONVIEWER_DROPDOWN, index).click();
    final SWTBotShell proposalShell = bot.shellWithId(SWTBOT_ID_EXPRESSIONVIEWER_PROPOSAL_SHELL);
    final SWTBot proposalBot = proposalShell.bot();
    final SWTBotTable proposalTAble = proposalBot.tableWithId(SWTBOT_ID_EXPRESSIONVIEWER_PROPOSAL_TABLE);

    final List<String> result = new ArrayList<>();
    for (int i = 0; i < proposalTAble.rowCount(); i++) {
        result.add(proposalTAble.getTableItem(i).getText());
    }
    proposalShell.close();
    return result;
}
 
Example #29
Source File: PinAndCloneTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test the follow time updates functionality
 */
@Test
public void testFollow() {
    TmfTraceManager traceManager = TmfTraceManager.getInstance();
    ITmfTrace ust = traceManager.getActiveTrace();
    assertNotNull(ust);
    ITmfTrace kernelTest = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.CONTEXT_SWITCHES_KERNEL);
    SWTBotUtils.openTrace(TRACE_PROJECT_NAME, kernelTest.getPath(), TRACETYPE_ID);
    /* Finish waiting for the trace to index */
    WaitUtils.waitForJobs();
    SWTBotEditor kernelEditor = SWTBotUtils.activateEditor(fBot, kernelTest.getName());
    // wait for the editor to be ready.
    fBot.editorByTitle(kernelTest.getName());
    ITmfTrace kernel = traceManager.getActiveTrace();
    assertNotNull(kernel);

    SWTBotTable kernelEventTable = kernelEditor.bot().table();
    SWTBotTableItem kernelEvent = kernelEventTable.getTableItem(5);
    kernelEvent.contextMenu(FOLLOW_TIME_UPDATES_FROM_OTHER_TRACES).click();
    SWTBotUtils.activateEditor(fBot, ust.getName());
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, RANGE, ust));

    // assert that the kernel trace followed the ust trace's range
    IWorkbenchPart part = fOriginalViewBot.getViewReference().getPart(false);
    assertTrue(part instanceof AbstractTimeGraphView);
    AbstractTimeGraphView abstractTimeGraphView = (AbstractTimeGraphView) part;
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, ust, RANGE));

    SWTBotUtils.activateEditor(fBot, kernel.getName());
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, kernel, RANGE));

    // unfollow (don't use context menu on table item to avoid updating selection)
    kernelEventTable.contextMenu(FOLLOW_TIME_UPDATES_FROM_OTHER_TRACES).click();
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, ust.getInitialTimeRange(), ust));
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, kernel, RANGE));

    kernelTest.dispose();
}
 
Example #30
Source File: BotBdmIndexesEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public BotBdmIndexesEditor moveField(String packageName, String businessObject, String indexName, String field,
        int position) {
    selectBusinessObject(packageName, businessObject);
    SWTBotTable indexesTable = getIndexesTable();
    indexesTable.select(indexName);
    SWTBotTable indexedFieldsTable = getIndexedFieldsTable();
    indexedFieldsTable.getTableItem(field).dragAndDrop(indexedFieldsTable.getTableItem(position));
    return this;
}