Search in sources :

Example 16 with WithTextMatcher

use of org.eclipse.reddeer.core.matcher.WithTextMatcher in project jbosstools-openshift by jbosstools.

the class EditResourcesTest method testCanEditResource.

@Test
public void testCanEditResource() {
    getBuildConfig().select();
    new ContextMenuItem(OpenShiftLabel.ContextMenu.EDIT).select();
    try {
        new TextEditor(new WithTextMatcher("*.eap-app.json"));
    // pass
    } catch (RedDeerException ex) {
        fail("Text editor to modify build config resource has not been opened.");
    }
}
Also used : RedDeerException(org.eclipse.reddeer.common.exception.RedDeerException) TextEditor(org.eclipse.reddeer.workbench.impl.editor.TextEditor) ContextMenuItem(org.eclipse.reddeer.swt.impl.menu.ContextMenuItem) WithTextMatcher(org.eclipse.reddeer.core.matcher.WithTextMatcher) AbstractTest(org.jboss.tools.openshift.ui.bot.test.application.v3.basic.AbstractTest) Test(org.junit.Test)

Example 17 with WithTextMatcher

use of org.eclipse.reddeer.core.matcher.WithTextMatcher in project jbosstools-openshift by jbosstools.

the class CDKTestUtils method removeAccessRedHatCredentials.

// removes access redhat com credentials used for first cdk run
public static void removeAccessRedHatCredentials(String domain, String username) {
    WorkbenchPreferenceDialog dialog = new WorkbenchPreferenceDialog();
    dialog.open();
    // $NON-NLS-1$ //$NON-NLS-2$
    dialog.select("JBoss Tools", "Credentials");
    try {
        new WaitUntil(new WidgetIsFound(org.eclipse.swt.custom.CLabel.class, new WithMnemonicTextMatcher("Credentials")), // $NON-NLS-1$
        TimePeriod.MEDIUM);
        // $NON-NLS-1$
        new DefaultCLabel("Credentials");
        DefaultTree tree = new DefaultTree(1);
        TreeItem item = TreeViewerHandler.getInstance().getTreeItem(tree, new String[] { domain, username });
        item.select();
        // $NON-NLS-1$
        new PushButton(new WithTextMatcher("Remove User")).click();
        new WaitUntil(new JobIsRunning(), TimePeriod.MEDIUM, false);
    } catch (WaitTimeoutExpiredException exc) {
        // $NON-NLS-1$
        log.error("JBoss Tools - Credentials preferences page has timed out");
        exc.printStackTrace();
    } catch (JFaceLayerException exc) {
        // $NON-NLS-1$
        log.error("JBoss Tools - Credentials does not contain required username to be deleted");
        exc.printStackTrace();
    } finally {
        dialog.ok();
    }
}
Also used : DefaultCLabel(org.eclipse.reddeer.swt.impl.clabel.DefaultCLabel) DefaultTree(org.eclipse.reddeer.swt.impl.tree.DefaultTree) TreeItem(org.eclipse.reddeer.swt.api.TreeItem) JFaceLayerException(org.eclipse.reddeer.jface.exception.JFaceLayerException) JobIsRunning(org.eclipse.reddeer.workbench.core.condition.JobIsRunning) DefaultCLabel(org.eclipse.reddeer.swt.impl.clabel.DefaultCLabel) WithMnemonicTextMatcher(org.eclipse.reddeer.core.matcher.WithMnemonicTextMatcher) WidgetIsFound(org.eclipse.reddeer.core.condition.WidgetIsFound) WithTextMatcher(org.eclipse.reddeer.core.matcher.WithTextMatcher) WorkbenchPreferenceDialog(org.eclipse.reddeer.workbench.ui.dialogs.WorkbenchPreferenceDialog) WaitTimeoutExpiredException(org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) PushButton(org.eclipse.reddeer.swt.impl.button.PushButton)

Example 18 with WithTextMatcher

use of org.eclipse.reddeer.core.matcher.WithTextMatcher in project jbosstools-openshift by jbosstools.

the class BuilderImageApplicationWizardHandlingTest method testPorts.

@Test
public void testPorts() {
    String defaultName = "8443-tcp";
    String defaultServicePort = "8443";
    String defaultPodPort = "8443";
    String newName = "1234-tcp";
    String newServicePort = "1234";
    String newPodPort = "4321";
    nextToBuildConfigurationWizardPage();
    next();
    next();
    // Test edit of an existing pod
    new DefaultTable().select(defaultName);
    new PushButton(OpenShiftLabel.Button.EDIT).click();
    new DefaultShell(OpenShiftLabel.Shell.SERVICE_PORTS);
    new LabeledText(OpenShiftLabel.TextLabels.POD_PORT).setText(newPodPort);
    new DefaultSpinner(OpenShiftLabel.TextLabels.SERVICE_PORT).setValue(Integer.valueOf(newServicePort));
    new OkButton().click();
    new WaitWhile(new ShellIsAvailable(OpenShiftLabel.Shell.SERVICE_PORTS));
    assertTrue("There should port mapping with name " + newName + ", but there is not.", new WidgetIsFound(org.eclipse.swt.widgets.TableItem.class, new WithTextMatcher(newName)).test());
    TableItem portMapping = new DefaultTable().getItem(newName);
    assertTrue("Modified pod mapping has incorrect mapped ports.", portMapping.getText(1).equals(newServicePort) && portMapping.getText(2).equals(newPodPort));
    // Test reset of pods
    new PushButton(OpenShiftLabel.Button.RESET).click();
    new DefaultShell(OpenShiftLabel.Shell.RESET_PORTS);
    new YesButton().click();
    new WaitWhile(new ShellIsAvailable(OpenShiftLabel.Shell.RESET_PORTS));
    new WaitWhile(new JobIsRunning());
    assertTrue("There should port mapping with name " + defaultName + ", but there is not.", new WidgetIsFound(org.eclipse.swt.widgets.TableItem.class, new WithTextMatcher(defaultName)).test());
    portMapping = new DefaultTable().getItem(defaultName);
    String resetServicePort = portMapping.getText(1);
    String resetPodPort = portMapping.getText(2);
    assertTrue("There should default values for port named " + defaultName + "\n" + "Service port should be " + defaultServicePort + ", but it is " + resetServicePort + " and pod port should be " + defaultPodPort + ", but it is " + resetPodPort, resetServicePort.equals(defaultServicePort) && resetPodPort.equals(defaultPodPort));
}
Also used : ShellIsAvailable(org.eclipse.reddeer.swt.condition.ShellIsAvailable) LabeledText(org.eclipse.reddeer.swt.impl.text.LabeledText) TableItem(org.eclipse.reddeer.swt.api.TableItem) DefaultTable(org.eclipse.reddeer.swt.impl.table.DefaultTable) JobIsRunning(org.eclipse.reddeer.workbench.core.condition.JobIsRunning) YesButton(org.eclipse.reddeer.swt.impl.button.YesButton) OkButton(org.eclipse.reddeer.swt.impl.button.OkButton) WaitWhile(org.eclipse.reddeer.common.wait.WaitWhile) DefaultShell(org.eclipse.reddeer.swt.impl.shell.DefaultShell) WidgetIsFound(org.eclipse.reddeer.core.condition.WidgetIsFound) WithTextMatcher(org.eclipse.reddeer.core.matcher.WithTextMatcher) DefaultSpinner(org.eclipse.reddeer.swt.impl.spinner.DefaultSpinner) PushButton(org.eclipse.reddeer.swt.impl.button.PushButton) Test(org.junit.Test)

Example 19 with WithTextMatcher

use of org.eclipse.reddeer.core.matcher.WithTextMatcher in project jbosstools-openshift by jbosstools.

the class ShellWithButton method lookForShellWithButton.

private static org.eclipse.swt.widgets.Shell lookForShellWithButton(final String title, final String buttonLabel) {
    Matcher<String> titleMatcher = new WithTextMatcher(title);
    Matcher<String> buttonMatcher = new BaseMatcher<String>() {

        @Override
        public boolean matches(Object obj) {
            if (obj instanceof Control) {
                final Control control = (Control) obj;
                ReferencedComposite ref = new ReferencedComposite() {

                    @Override
                    public Control getControl() {
                        return control;
                    }
                };
                try {
                    new PushButton(ref, buttonLabel);
                    return true;
                } catch (CoreLayerException e) {
                // ok, this control doesn't contain the button
                }
            }
            return false;
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("containing button '" + buttonLabel + "'");
        }
    };
    @SuppressWarnings("unchecked") Matcher<String> matcher = new AndMatcher(titleMatcher, buttonMatcher);
    return ShellLookup.getInstance().getShell(matcher);
}
Also used : AndMatcher(org.eclipse.reddeer.common.matcher.AndMatcher) Control(org.eclipse.swt.widgets.Control) Description(org.hamcrest.Description) BaseMatcher(org.hamcrest.BaseMatcher) WithTextMatcher(org.eclipse.reddeer.core.matcher.WithTextMatcher) PushButton(org.eclipse.reddeer.swt.impl.button.PushButton) CoreLayerException(org.eclipse.reddeer.core.exception.CoreLayerException) ReferencedComposite(org.eclipse.reddeer.core.reference.ReferencedComposite)

Aggregations

WithTextMatcher (org.eclipse.reddeer.core.matcher.WithTextMatcher)19 PushButton (org.eclipse.reddeer.swt.impl.button.PushButton)15 OkButton (org.eclipse.reddeer.swt.impl.button.OkButton)9 LabeledText (org.eclipse.reddeer.swt.impl.text.LabeledText)8 DefaultShell (org.eclipse.reddeer.swt.impl.shell.DefaultShell)7 WaitUntil (org.eclipse.reddeer.common.wait.WaitUntil)5 WaitTimeoutExpiredException (org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException)4 CoreLayerException (org.eclipse.reddeer.core.exception.CoreLayerException)4 ShellIsAvailable (org.eclipse.reddeer.swt.condition.ShellIsAvailable)3 RadioButton (org.eclipse.reddeer.swt.impl.button.RadioButton)3 DefaultTree (org.eclipse.reddeer.swt.impl.tree.DefaultTree)3 JobIsRunning (org.eclipse.reddeer.workbench.core.condition.JobIsRunning)3 Test (org.junit.Test)3 RedDeerException (org.eclipse.reddeer.common.exception.RedDeerException)2 RegexMatcher (org.eclipse.reddeer.common.matcher.RegexMatcher)2 WaitWhile (org.eclipse.reddeer.common.wait.WaitWhile)2 WidgetIsFound (org.eclipse.reddeer.core.condition.WidgetIsFound)2 Button (org.eclipse.reddeer.swt.api.Button)2 TreeItem (org.eclipse.reddeer.swt.api.TreeItem)2 CheckBox (org.eclipse.reddeer.swt.impl.button.CheckBox)2