diff options
author | Martin Fluegge | 2010-12-20 16:21:16 +0000 |
---|---|---|
committer | Martin Fluegge | 2010-12-20 16:21:16 +0000 |
commit | b50c94666679652dbf059b91a0f8e3e3e5d71365 (patch) | |
tree | 345220b00a08d6c2d482d444cf145aa057ec6262 /plugins/org.eclipse.emf.cdo.tests.ui | |
parent | 8f8dcd31143c522eda8bc7f8175860c54e505d73 (diff) | |
download | cdo-b50c94666679652dbf059b91a0f8e3e3e5d71365.tar.gz cdo-b50c94666679652dbf059b91a0f8e3e3e5d71365.tar.xz cdo-b50c94666679652dbf059b91a0f8e3e3e5d71365.zip |
[320193] [Dawn] Provide a flexible testing environment for UI tests
https://bugs.eclipse.org/bugs/show_bug.cgi?id=320193
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests.ui')
3 files changed, 71 insertions, 40 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AbstractCDOUITest.java b/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AbstractCDOUITest.java index 9c0d1aa7c4..7628b0d8ef 100644 --- a/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AbstractCDOUITest.java +++ b/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AbstractCDOUITest.java @@ -17,6 +17,7 @@ import org.eclipse.net4j.util.om.OMPlatform; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; import org.eclipse.swtbot.swt.finder.SWTBot; import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; import org.eclipse.swtbot.swt.finder.keyboard.Keyboard; @@ -37,14 +38,40 @@ import java.util.concurrent.TimeUnit; /** * @author Martin Fluegge */ -public abstract class AbstractCDOUITest extends AbstractCDOTest +public abstract class AbstractCDOUITest<T extends SWTWorkbenchBot> extends AbstractCDOTest { + private T bot; + @Override public void setUp() throws Exception { + super.setUp(); SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; SWTBotPreferences.SCREENSHOTS_DIR = OMPlatform.INSTANCE.getProperty("java.io.tmpdir") + "/cdotests"; - super.setUp(); + createBot(); + } + + @SuppressWarnings("unchecked") + protected void createBot() + { + setBot((T)new SWTWorkbenchBot()); + } + + protected T getBot() + { + return bot; + } + + protected void setBot(T bot) + { + this.bot = bot; + } + + @Override + public void tearDown() throws Exception + { + super.tearDown(); + closeAllEditors(); } protected void closeAllEditors() diff --git a/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AllTestsCDOUISWTBot.java b/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AllTestsCDOUISWTBot.java index 345a0d8ab3..f177a00e2c 100644 --- a/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AllTestsCDOUISWTBot.java +++ b/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AllTestsCDOUISWTBot.java @@ -10,17 +10,40 @@ */ package org.eclipse.emf.cdo.tests.ui; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; +import org.eclipse.emf.cdo.tests.AllTests; +import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; +import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite; + +import java.util.List; + +import junit.framework.Test; +import junit.framework.TestSuite; /** * This test suite should be executed as SWTBot test. * * @author Martin Fluegge */ -@RunWith(Suite.class) -@SuiteClasses({ CDOSessionsViewTest.class }) -public class AllTestsCDOUISWTBot +public class AllTestsCDOUISWTBot extends ConfigTestSuite { + public static Test suite() + { + TestSuite testSuite = (TestSuite)new AllTestsCDOUISWTBot().getTestSuite(AllTests.class.getName()); + return testSuite; + } + + @Override + protected void initConfigSuites(TestSuite parent) + { + addScenario(parent, COMBINED, MEM, TCP, NATIVE); + addScenario(parent, COMBINED, MEM_BRANCHES, TCP, NATIVE); + addScenario(parent, COMBINED, MEM_BRANCHES, TCP, LEGACY); + addScenario(parent, COMBINED, MEM_BRANCHES, TCP, LEGACY); + } + + @Override + protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses) + { + testClasses.add(CDOSessionsViewTest.class); + } } diff --git a/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/CDOSessionsViewTest.java b/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/CDOSessionsViewTest.java index 57be083e83..c8a4e31348 100644 --- a/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/CDOSessionsViewTest.java +++ b/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/CDOSessionsViewTest.java @@ -15,7 +15,6 @@ import org.eclipse.emf.cdo.internal.ui.views.CDOSessionsView; import org.eclipse.swt.SWT; import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; -import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot; import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.eclipse.swtbot.swt.finder.keyboard.Keyboard; import org.eclipse.swtbot.swt.finder.keyboard.KeyboardFactory; @@ -25,8 +24,6 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; import org.eclipse.ui.IViewPart; import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -34,24 +31,8 @@ import org.junit.runner.RunWith; * @author Martin Fluegge */ @RunWith(SWTBotJunit4ClassRunner.class) -public class CDOSessionsViewTest extends AbstractCDOUITest +public class CDOSessionsViewTest extends AbstractCDOUITest<SWTWorkbenchBot> { - private static SWTWorkbenchBot bot; - - @BeforeClass - public static void beforeClass() throws Exception - { - bot = new SWTGefBot(); - bot.viewByTitle("Welcome").close(); - } - - @Override - @Before - public void setUp() throws Exception - { - super.setUp(); - } - @Override @After public void tearDown() throws Exception @@ -61,16 +42,16 @@ public class CDOSessionsViewTest extends AbstractCDOUITest } @Test - public void openSessionsView() throws Exception + public void testOpenSessionsView() throws Exception { - bot.menu("Window").menu("Show View").menu("Other...").click(); + getBot().menu("Window").menu("Show View").menu("Other...").click(); - SWTBotShell shell = bot.shell("Show View"); + SWTBotShell shell = getBot().shell("Show View"); shell.activate(); - bot.tree().expandNode("CDO").select("CDO Sessions"); - bot.button("OK").click(); + getBot().tree().expandNode("CDO").select("CDO Sessions"); + getBot().button("OK").click(); - SWTBotView activeView = bot.activeView(); + SWTBotView activeView = getBot().activeView(); assertEquals("CDO Sessions", activeView.getViewReference().getTitle()); IViewPart view = activeView.getViewReference().getView(false); assertInstanceOf(CDOSessionsView.class, view); @@ -79,9 +60,9 @@ public class CDOSessionsViewTest extends AbstractCDOUITest activeView.toolbarButton(org.eclipse.emf.cdo.internal.ui.messages.Messages.getString("OpenSessionAction.0")) .click(); - SWTBotShell openSessionDialog = bot.shell("Open Session"); + SWTBotShell openSessionDialog = getBot().shell("Open Session"); openSessionDialog.activate(); - SWTBotCCombo ccomboBox = bot.ccomboBox(0); + SWTBotCCombo ccomboBox = getBot().ccomboBox(0); ccomboBox.setFocus(); Keyboard keyboard = KeyboardFactory.getDefaultKeyboard(ccomboBox.widget, null); @@ -91,15 +72,15 @@ public class CDOSessionsViewTest extends AbstractCDOUITest keyboard.pressShortcut(SWT.SHIFT, '7'); keyboard.typeText("localhost"); - SWTBotCCombo repositoryNameCcomboBox = bot.ccomboBox(1); + SWTBotCCombo repositoryNameCcomboBox = getBot().ccomboBox(1); repositoryNameCcomboBox.setFocus(); - typeTextToFocusedWidget("repo1", bot, false); + typeTextToFocusedWidget("repo1", getBot(), false); - bot.button("OK").click(); + getBot().button("OK").click(); activeView.setFocus(); - SWTBotTree tree = bot.tree(0); + SWTBotTree tree = getBot().tree(0); sleep(3000); assertEquals(1, tree.getAllItems().length); assertEquals("Session repo1 [2]", tree.getAllItems()[0].getText()); |