Skip to content

Commit

Permalink
Remove breakpoints button changed text in Photon. Fixes #1923
Browse files Browse the repository at this point in the history
Signed-off-by: Rastislav Wagner <rawagner@redhat.com>
  • Loading branch information
rawagner authored and odockal committed May 17, 2018
1 parent af6e411 commit 43373bb
Showing 1 changed file with 48 additions and 18 deletions.
Expand Up @@ -12,18 +12,27 @@

import java.util.List;

import org.eclipse.reddeer.common.condition.AbstractWaitCondition;
import org.eclipse.reddeer.common.wait.AbstractWait;
import org.eclipse.reddeer.common.wait.TimePeriod;
import org.eclipse.reddeer.common.wait.WaitUntil;
import org.eclipse.reddeer.common.wait.WaitWhile;
import org.eclipse.reddeer.core.condition.WidgetIsFound;
import org.eclipse.reddeer.core.matcher.WithMnemonicTextMatcher;
import org.eclipse.reddeer.core.matcher.WithTextMatcher;
import org.eclipse.reddeer.eclipse.exception.EclipseLayerException;
import org.eclipse.reddeer.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
import org.eclipse.reddeer.jface.wizard.WizardDialog;
import org.eclipse.reddeer.swt.api.Button;
import org.eclipse.reddeer.swt.api.Shell;
import org.eclipse.reddeer.swt.api.ToolItem;
import org.eclipse.reddeer.swt.api.TreeItem;
import org.eclipse.reddeer.swt.condition.ControlIsEnabled;
import org.eclipse.reddeer.swt.condition.ShellIsAvailable;
import org.eclipse.reddeer.swt.impl.button.OkButton;
import org.eclipse.reddeer.swt.impl.button.PushButton;
import org.eclipse.reddeer.swt.impl.menu.ContextMenuItem;
import org.eclipse.reddeer.swt.impl.button.YesButton;
import org.eclipse.reddeer.swt.impl.shell.DefaultShell;
import org.eclipse.reddeer.swt.impl.text.DefaultText;
import org.eclipse.reddeer.swt.impl.text.LabeledText;
import org.eclipse.reddeer.swt.impl.toolbar.DefaultToolItem;
import org.eclipse.reddeer.swt.impl.tree.DefaultTree;
Expand Down Expand Up @@ -54,11 +63,10 @@ public void addJavaExceptionBreakpoint(String exception) {
log.info("Adding java exception breakpoint '" + exception + "'");
open();
new DefaultToolItem(cTabItem.getFolder(), "Add Java Exception Breakpoint").click();
new DefaultShell("Add Java Exception Breakpoint");
new DefaultText().setText(exception);
new WaitUntil(new ControlIsEnabled(new OkButton()), TimePeriod.LONG);
new OkButton().click();
new WaitWhile(new ShellIsAvailable("Add Java Exception Breakpoint"));
FilteredItemsSelectionDialog breakpointsDialog = new FilteredItemsSelectionDialog(new WithTextMatcher("Add Java Exception Breakpoint"));
breakpointsDialog.setFilterText(exception);
new WaitUntil(new ControlIsEnabled(new OkButton(breakpointsDialog)), TimePeriod.LONG);
breakpointsDialog.ok();
};

/**
Expand All @@ -83,7 +91,7 @@ public Breakpoint getBreakpoint(String label) {
log.info("Accessing breakpoints in Breakpoints view");
open();
AbstractWait.sleep(TimePeriod.SHORT);
List<TreeItem> items = new DefaultTree(cTabItem).getItems();
List<TreeItem> items = new DefaultTree(this).getItems();
for (TreeItem item : items) {
log.debug("\tfound: " + item.getText());
if (item.getText().contains(label)) {
Expand All @@ -99,10 +107,22 @@ public Breakpoint getBreakpoint(String label) {
public void removeAllBreakpoints() {
log.info("Removing all breakpoints from Breakpoints view");
open();
if (new DefaultToolItem(cTabItem.getFolder(), "Remove All Breakpoints").isEnabled()) {
new DefaultToolItem(cTabItem.getFolder(), "Remove All Breakpoints").click();
new DefaultShell("Remove All Breakpoints").setFocus();
new PushButton("Yes").click();
ToolItem removeBreakpointsItem = new DefaultToolItem(cTabItem.getFolder(), "Remove All Breakpoints");
if (removeBreakpointsItem.isEnabled()) {
removeBreakpointsItem.click();
Shell removeBreakpointsShell = new DefaultShell("Remove All Breakpoints");

//photon changed button text
WidgetIsFound removeButtonTest = new WidgetIsFound(org.eclipse.swt.widgets.Button.class, removeBreakpointsShell.getControl(),
new WithMnemonicTextMatcher("Remove"));
Button button;
if(removeButtonTest.test()){
button = new PushButton((org.eclipse.swt.widgets.Button)removeButtonTest.getResult());
} else {
button = new YesButton(removeBreakpointsShell);
}
button.click();
new WaitWhile(new ShellIsAvailable(removeBreakpointsShell));
}
}

Expand All @@ -114,11 +134,21 @@ public void removeAllBreakpoints() {
public void importBreakpoints(String path) {
log.info("Importing breakpoints from '" + path + "'");
open();
new DefaultTree(cTabItem).setFocus();
new ContextMenuItem("Import Breakpoints...").select();
new DefaultShell("Import Breakpoints");
new LabeledText("From file:").setText(path);
new PushButton("Finish").click();
new WaitWhile(new ShellIsAvailable("Import Breakpoints"));
new DefaultTree(this).getContextMenu().getItem("Import Breakpoints...").select();
WizardDialog importBreakpointsDialog = new WizardDialog("Import Breakpoints");
importBreakpointsDialog.isOpen();
new LabeledText(importBreakpointsDialog, "From file:").setText(path);
new WaitUntil(new AbstractWaitCondition() {

@Override
public boolean test() {
return importBreakpointsDialog.isFinishEnabled();
}
}, TimePeriod.SHORT, false);
if(!importBreakpointsDialog.isFinishEnabled()) {
throw new EclipseLayerException("Finish button is not enabled. Dialog error is '"
+importBreakpointsDialog.getMessage()+"'");
}
importBreakpointsDialog.finish();
}
}

0 comments on commit 43373bb

Please sign in to comment.