Revision e267fdab
Added by Niels Hoffmann over 12 years ago
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/AbstractEditorTest.java | ||
---|---|---|
3 | 3 |
*/ |
4 | 4 |
package eu.etaxonomy.taxeditor.test; |
5 | 5 |
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
import org.eclipse.swt.widgets.Tree; |
|
9 |
import org.eclipse.swt.widgets.Widget; |
|
10 | 6 |
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; |
11 |
import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory; |
|
12 | 7 |
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 | 8 |
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; |
17 | 9 |
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; |
18 |
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; |
|
19 | 10 |
import org.junit.Before; |
20 | 11 |
import org.junit.runner.RunWith; |
21 | 12 |
|
... | ... | |
28 | 19 |
|
29 | 20 |
protected SWTWorkbenchBot bot; |
30 | 21 |
|
22 |
public SwtBotUtils utils; |
|
23 |
|
|
31 | 24 |
@Before |
32 | 25 |
public void setup() { |
33 | 26 |
bot = new SWTWorkbenchBot(); |
34 | 27 |
SWTBotPreferences.TIMEOUT = 300000; |
28 |
utils = new SwtBotUtils(bot); |
|
29 |
|
|
30 |
// unfortunately swt bot is not available at the time this is set up |
|
31 |
// if("Choose a nomenclatural code".equals(getActiveShellHeadline())){ |
|
32 |
// ok(); |
|
33 |
// bot.waitUntil(Conditions.shellIsActive("Nomenclatural code set")); |
|
34 |
// ok(); |
|
35 |
// } |
|
35 | 36 |
|
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(); |
|
37 |
if("Connecting to datasource: cdm".equals(utils.getActiveShellHeadline())){ |
|
38 |
performLogin(); |
|
40 | 39 |
} |
41 | 40 |
} |
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 | 41 |
|
64 |
public void cancel() { |
|
65 |
clickButton("Cancel"); |
|
42 |
private void performLogin(){ |
|
43 |
bot.waitUntil(Conditions.shellIsActive("Login")); |
|
44 |
bot.textWithLabel("Username").setText("admin"); |
|
45 |
bot.textWithLabel("Password").setText("00000"); |
|
46 |
bot.button("OK").click(); |
|
66 | 47 |
} |
67 | 48 |
|
68 |
public void ok() { |
|
69 |
clickButton("OK"); |
|
70 |
} |
|
49 |
|
|
71 | 50 |
|
72 |
public void clickButton(String label) { |
|
73 |
bot.button(label).click(); |
|
74 |
} |
|
51 |
|
|
75 | 52 |
} |
Also available in: Unified diff
Reorganized the test classes