ff28acb41d41780d745a683e24a2cc94e7ad6443
[taxeditor.git] / eu.etaxonomy.taxeditor.test / src / test / java / eu / etaxonomy / taxeditor / test / AbstractEditorTest.java
1 /**
2 *
3 */
4 package eu.etaxonomy.taxeditor.test;
5
6 import java.util.List;
7
8 import org.eclipse.swt.widgets.Tree;
9 import org.eclipse.swt.widgets.Widget;
10 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
11 import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
12 import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
13 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
14 import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
15 import org.eclipse.swtbot.swt.finder.finders.ChildrenControlFinder;
16 import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
17 import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
18 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
19 import org.junit.Before;
20 import org.junit.runner.RunWith;
21
22 /**
23 * @author n.hoffmann
24 *
25 */
26 @RunWith(SWTBotJunit4ClassRunner.class)
27 public abstract class AbstractEditorTest {
28
29 protected SWTWorkbenchBot bot;
30
31 @Before
32 public void setup() {
33 bot = new SWTWorkbenchBot();
34 SWTBotPreferences.TIMEOUT = 300000;
35
36 String activeText = bot.activeShell().getText();
37 if(activeText.equals("Connecting to datasource: cdm")){
38 bot.waitUntil(Conditions.shellIsActive("Login"));
39 bot.button("Cancel").click();
40 }
41 }
42
43
44 /**
45 * @return
46 * @throws WidgetNotFoundException
47 */
48 public SWTBotTree tree(Widget widget) throws WidgetNotFoundException {
49 List<Tree> controls = new ChildrenControlFinder(widget).findControls(WidgetMatcherFactory.widgetOfType(Tree.class));
50 if (controls.isEmpty())
51 throw new WidgetNotFoundException("Could not find any tree");
52 SWTBotTree tree = new SWTBotTree((Tree) controls.get(0));
53 return tree;
54 }
55
56 /**
57 * @return
58 * @throws WidgetNotFoundException
59 */
60 public SWTBotView view(String title) throws WidgetNotFoundException {
61 return bot.viewByTitle(title);
62 }
63
64
65 }