org.eclipse.swtbot.swt.finder.waits.ICondition Java Examples

The following examples show how to use org.eclipse.swtbot.swt.finder.waits.ICondition. 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: BotContractConstraintRow.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private ICondition textApplied(final String text, final int column) {
    return new ICondition() {

        @Override
        public boolean test() throws Exception {
            return text.equals(constraintTable.getTableItem(row).getText(column));
        }

        @Override
        public void init(final SWTBot bot) {
        }

        @Override
        public String getFailureMessage() {
            return "item not found: " + text + " in " + constraintTable.getTableItem(row).getText(column);
        }
    };
}
 
Example #2
Source File: ConditionHelpers.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public boolean test() throws Exception {
    ICondition selectionRangeCondition = ConditionHelpers.selectionRange(fSelectionRange);
    if (!selectionRangeCondition.test()) {
        fFailureMessage = selectionRangeCondition.getFailureMessage();
        return false;
    }
    @NonNull TmfTimeRange curWindowRange = TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange();
    if (!curWindowRange.contains(fVisibleTime)) {
        fFailureMessage = "Current window range " + curWindowRange + " does not contain " + fVisibleTime;
        return false;
    }

    if (fView.isDirty()) {
        fFailureMessage = "Time graph is dirty";
        return false;

    }
    return true;
}
 
Example #3
Source File: ConditionHelpers.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Condition to check if the selection contains the specified text at the
 * specified column. The text is checked in any item of the tree selection.
 *
 * @param timeGraph
 *            the {@link SWTBotTimeGraph}
 * @param column
 *            the column index
 * @param text
 *            the expected text
 * @return ICondition for verification
 */
public static ICondition timeGraphSelectionContains(final SWTBotTimeGraph timeGraph, final int column, final String text) {
    return new SWTBotTestCondition() {
        @Override
        public boolean test() throws Exception {
            TableCollection selection = timeGraph.selection();
            for (int row = 0; row < selection.rowCount(); row++) {
                if (selection.get(row, column).equals(text)) {
                    return true;
                }
            }
            return false;
        }

        @Override
        public String getFailureMessage() {
            return NLS.bind("Time graph selection [0,{0}]: {1} expected: {2}",
                    new Object[] { column, timeGraph.selection().get(0, column), text});
        }
    };
}
 
Example #4
Source File: ConditionHelpers.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Condition to check if the selection contains the specified text at the
 * specified column. The text is checked in any item of the tree selection.
 *
 * @param tree
 *            the SWTBot tree
 * @param column
 *            the column index
 * @param text
 *            the expected text
 * @return ICondition for verification
 */
public static ICondition treeSelectionContains(final SWTBotTree tree, final int column, final String text) {
    return new SWTBotTestCondition() {
        @Override
        public boolean test() throws Exception {
            TableCollection selection = tree.selection();
            for (int row = 0; row < selection.rowCount(); row++) {
                if (selection.get(row, column).equals(text)) {
                    return true;
                }
            }
            return false;
        }

        @Override
        public String getFailureMessage() {
            return NLS.bind("Tree selection [0,{0}]: {1} expected: {2}",
                    new Object[] { column, tree.selection().get(0, column), text});
        }
    };
}
 
Example #5
Source File: ConditionBuilder.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public ICondition create() {
    return new ICondition() {

        @Override
        public boolean test() throws Exception {
            return test.get();
        }

        @Override
        public void init(SWTBot bot) {
        }

        @Override
        public String getFailureMessage() {
            return failureMessageSupplier.get();
        }
    };
}
 
Example #6
Source File: ConditionHelpers.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Is the wizard on the page you want?
 *
 * @param wizard
 *            wizard
 * @param page
 *            the desired page
 * @return ICondition for verification
 */
public static ICondition isWizardOnPage(final Wizard wizard, final IWizardPage page) {
    return new SWTBotTestCondition() {
        @Override
        public boolean test() throws Exception {
            if (wizard == null || page == null) {
                return false;
            }
            final IWizardContainer container = wizard.getContainer();
            if (container == null) {
                return false;
            }
            IWizardPage currentPage = container.getCurrentPage();
            return page.equals(currentPage);
        }
    };
}
 
Example #7
Source File: ConditionHelpers.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Is the treeItem's node removed
 *
 * @param length
 *            length of the node after removal
 * @param treeItem
 *            the treeItem
 * @return ICondition for verification
 */
public static ICondition isTreeChildNodeRemoved(final int length, final SWTBotTreeItem treeItem) {
    return new SWTBotTestCondition() {
        @Override
        public boolean test() throws Exception {
            try {
                return treeItem.getNodes().size() == length;
            } catch (Exception e) {
            }
            return false;
        }

        @Override
        public String getFailureMessage() {
            return NLS.bind("Child of tree item {0} found with text ''{1}'' not removed. Child items: {2}",
                    new String[] { treeItem.toString(), String.valueOf(length), Arrays.toString(treeItem.getItems()) });
        }
    };
}
 
Example #8
Source File: ConditionHelpers.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Is the treeItem's node available
 *
 * @param name
 *            the name of the node
 * @param treeItem
 *            the treeItem
 * @return ICondition for verification
 */
public static ICondition isTreeChildNodeAvailable(final String name, final SWTBotTreeItem treeItem) {
    return new SWTBotTestCondition() {
        @Override
        public boolean test() throws Exception {
            try {
                return treeItem.getNode(name) != null;
            } catch (Exception e) {
            }
            return false;
        }

        @Override
        public String getFailureMessage() {
            return NLS.bind("No child of tree item {0} found with text ''{1}''. Child items: {2}",
                    new String[] { treeItem.toString(), name, Arrays.toString(treeItem.getItems()) });
        }
    };
}
 
Example #9
Source File: ConditionHelpers.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Is a table item available
 *
 * @param name
 *            the name of the item
 * @param table
 *            the parent table
 * @return ICondition for verification
 */
public static ICondition isTableItemAvailable(final String name, final SWTBotTable table) {
    return new SWTBotTestCondition() {
        @Override
        public boolean test() throws Exception {
            try {
                return table.containsItem(name);
            } catch (Exception e) {
            }
            return false;
        }

        @Override
        public String getFailureMessage() {
            return NLS.bind("No child of table {0} found with text ''{1}''.", table, name);
        }
    };
}
 
Example #10
Source File: ConditionHelpers.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Is a tree node available
 *
 * @param name
 *            the name of the node
 * @param tree
 *            the parent tree
 * @return ICondition for verification
 */
public static ICondition isTreeNodeAvailable(final String name, final SWTBotTree tree) {
    return new SWTBotTestCondition() {
        @Override
        public boolean test() throws Exception {
            try {
                final SWTBotTreeItem[] treeItems = tree.getAllItems();
                for (SWTBotTreeItem ti : treeItems) {
                    final String text = ti.getText();
                    if (text.equals(name)) {
                        return true;
                    }
                }
            } catch (Exception e) {
            }
            return false;
        }

        @Override
        public String getFailureMessage() {
            return NLS.bind("No child of tree {0} found with text {1}. Child items: {2}",
                    new String[] { tree.toString(), name, Arrays.toString(tree.getAllItems()) });
        }
    };
}
 
Example #11
Source File: TestSave.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private ICondition widgetIsDisabled(AbstractSWTBot<? extends Widget> widget) {
    return new ICondition() {

        @Override
        public boolean test() throws Exception {
            return !widget.isEnabled();
        }

        @Override
        public void init(final SWTBot bot) {

        }

        @Override
        public String getFailureMessage() {
            return widget.toString() + "is still enabled !";
        }
    };
}
 
Example #12
Source File: LamiChartViewerTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Check if a LAMI analysis is enabled, ie the item is enabled, and not
 * striked-out
 *
 * @param item
 *            the item representing the LAMI analysis element
 * @return true or false, it should swallow all exceptions
 */
private static ICondition isLamiAnalysisEnabled(final SWTBotTreeItem item) {
    return new SWTBotTestCondition() {

        private boolean fIsOk = false;

        @Override
        public boolean test() throws Exception {
            try {
                if (!item.isEnabled()) {
                    return false;
                }
                Display.getDefault().syncExec(() -> {
                    // Make sure the object is not striked-out, this
                    // property will return a non empty StyleRange[] if if
                    // is
                    Object data = item.widget.getData("org.eclipse.jfacestyled_label_key_0");
                    if (data == null) {
                        fIsOk = false;
                        return;
                    }
                    if (data instanceof StyleRange[]) {
                        StyleRange[] sr = (StyleRange[]) data;
                        fIsOk = sr.length == 0;
                    } else {
                        fIsOk = false;
                    }
                });

            } catch (Exception e) {
            }
            return fIsOk;
        }

        @Override
        public String getFailureMessage() {
            return "The lami analysis is not enabled";
        }
    };
}
 
Example #13
Source File: ConditionHelpers.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Condition to wait for a view to become active
 *
 * @param view
 *            bot view for the view
 * @return ICondition for verification
 */
public static ICondition viewIsActive(final SWTBotView view) {
    return new SWTBotTestCondition() {
        @Override
        public boolean test() throws Exception {
            return (view != null) && (view.isActive());
        }

        @Override
        public String getFailureMessage() {
            return view.getTitle() + " view did not become active";
        }
    };
}
 
Example #14
Source File: ConditionHelpers.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Condition to check if an editor with the specified title is opened.
 *
 * @param bot
 *            a workbench bot
 * @param title
 *            the editor title
 * @return ICondition for verification
 */
public static ICondition isEditorOpened(final SWTWorkbenchBot bot, final String title) {
    return new SWTBotTestCondition() {
        @Override
        public boolean test() throws Exception {
            Matcher<IEditorReference> withPartName = withPartName(title);
            return !bot.editors(withPartName).isEmpty();
        }
    };
}
 
Example #15
Source File: ControlViewSwtBotUtil.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Tests for Target node state
 *
 * @param node
 *            target node component
 * @param state
 *            the state to wait
 * @return the condition instance
 */
public static ICondition isStateChanged(final TargetNodeComponent node, final TargetNodeState state) {
    return new SWTBotTestCondition() {
        @Override
        public boolean test() throws Exception {
            if (node.getTargetNodeState() != state) {
                return false;
            }
            return true;
        }
    };
}
 
Example #16
Source File: ControlViewSwtBotUtil.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Tests for session state
 *
 * @param session
 *            the session component
 * @param state
 *            the state to wait
 * @return the condition instance
 */
public static ICondition isSessionStateChanged(final TraceSessionComponent session, final TraceSessionState state) {
    return new SWTBotTestCondition() {
        @Override
        public boolean test() throws Exception {
            if (session.getSessionState() != state) {
                return false;
            }
            return true;
        }
    };
}
 
Example #17
Source File: ProjectExplorerBot.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ICondition nodeAvailable(SWTBotTreeItem item, String node) {
    return new ConditionBuilder()
            .withTest(() -> {
                try {
                    item.getNode(node);
                    return true;
                } catch (WidgetNotFoundException e) {
                    return false;
                }
            })
            .withFailureMessage(() -> String.format("The node %s of '%s' isn't available", node, item))
            .create();
}
 
Example #18
Source File: ProjectExplorerBot.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ICondition contextMenuAvailable(SWTBotTreeItem item, String menu) {
    return new ConditionBuilder()
            .withTest(() -> item.contextMenu().menuItems().contains(menu))
            .withFailureMessage(() -> String.format("The menu '%s' of '%s' isn't available (%s)", menu, item,
                    item.contextMenu().menuItems()))
            .create();
}
 
Example #19
Source File: ConditionHelpers.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Checks if the wizard's shell is null
 *
 * @param wizard
 *            the null
 * @return ICondition for verification
 */
public static ICondition isWizardReady(final Wizard wizard) {
    return new SWTBotTestCondition() {
        @Override
        public boolean test() throws Exception {
            if (wizard.getShell() == null) {
                return false;
            }
            return true;
        }
    };
}
 
Example #20
Source File: SwtWorkbenchBot.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void waitUntilWidgetAppears(final ICondition waitForWidget) {
  try {
    waitUntil(waitForWidget, SHORT_TIME_OUT, SHORT_INTERVAL);
  } catch (TimeoutException e) {
    throw new WidgetNotFoundException("Could not find widget.", e); //$NON-NLS-1$
  }
}
 
Example #21
Source File: ProjectExplorerBot.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void waitUntilActiveEditorTitleIs(String title, Optional<String> extension) {
    String expectedTitle = extension.isPresent() ? title + extension.get() : title;
    ICondition condition = new ConditionBuilder()
            .withTest(() -> {
                try {
                    return Objects.equals(bot.activeEditor().getTitle(), expectedTitle);
                } catch (WidgetNotFoundException e) {
                    return false;
                }
            })
            .withFailureMessage(() -> String.format("The active editor title should be  %s instead of %s", expectedTitle,
                    bot.activeEditor().getTitle()))
            .create();
    bot.waitUntil(condition, 10000);
}
 
Example #22
Source File: BotBdmModelEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ICondition nodeAvailable(SWTBotTreeItem item, String node) {
    return new ConditionBuilder()
            .withTest(() -> {
                try {
                    item.getNode(node);
                    return true;
                } catch (WidgetNotFoundException e) {
                    return false;
                }
            })
            .withFailureMessage(() -> String.format("The node %s of '%s' isn't available", node, item))
            .create();
}
 
Example #23
Source File: BotBdmModelEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ICondition treeItemAvailable(SWTBotTree tree, String item) {
    return new ConditionBuilder()
            .withTest(() -> {
                try {
                    tree.getTreeItem(item);
                    return true;
                } catch (WidgetNotFoundException e) {
                    return false;
                }
            })
            .withFailureMessage(() -> String.format("The node %s isn't available", item))
            .create();
}
 
Example #24
Source File: ImportBdmWizardBot.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ICondition treeItemAvailable(SWTBotTree tree, String itemName) {
    return new ConditionBuilder()
            .withTest(() -> {
                try {
                    tree.getTreeItem(itemName);
                    return true;
                } catch (WidgetNotFoundException e) {
                    return false;
                }
            })
            .withFailureMessage(() -> String.format("Tree item `%s` not found.", itemName))
            .create();
}
 
Example #25
Source File: ImportBdmWizardBot.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ICondition treeNodeAvailable(SWTBotTreeItem treeItem, String nodeName) {
    return new ConditionBuilder()
            .withTest(() -> {
                try {
                    treeItem.getNode(nodeName);
                    return true;
                } catch (WidgetNotFoundException e) {
                    return false;
                }
            })
            .withFailureMessage(() -> String.format("Tree node `%s` not found.", nodeName))
            .create();
}
 
Example #26
Source File: ImportBdmWizardBot.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ICondition treeNodeNotAvailable(SWTBotTreeItem treeItem, String nodeName) {
    return new ConditionBuilder()
            .withTest(() -> {
                try {
                    treeItem.getNode(nodeName);
                    return false;
                } catch (WidgetNotFoundException e) {
                    return true;
                }
            })
            .withFailureMessage(() -> String.format("Tree node `%s` should not be present.", nodeName))
            .create();
}
 
Example #27
Source File: BotTreeWidget.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ICondition emptyCondition() {
    return new DefaultCondition() {

        @Override
        public boolean test() throws Exception {
            return getSWTBotWidget().getAllItems().length == 0;
        }

        @Override
        public String getFailureMessage() {
            return "Tree is not empty";
        }
    };
}
 
Example #28
Source File: BotTreeWidget.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ICondition activeCondition() {
    return new DefaultCondition() {

        @Override
        public boolean test() throws Exception {
            return getSWTBotWidget().isActive() && getSWTBotWidget().isEnabled();
        }

        @Override
        public String getFailureMessage() {
            return "Tree is not active";
        }
    };
}
 
Example #29
Source File: BotTableWidget.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ICondition emptyCondition() {
    return new DefaultCondition() {

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

        @Override
        public String getFailureMessage() {
            return "Table is not empty";
        }
    };
}
 
Example #30
Source File: ProjectExplorerBdmIT.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void validateBdmIsDeleted() {
    ICondition bdmDeletedCondition = new ConditionBuilder()
            .withTest(() -> repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)
                    .getChild("bom.xml", true) == null)
            .withFailureMessage(() -> "Business data model has not been deleted.")
            .create();
    bot.waitUntil(bdmDeletedCondition);
}