diff options
author | Ketan Padegaonkar | 2011-03-02 06:25:31 +0000 |
---|---|---|
committer | Ketan Padegaonkar | 2011-03-02 06:25:31 +0000 |
commit | e147c1892763e3ac4b61c3146140b60fa9518f19 (patch) | |
tree | 719acd6702b1308c338a80ee940e144dc5ad4500 /org.eclipse.swtbot.forms.finder.test/src | |
parent | c154e48d049b9d39bf6597410c52003bc1374430 (diff) | |
download | org.eclipse.swtbot-e147c1892763e3ac4b61c3146140b60fa9518f19.tar.gz org.eclipse.swtbot-e147c1892763e3ac4b61c3146140b60fa9518f19.tar.xz org.eclipse.swtbot-e147c1892763e3ac4b61c3146140b60fa9518f19.zip |
Get the code to build. Make the tests use a full eclipse instance to begin with.
Diffstat (limited to 'org.eclipse.swtbot.forms.finder.test/src')
10 files changed, 68 insertions, 83 deletions
diff --git a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/AbstractSWTBotFormsTestCase.java b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/AbstractSWTBotFormsTestCase.java deleted file mode 100644 index ffea4527..00000000 --- a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/AbstractSWTBotFormsTestCase.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Chris Aniszczyk and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chris Aniszczyk <caniszczyk@gmail.com> - initial API and implementation - *******************************************************************************/ -package org.eclipse.swtbot.forms.finder.test; - -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swtbot.forms.finder.finders.SWTFormsBot; -import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.results.WidgetResult; -import org.junit.After; -import org.junit.Before; -import org.junit.runner.RunWith; - - -@RunWith(SWTBotJunit4ClassRunner.class) -public abstract class AbstractSWTBotFormsTestCase { - - public static Display display; - public static SWTFormsBot bot; - public static FormView view; - public static Thread thread; - - protected Shell createShell(final String text) { - return UIThreadRunnable.syncExec(new WidgetResult<Shell>() { - public Shell run() { - Shell shell = new Shell(display); - shell.setText(text); - shell.setLayout(new GridLayout()); - return shell; - } - }); - } - - @Before - public void setUp() { - display = new Display(); - bot = new SWTFormsBot(); - thread = new Thread("UI Thread") { - public void run() { - while ((display != null) && !display.isDisposed()) - if (!display.readAndDispatch()) - display.sleep(); - } - }; - thread.start(); - Shell shell = createShell("Forms Test"); - view = new FormView(shell); - shell.open(); - } - - @After - public void tearDown() { - // TODO - } - - -} diff --git a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/AbstractSWTBotFormsTest.java b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/AbstractSWTBotFormsTest.java new file mode 100644 index 00000000..5bbc0ffe --- /dev/null +++ b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/AbstractSWTBotFormsTest.java @@ -0,0 +1,57 @@ +/*******************************************************************************
+ * Copyright (c) 2010 Ketan Padegaonkar and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ketan Padegaonkar - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.forms.finder.test.widgets;
+
+import java.util.List;
+
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.forms.finder.finders.SWTFormsBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.junit.After;
+import org.junit.BeforeClass;
+
+public abstract class AbstractSWTBotFormsTest {
+
+ protected static SWTFormsBot bot = new SWTFormsBot();
+ protected static SWTWorkbenchBot workbench = new SWTWorkbenchBot();
+
+ @BeforeClass
+ public static void beforeClass() {
+ closeWelcomePage();
+ }
+
+ private static void closeWelcomePage() {
+ try {
+ System.setProperty("org.eclipse.swtbot.search.timeout", "0");
+ workbench.viewByTitle("Welcome").close();
+ } catch (WidgetNotFoundException e) {
+ // do nothing
+ } finally {
+ System.setProperty("org.eclipse.swtbot.search.timeout", "5000");
+ }
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ saveAndCloseAllEditors();
+ }
+
+ /**
+ * @throws WidgetNotFoundException
+ */
+ private void saveAndCloseAllEditors() {
+ List<? extends SWTBotEditor> editors = workbench.editors();
+ for (SWTBotEditor editor : editors) {
+ editor.saveAndClose();
+ }
+ }
+}
diff --git a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotExpandableCompositeTest.java b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotExpandableCompositeTest.java index 69712469..6d734caa 100644 --- a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotExpandableCompositeTest.java +++ b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotExpandableCompositeTest.java @@ -13,11 +13,13 @@ package org.eclipse.swtbot.forms.finder.test.widgets; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.eclipse.swtbot.forms.finder.test.AbstractSWTBotFormsTestCase; import org.eclipse.swtbot.forms.finder.widgets.SWTBotExpandableComposite; +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.junit.Test; +import org.junit.runner.RunWith; -public class SWTBotExpandableCompositeTest extends AbstractSWTBotFormsTestCase { +@RunWith(SWTBotJunit4ClassRunner.class) +public class SWTBotExpandableCompositeTest extends AbstractSWTBotFormsTest { @Test public void findExpandableComposite() throws Exception { diff --git a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotFormTextTest.java b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotFormTextTest.java index 11ba0008..a2f3e286 100644 --- a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotFormTextTest.java +++ b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotFormTextTest.java @@ -12,11 +12,10 @@ package org.eclipse.swtbot.forms.finder.test.widgets; import static org.junit.Assert.assertNotNull; -import org.eclipse.swtbot.forms.finder.test.AbstractSWTBotFormsTestCase; import org.eclipse.swtbot.forms.finder.widgets.SWTBotFormText; import org.junit.Test; -public class SWTBotFormTextTest extends AbstractSWTBotFormsTestCase { +public class SWTBotFormTextTest extends AbstractSWTBotFormsTest { @Test public void findsFormText() throws Exception { diff --git a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotHyperlinkTest.java b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotHyperlinkTest.java index 25a59ffd..1c193a98 100644 --- a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotHyperlinkTest.java +++ b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotHyperlinkTest.java @@ -13,11 +13,10 @@ package org.eclipse.swtbot.forms.finder.test.widgets; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.eclipse.swtbot.forms.finder.test.AbstractSWTBotFormsTestCase; import org.eclipse.swtbot.forms.finder.widgets.SWTBotHyperlink; import org.junit.Test; -public class SWTBotHyperlinkTest extends AbstractSWTBotFormsTestCase { +public class SWTBotHyperlinkTest extends AbstractSWTBotFormsTest { @Test public void findHyperlink() throws Exception { diff --git a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotImageHyperlinkTest.java b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotImageHyperlinkTest.java index 1e1e2d30..bff520bf 100644 --- a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotImageHyperlinkTest.java +++ b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotImageHyperlinkTest.java @@ -13,11 +13,10 @@ package org.eclipse.swtbot.forms.finder.test.widgets; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.eclipse.swtbot.forms.finder.test.AbstractSWTBotFormsTestCase; import org.eclipse.swtbot.forms.finder.widgets.SWTBotImageHyperlink; import org.junit.Test; -public class SWTBotImageHyperlinkTest extends AbstractSWTBotFormsTestCase { +public class SWTBotImageHyperlinkTest extends AbstractSWTBotFormsTest { @Test public void findImageHyperlink() throws Exception { diff --git a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotScrolledFormTextTest.java b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotScrolledFormTextTest.java index 6c4651d2..2f796729 100644 --- a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotScrolledFormTextTest.java +++ b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotScrolledFormTextTest.java @@ -12,11 +12,10 @@ package org.eclipse.swtbot.forms.finder.test.widgets; import static org.junit.Assert.assertNotNull; -import org.eclipse.swtbot.forms.finder.test.AbstractSWTBotFormsTestCase; import org.eclipse.swtbot.forms.finder.widgets.SWTBotScrolledFormText; import org.junit.Test; -public class SWTBotScrolledFormTextTest extends AbstractSWTBotFormsTestCase { +public class SWTBotScrolledFormTextTest extends AbstractSWTBotFormsTest { @Test public void findsScrolledFormText() throws Exception { diff --git a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotSectionTest.java b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotSectionTest.java index 9c8fbbea..93439e68 100644 --- a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotSectionTest.java +++ b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotSectionTest.java @@ -13,11 +13,10 @@ package org.eclipse.swtbot.forms.finder.test.widgets; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.eclipse.swtbot.forms.finder.test.AbstractSWTBotFormsTestCase; import org.eclipse.swtbot.forms.finder.widgets.SWTBotSection; import org.junit.Test; -public class SWTBotSectionTest extends AbstractSWTBotFormsTestCase { +public class SWTBotSectionTest extends AbstractSWTBotFormsTest { @Test public void findSection() throws Exception { diff --git a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotTreeNodeTest.java b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotTreeNodeTest.java index 1e2bbf7c..c77e0b1f 100644 --- a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotTreeNodeTest.java +++ b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotTreeNodeTest.java @@ -12,11 +12,10 @@ package org.eclipse.swtbot.forms.finder.test.widgets; import static org.junit.Assert.assertNotNull; -import org.eclipse.swtbot.forms.finder.test.AbstractSWTBotFormsTestCase; import org.eclipse.swtbot.forms.finder.widgets.SWTBotTreeNode; import org.junit.Test; -public class SWTBotTreeNodeTest extends AbstractSWTBotFormsTestCase { +public class SWTBotTreeNodeTest extends AbstractSWTBotFormsTest { @Test public void findTreeNode() throws Exception { diff --git a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotTwistieTest.java b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotTwistieTest.java index 311894e9..1d597b0d 100644 --- a/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotTwistieTest.java +++ b/org.eclipse.swtbot.forms.finder.test/src/org/eclipse/swtbot/forms/finder/test/widgets/SWTBotTwistieTest.java @@ -12,11 +12,10 @@ package org.eclipse.swtbot.forms.finder.test.widgets; import static org.junit.Assert.assertNotNull; -import org.eclipse.swtbot.forms.finder.test.AbstractSWTBotFormsTestCase; import org.eclipse.swtbot.forms.finder.widgets.SWTBotTwistie; import org.junit.Test; -public class SWTBotTwistieTest extends AbstractSWTBotFormsTestCase { +public class SWTBotTwistieTest extends AbstractSWTBotFormsTest { @Test public void findTwistie() throws Exception { |