From e267fdab2c1565c0f28fb4c7aa69e44a9d883abd Mon Sep 17 00:00:00 2001 From: "n.hoffmann" Date: Thu, 6 Oct 2011 11:40:25 +0000 Subject: [PATCH] Reorganized the test classes --- .gitattributes | 14 +++- eu.etaxonomy.taxeditor.test/.classpath | 17 ++-- .../META-INF/MANIFEST.MF | 10 ++- .../menu/general}/NewMenuTest.java | 20 +++-- .../contextmenu}/ClassificationTest.java | 13 +-- .../newWizard/NewTaxonWizardTest.java | 55 ++++++++++++ .../taxeditor/test/AbstractEditorTest.java | 61 +++++--------- .../taxeditor/test/ContextMenuHelper.java | 4 +- .../etaxonomy/taxeditor/test/LoginTest.java | 18 ---- .../taxeditor/test/NewTaxonWizardTest.java | 35 -------- .../etaxonomy/taxeditor/test/SwtBotUtils.java | 83 +++++++++++++++++++ .../taxeditor/ui/dialogs/LoginDialogTest.java | 27 ++++++ .../AbstractSelectionElementTest.java | 27 ++++++ .../ClassificationSelectionElementTest.java | 30 +++++++ .../selection/NameSelectionElementTest.java | 26 ++++++ .../TaxonNodeSelectionElementTest.java | 27 ++++++ .../selection/TaxonSelectionElementTest.java | 30 +++++++ 17 files changed, 373 insertions(+), 124 deletions(-) rename eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/{test => application/menu/general}/NewMenuTest.java (73%) rename eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/{test => navigation/navigator/contextmenu}/ClassificationTest.java (72%) create mode 100644 eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonWizardTest.java delete mode 100644 eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/LoginTest.java delete mode 100644 eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/NewTaxonWizardTest.java create mode 100644 eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/SwtBotUtils.java create mode 100644 eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/dialogs/LoginDialogTest.java create mode 100644 eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/AbstractSelectionElementTest.java create mode 100644 eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/ClassificationSelectionElementTest.java create mode 100644 eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/NameSelectionElementTest.java create mode 100644 eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/TaxonNodeSelectionElementTest.java create mode 100644 eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/TaxonSelectionElementTest.java diff --git a/.gitattributes b/.gitattributes index 29b16e4e5..cc8c8fd5f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1323,12 +1323,18 @@ eu.etaxonomy.taxeditor.test/META-INF/MANIFEST.MF -text eu.etaxonomy.taxeditor.test/build.properties -text eu.etaxonomy.taxeditor.test/ide/eclipse/EDITor[!!-~]Tests.launch -text eu.etaxonomy.taxeditor.test/src/main/resources/log4j.xml -text +eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/application/menu/general/NewMenuTest.java -text +eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/navigation/navigator/contextmenu/ClassificationTest.java -text +eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonWizardTest.java -text eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/AbstractEditorTest.java -text -eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ClassificationTest.java -text eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ContextMenuHelper.java -text -eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/LoginTest.java -text -eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/NewMenuTest.java -text -eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/NewTaxonWizardTest.java -text +eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/SwtBotUtils.java -text +eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/dialogs/LoginDialogTest.java -text +eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/AbstractSelectionElementTest.java -text +eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/ClassificationSelectionElementTest.java -text +eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/NameSelectionElementTest.java -text +eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/TaxonNodeSelectionElementTest.java -text +eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/TaxonSelectionElementTest.java -text eu.etaxonomy.taxeditor/.classpath -text eu.etaxonomy.taxeditor/.project -text eu.etaxonomy.taxeditor/deploy_nightly.sh -text diff --git a/eu.etaxonomy.taxeditor.test/.classpath b/eu.etaxonomy.taxeditor.test/.classpath index 9926b7092..c5d344b0e 100644 --- a/eu.etaxonomy.taxeditor.test/.classpath +++ b/eu.etaxonomy.taxeditor.test/.classpath @@ -1,8 +1,9 @@ - - - - - - - - + + + + + + + + + diff --git a/eu.etaxonomy.taxeditor.test/META-INF/MANIFEST.MF b/eu.etaxonomy.taxeditor.test/META-INF/MANIFEST.MF index 73df11ab2..998796316 100644 --- a/eu.etaxonomy.taxeditor.test/META-INF/MANIFEST.MF +++ b/eu.etaxonomy.taxeditor.test/META-INF/MANIFEST.MF @@ -14,5 +14,13 @@ Require-Bundle: org.apache.log4j, org.eclipse.swtbot.junit4_x, org.hamcrest, org.eclipse.ui.ide, - org.junit4 + org.junit4, + eu.etaxonomy.taxeditor.application;bundle-version="3.0.6", + eu.etaxonomy.taxeditor.bulkeditor;bundle-version="3.0.6", + eu.etaxonomy.taxeditor.cdmlib;bundle-version="3.0.6", + eu.etaxonomy.taxeditor.editor;bundle-version="3.0.6", + eu.etaxonomy.taxeditor.help;bundle-version="3.0.6", + eu.etaxonomy.taxeditor.navigation;bundle-version="3.0.6", + eu.etaxonomy.taxeditor.printpublisher;bundle-version="3.0.6", + eu.etaxonomy.taxeditor.store;bundle-version="3.0.6" Eclipse-RegisterBuddy: org.apache.log4j diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/NewMenuTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/application/menu/general/NewMenuTest.java similarity index 73% rename from eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/NewMenuTest.java rename to eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/application/menu/general/NewMenuTest.java index cb49f1f04..0dc906526 100644 --- a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/NewMenuTest.java +++ b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/application/menu/general/NewMenuTest.java @@ -1,10 +1,12 @@ -package eu.etaxonomy.taxeditor.test; +package eu.etaxonomy.taxeditor.application.menu.general; import org.eclipse.swtbot.eclipse.finder.waits.Conditions; import org.junit.Test; +import eu.etaxonomy.taxeditor.test.AbstractEditorTest; + /** - * Open all new menus + * Open all "General -> New" menus * * @author n.hoffmann * @@ -14,48 +16,48 @@ public class NewMenuTest extends AbstractEditorTest { @Test public void canOpenNewWizardForTaxon(){ openNewWizardFor("Taxon"); - cancel(); + utils.cancel(); } @Test public void canOpenNewWizardForReference(){ openNewWizardFor("Reference"); - cancel(); + utils.cancel(); } @Test public void canOpenNewWizardForName(){ openNewWizardFor("Name"); - cancel(); + utils.cancel(); } @Test public void canOpenNewWizardForTeam(){ openNewWizardFor("Team"); - cancel(); + utils.cancel(); } @Test public void canOpenNewWizardForPerson(){ openNewWizardFor("Person"); - cancel(); + utils.cancel(); } @Test public void canOpenNewWizardForSpecimen(){ openNewWizardFor("Specimen"); - cancel(); + utils.cancel(); } @Test public void canOpenNewWizardForClassification(){ openNewWizardFor("Classification"); - cancel(); + utils.cancel(); } private void openNewWizardFor(String entity) { diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ClassificationTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/navigation/navigator/contextmenu/ClassificationTest.java similarity index 72% rename from eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ClassificationTest.java rename to eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/navigation/navigator/contextmenu/ClassificationTest.java index d73aa5bcc..6d4dac58c 100644 --- a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ClassificationTest.java +++ b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/navigation/navigator/contextmenu/ClassificationTest.java @@ -1,7 +1,7 @@ /** * */ -package eu.etaxonomy.taxeditor.test; +package eu.etaxonomy.taxeditor.navigation.navigator.contextmenu; import org.eclipse.swtbot.eclipse.finder.waits.Conditions; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; @@ -9,6 +9,9 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; import org.junit.Before; import org.junit.Test; +import eu.etaxonomy.taxeditor.test.AbstractEditorTest; +import eu.etaxonomy.taxeditor.test.ContextMenuHelper; + /** * @author n.hoffmann * @@ -21,8 +24,8 @@ public class ClassificationTest extends AbstractEditorTest { @Before public void setup() { super.setup(); - navigatorView = view("Taxon Navigator"); - tree = tree(navigatorView.getWidget()); + navigatorView = utils.view("Taxon Navigator"); + tree = utils.tree(navigatorView.getWidget()); } @Test @@ -30,7 +33,7 @@ public class ClassificationTest extends AbstractEditorTest { tree.select(0); ContextMenuHelper.clickContextMenu(tree, "Delete"); bot.waitUntil(Conditions.shellIsActive("Confirm Deletion")); - bot.button("OK").click(); + utils.ok(); } @Test @@ -39,6 +42,6 @@ public class ClassificationTest extends AbstractEditorTest { ContextMenuHelper.clickContextMenu(tree, "New", "Classification"); bot.waitUntil(Conditions.shellIsActive("New Entity")); bot.textWithLabel("Label").setText("Classification"); - bot.button("Finish").click(); + utils.finish(); } } diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonWizardTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonWizardTest.java new file mode 100644 index 000000000..1c09585e5 --- /dev/null +++ b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonWizardTest.java @@ -0,0 +1,55 @@ +/** + * + */ +package eu.etaxonomy.taxeditor.newWizard; + +import junit.framework.Assert; + +import org.eclipse.swtbot.eclipse.finder.waits.Conditions; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton; +import org.junit.Test; + +import eu.etaxonomy.taxeditor.test.AbstractEditorTest; + +/** + * @author n.hoffmann + * + */ +public class NewTaxonWizardTest extends AbstractEditorTest { + + @Override + public void setup() { + super.setup(); + bot.menu("General").menu("New").menu("Taxon").click(); + bot.waitUntil(Conditions.shellIsActive("New Entity")); + } + + @Test + public void unalteredDialogCanNotBefinished() { + boolean finishIsEnabled = bot.button("Finish").isEnabled(); + Assert.assertEquals(false, finishIsEnabled); + utils.cancel(); + } + + @Test + public void canCreateNewTaxonMinimal(){ + utils.openFilteredSelection(0, "Choose a Classification"); + + SWTBotButton okButton = bot.button(1); + bot.text(0).setText("?"); + bot.waitUntil(Conditions.widgetIsEnabled(okButton)); + utils.ok(); + bot.waitUntil(Conditions.shellIsActive("New Entity")); + String newTaxonName = "Test taxon Smartbert"; + bot.textWithLabel("New Taxon").setText(newTaxonName); + bot.waitUntil(Conditions.widgetIsEnabled(bot.button("Finish"))); + utils.finish(); + +// bot.waitUntil(Conditions.waitForEditor(WithPartId.withPartId(MultiPageTaxonEditor.ID))); +// Assert.assertEquals(newTaxonName, bot.activeEditor().getTitle()); + } + + + + +} diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/AbstractEditorTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/AbstractEditorTest.java index f6da7727e..78a24ab76 100644 --- a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/AbstractEditorTest.java +++ b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/AbstractEditorTest.java @@ -3,19 +3,10 @@ */ package eu.etaxonomy.taxeditor.test; -import java.util.List; - -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.Widget; import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory; import org.eclipse.swtbot.eclipse.finder.waits.Conditions; -import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; -import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; -import org.eclipse.swtbot.swt.finder.finders.ChildrenControlFinder; import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; import org.junit.Before; import org.junit.runner.RunWith; @@ -28,48 +19,34 @@ public abstract class AbstractEditorTest { protected SWTWorkbenchBot bot; + public SwtBotUtils utils; + @Before public void setup() { bot = new SWTWorkbenchBot(); SWTBotPreferences.TIMEOUT = 300000; + utils = new SwtBotUtils(bot); + + // unfortunately swt bot is not available at the time this is set up +// if("Choose a nomenclatural code".equals(getActiveShellHeadline())){ +// ok(); +// bot.waitUntil(Conditions.shellIsActive("Nomenclatural code set")); +// ok(); +// } - String activeText = bot.activeShell().getText(); - if(activeText.equals("Connecting to datasource: cdm")){ - bot.waitUntil(Conditions.shellIsActive("Login")); - bot.button("Cancel").click(); + if("Connecting to datasource: cdm".equals(utils.getActiveShellHeadline())){ + performLogin(); } } - - - /** - * @return - * @throws WidgetNotFoundException - */ - public SWTBotTree tree(Widget widget) throws WidgetNotFoundException { - List controls = new ChildrenControlFinder(widget).findControls(WidgetMatcherFactory.widgetOfType(Tree.class)); - if (controls.isEmpty()) - throw new WidgetNotFoundException("Could not find any tree"); - SWTBotTree tree = new SWTBotTree((Tree) controls.get(0)); - return tree; - } - - /** - * @return - * @throws WidgetNotFoundException - */ - public SWTBotView view(String title) throws WidgetNotFoundException { - return bot.viewByTitle(title); - } - public void cancel() { - clickButton("Cancel"); + private void performLogin(){ + bot.waitUntil(Conditions.shellIsActive("Login")); + bot.textWithLabel("Username").setText("admin"); + bot.textWithLabel("Password").setText("00000"); + bot.button("OK").click(); } - public void ok() { - clickButton("OK"); - } + - public void clickButton(String label) { - bot.button(label).click(); - } + } diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ContextMenuHelper.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ContextMenuHelper.java index 37371d05c..8fe523c70 100644 --- a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ContextMenuHelper.java +++ b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/ContextMenuHelper.java @@ -24,9 +24,9 @@ public class ContextMenuHelper { * Clicks the context menu matching the text. * * @param text - * the text on the context menu. + * the text on the context menu. * @throws WidgetNotFoundException - * if the widget is not found. + * if the widget is not found. */ public static void clickContextMenu(final AbstractSWTBot bot, final String... texts) { diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/LoginTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/LoginTest.java deleted file mode 100644 index e9ac066fa..000000000 --- a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/LoginTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package eu.etaxonomy.taxeditor.test; - -import org.eclipse.swtbot.eclipse.finder.waits.Conditions; -import org.junit.Test; - - -public class LoginTest extends AbstractEditorTest{ - - @Test - public void canLoginAsAdmin() throws Exception { - bot.menu("General").menu("Login").click(); - bot.waitUntil(Conditions.shellIsActive("Login")); - bot.textWithLabel("Username").setText("admin"); - bot.textWithLabel("Password").setText("0000"); - bot.button("Cancel").click(); - } - -} diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/NewTaxonWizardTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/NewTaxonWizardTest.java deleted file mode 100644 index 7fc285c09..000000000 --- a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/NewTaxonWizardTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * - */ -package eu.etaxonomy.taxeditor.test; - -import org.eclipse.swtbot.eclipse.finder.waits.Conditions; -import org.junit.After; -import org.junit.Ignore; -import org.junit.Test; - -/** - * @author n.hoffmann - * - */ -public class NewTaxonWizardTest extends AbstractEditorTest { - - @Override - public void setup() { - super.setup(); - bot.menu("General").menu("New").menu("Taxon").click(); - bot.waitUntil(Conditions.shellIsActive("New Entity")); - } - - @Ignore - @Test - public void canSelectClassification() { - bot.button("Browse existing").click(); - bot.waitUntil(Conditions.shellIsActive("Choose a Classification")); - } - - @After - public void tearDown() { - clickButton("Finish"); - } -} diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/SwtBotUtils.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/SwtBotUtils.java new file mode 100644 index 000000000..b2d7c455a --- /dev/null +++ b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/SwtBotUtils.java @@ -0,0 +1,83 @@ +package eu.etaxonomy.taxeditor.test; + +import java.util.List; + +import org.eclipse.osgi.internal.loader.FilteredSourcePackage; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.Widget; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory; +import org.eclipse.swtbot.eclipse.finder.waits.Conditions; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; +import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; +import org.eclipse.swtbot.swt.finder.finders.ChildrenControlFinder; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; + +public class SwtBotUtils { + + private SWTWorkbenchBot bot; + + public SwtBotUtils(SWTWorkbenchBot bot) { + this.bot = bot; + } + + /** + * @return + * @throws WidgetNotFoundException + */ + public SWTBotTree tree(Widget widget) throws WidgetNotFoundException { + List controls = new ChildrenControlFinder(widget).findControls(WidgetMatcherFactory.widgetOfType(Tree.class)); + if (controls.isEmpty()) + throw new WidgetNotFoundException("Could not find any tree"); + SWTBotTree tree = new SWTBotTree((Tree) controls.get(0)); + return tree; + } + + /** + * + * @param index the index of the SelectionElement + * @param dialogName the title of the expected dialog + */ + public void openFilteredSelection(int index, String dialogName){ + SWTBotButton existing = bot.buttonWithTooltip("Browse existing", index); + existing.click(); + bot.waitUntil(Conditions.shellIsActive(dialogName)); + } + + /** + * @return + * @throws WidgetNotFoundException + */ + public SWTBotView view(String title) throws WidgetNotFoundException { + return getBot().viewByTitle(title); + } + + public void cancel() { + clickButton("Cancel"); + } + + public void ok() { + clickButton("OK"); + } + + public void finish() { + clickButton("Finish"); + } + + public void clickButton(String label) { + getBot().button(label).click(); + } + + public String getActiveShellHeadline(){ + return getBot().activeShell().getText(); + } + + public SWTWorkbenchBot getBot() { + return bot; + } + + public void setBot(SWTWorkbenchBot bot) { + this.bot = bot; + } +} diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/dialogs/LoginDialogTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/dialogs/LoginDialogTest.java new file mode 100644 index 000000000..2905ba58b --- /dev/null +++ b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/dialogs/LoginDialogTest.java @@ -0,0 +1,27 @@ +package eu.etaxonomy.taxeditor.ui.dialogs; + +import org.eclipse.swtbot.eclipse.finder.waits.Conditions; +import org.junit.Test; + +import eu.etaxonomy.taxeditor.test.AbstractEditorTest; + + +public class LoginDialogTest extends AbstractEditorTest{ + + @Test + public void canLoginAsAdmin() throws Exception { + bot.menu("General").menu("Login").click(); + bot.waitUntil(Conditions.shellIsActive("Login")); + bot.textWithLabel("Username").setText("admin"); + bot.textWithLabel("Password").setText("00000"); + utils.ok(); + } + + @Test + public void canCancelLogin() throws Exception { + bot.menu("General").menu("Login").click(); + bot.waitUntil(Conditions.shellIsActive("Login")); + utils.cancel(); + } + +} diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/AbstractSelectionElementTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/AbstractSelectionElementTest.java new file mode 100644 index 000000000..adccccfe3 --- /dev/null +++ b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/AbstractSelectionElementTest.java @@ -0,0 +1,27 @@ +/** + * + */ +package eu.etaxonomy.taxeditor.ui.selection; + +import org.junit.After; + +import eu.etaxonomy.taxeditor.test.AbstractEditorTest; + +/** + * This test will only test the selection element itself. The test may have to start other + * dialogs open windows before to get at the selection element. Any errors on the way + * should be handled by different tests. + * + * @author n.hoffmann + * + */ +public abstract class AbstractSelectionElementTest extends AbstractEditorTest{ + + + + @After + public void tearDown() { + utils.cancel(); + } + +} diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/ClassificationSelectionElementTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/ClassificationSelectionElementTest.java new file mode 100644 index 000000000..245f93498 --- /dev/null +++ b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/ClassificationSelectionElementTest.java @@ -0,0 +1,30 @@ +/** + * + */ +package eu.etaxonomy.taxeditor.ui.selection; + +import org.eclipse.swtbot.eclipse.finder.waits.Conditions; +import org.junit.Test; + +/** + * This test will only test the selection element itself. The test may have to start other + * dialogs open windows before to get at the selection element. Any errors on the way + * should be handled by different tests. + * + * @author n.hoffmann + * + */ +public class ClassificationSelectionElementTest extends AbstractSelectionElementTest{ + @Override + public void setup() { + super.setup(); + bot.menu("General").menu("New").menu("Taxon").click(); + bot.waitUntil(Conditions.shellIsActive("New Entity")); + } + + @Test + public void canSelectClassification() { + utils.openFilteredSelection(0, "Choose a Classification"); + utils.cancel(); + } +} diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/NameSelectionElementTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/NameSelectionElementTest.java new file mode 100644 index 000000000..a8b653ca5 --- /dev/null +++ b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/NameSelectionElementTest.java @@ -0,0 +1,26 @@ +/** + * + */ +package eu.etaxonomy.taxeditor.ui.selection; + +import org.eclipse.swtbot.eclipse.finder.waits.Conditions; +import org.junit.Test; + +/** + * @author n.hoffmann + * + */ +public class NameSelectionElementTest extends AbstractSelectionElementTest { + @Override + public void setup() { + super.setup(); + bot.menu("General").menu("New").menu("Taxon").click(); + bot.waitUntil(Conditions.shellIsActive("New Entity")); + } + + @Test + public void canSelectName() { + utils.openFilteredSelection(3, "Choose a name"); + utils.cancel(); + } +} diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/TaxonNodeSelectionElementTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/TaxonNodeSelectionElementTest.java new file mode 100644 index 000000000..2b29c8739 --- /dev/null +++ b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/TaxonNodeSelectionElementTest.java @@ -0,0 +1,27 @@ +/** + * + */ +package eu.etaxonomy.taxeditor.ui.selection; + +import org.eclipse.swtbot.eclipse.finder.waits.Conditions; +import org.junit.Test; + +/** + * @author n.hoffmann + * + */ +public class TaxonNodeSelectionElementTest extends AbstractSelectionElementTest { + @Override + public void setup() { + super.setup(); + bot.menu("General").menu("New").menu("Taxon").click(); + bot.waitUntil(Conditions.shellIsActive("New Entity")); + } + + @Test + public void canSelectTaxon() { + utils.openFilteredSelection(1, "Select parent taxon"); + utils.cancel(); + } + +} diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/TaxonSelectionElementTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/TaxonSelectionElementTest.java new file mode 100644 index 000000000..af84076b8 --- /dev/null +++ b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/selection/TaxonSelectionElementTest.java @@ -0,0 +1,30 @@ +/** + * + */ +package eu.etaxonomy.taxeditor.ui.selection; + +import org.eclipse.swtbot.eclipse.finder.waits.Conditions; +import org.junit.Test; + +/** + * This test will only test the selection element itself. The test may have to start other + * dialogs open windows before to get at the selection element. Any errors on the way + * should be handled by different tests. + * + * @author n.hoffmann + * + */ +public class TaxonSelectionElementTest extends AbstractSelectionElementTest { + @Override + public void setup() { + super.setup(); + bot.menu("General").menu("New").menu("Taxon").click(); + bot.waitUntil(Conditions.shellIsActive("New Entity")); + } + + @Test + public void canSelectTaxon() { + utils.openFilteredSelection(2, "Choose a taxon"); + utils.cancel(); + } +} -- 2.34.1