Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKetan Padegaonkar2010-06-24 17:51:40 +0000
committerKetan Padegaonkar2010-06-24 17:51:40 +0000
commit4d849a63169754b8189b811434bb519d4309a6ea (patch)
tree3e4c2ad173ad31347ee7ba41940cbcbc36efea00
parentb743aad566eaf4e0e7ad338a79bec40be445cdb9 (diff)
downloadorg.eclipse.swtbot-4d849a63169754b8189b811434bb519d4309a6ea.tar.gz
org.eclipse.swtbot-4d849a63169754b8189b811434bb519d4309a6ea.tar.xz
org.eclipse.swtbot-4d849a63169754b8189b811434bb519d4309a6ea.zip
Added some smoke tests for the SWTBot UI.
-rw-r--r--org.eclipse.swtbot.eclipse.ui.test/functional/org/eclipse/swtbot/eclipse/ui/functional/AllTests.java24
-rw-r--r--org.eclipse.swtbot.eclipse.ui.test/functional/org/eclipse/swtbot/eclipse/ui/functional/ProjectCreationWizardTest.java120
-rw-r--r--org.eclipse.swtbot.eclipse.ui.test/functional/org/eclipse/swtbot/eclipse/ui/functional/SWTBotProject.java40
-rw-r--r--org.eclipse.swtbot.releng/test-sandbox/org.eclipse.swtbot.eclipse.ui.test.xml7
4 files changed, 191 insertions, 0 deletions
diff --git a/org.eclipse.swtbot.eclipse.ui.test/functional/org/eclipse/swtbot/eclipse/ui/functional/AllTests.java b/org.eclipse.swtbot.eclipse.ui.test/functional/org/eclipse/swtbot/eclipse/ui/functional/AllTests.java
new file mode 100644
index 00000000..c3212304
--- /dev/null
+++ b/org.eclipse.swtbot.eclipse.ui.test/functional/org/eclipse/swtbot/eclipse/ui/functional/AllTests.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * 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.eclipse.ui.functional;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>
+ */
+@RunWith(Suite.class)
+@SuiteClasses({ ProjectCreationWizardTest.class })
+public class AllTests {
+
+}
diff --git a/org.eclipse.swtbot.eclipse.ui.test/functional/org/eclipse/swtbot/eclipse/ui/functional/ProjectCreationWizardTest.java b/org.eclipse.swtbot.eclipse.ui.test/functional/org/eclipse/swtbot/eclipse/ui/functional/ProjectCreationWizardTest.java
new file mode 100644
index 00000000..46663be4
--- /dev/null
+++ b/org.eclipse.swtbot.eclipse.ui.test/functional/org/eclipse/swtbot/eclipse/ui/functional/ProjectCreationWizardTest.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * 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.eclipse.ui.functional;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.utils.FileUtils;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class ProjectCreationWizardTest {
+
+ private static SWTWorkbenchBot bot = new SWTWorkbenchBot();
+
+ @Test
+ public void canCreateSWTBotProject() throws Exception {
+ new SWTBotProject().create("com.example");
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("com.example");
+ assertTrue(project.exists());
+
+ assertEquals("" +
+ "Manifest-Version: 1.0\n" +
+ "Bundle-ManifestVersion: 2\n" +
+ "Bundle-Name: com.example\n" +
+ "Bundle-SymbolicName: com.example;singleton:=true\n" +
+ "Bundle-Version: 1.0.0.qualifier\n" +
+ "Bundle-ActivationPolicy: lazy\n" +
+ "Bundle-Vendor: ACME Corp.\n" +
+ "Bundle-RequiredExecutionEnvironment: J2SE-1.5\n" +
+ "Require-Bundle: org.eclipse.swtbot.go\n" +
+ "", contentsOf(project, "META-INF/MANIFEST.MF"));
+
+ assertEquals("" +
+ "source.. = src/\n" +
+ "output.. = bin/\n" +
+ "bin.includes = META-INF/,\\\n" +
+ " .\n" +
+ "", contentsOf(project, "build.properties"));
+
+ assertEquals("" +
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<projectDescription>\n" +
+ " <name>com.example</name>\n" +
+ " <comment></comment>\n" +
+ " <projects>\n" +
+ " </projects>\n" +
+ " <buildSpec>\n" +
+ " <buildCommand>\n" +
+ " <name>org.eclipse.jdt.core.javabuilder</name>\n" +
+ " <arguments>\n" +
+ " </arguments>\n" +
+ " </buildCommand>\n" +
+ " <buildCommand>\n" +
+ " <name>org.eclipse.pde.ManifestBuilder</name>\n" +
+ " <arguments>\n" +
+ " </arguments>\n" +
+ " </buildCommand>\n" +
+ " <buildCommand>\n" +
+ " <name>org.eclipse.pde.SchemaBuilder</name>\n" +
+ " <arguments>\n" +
+ " </arguments>\n" +
+ " </buildCommand>\n" +
+ " </buildSpec>\n" +
+ " <natures>\n" +
+ " <nature>org.eclipse.pde.PluginNature</nature>\n" +
+ " <nature>org.eclipse.jdt.core.javanature</nature>\n" +
+ " </natures>\n" +
+ "</projectDescription>\n" +
+ "", contentsOf(project, ".project"));
+
+ assertEquals("" +
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<classpath>\n" +
+ " <classpathentry kind=\"con\" " +
+ "path=\"org.eclipse.jdt.launching.JRE_CONTAINER/" +
+ "org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5\"/>\n" +
+ " <classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n" +
+ " <classpathentry kind=\"src\" path=\"src\"/>\n" +
+ " <classpathentry kind=\"output\" path=\"bin\"/>\n" +
+ "</classpath>\n" +
+ "", contentsOf(project, ".classpath"));
+
+ }
+
+ private String contentsOf(IProject project, String name) throws CoreException {
+ return FileUtils.read(project.getFile(name).getContents());
+ }
+
+ @BeforeClass
+ public static void oneTimeSetup() {
+ List<SWTBotView> views = bot.views();
+ for (SWTBotView view : views) {
+ if (view.getTitle().equals("Welcome"))
+ view.close();
+ }
+ }
+
+}
diff --git a/org.eclipse.swtbot.eclipse.ui.test/functional/org/eclipse/swtbot/eclipse/ui/functional/SWTBotProject.java b/org.eclipse.swtbot.eclipse.ui.test/functional/org/eclipse/swtbot/eclipse/ui/functional/SWTBotProject.java
new file mode 100644
index 00000000..aaf875d7
--- /dev/null
+++ b/org.eclipse.swtbot.eclipse.ui.test/functional/org/eclipse/swtbot/eclipse/ui/functional/SWTBotProject.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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.eclipse.ui.functional;
+
+import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellCloses;
+
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+
+/**
+ * @author Ketan Padegaonkar &lt;KetanPadegaonkar [at] gmail [dot] com&gt;
+ */
+public class SWTBotProject {
+
+ private final SWTWorkbenchBot bot = new SWTWorkbenchBot();
+
+ public void create(String projectId) {
+ bot.menu("File").menu("New").menu("Project...").click();
+ SWTBotShell shell = bot.shell("New Project");
+ shell.activate();
+
+ bot.tree().expandNode("Other", "New SWTBot Test Plug-in").select();
+ bot.button("Next >").click();
+
+ bot.textWithLabel("Plug-in Name:").setText(projectId);
+ bot.textWithLabel("Plug-in id:").setText(projectId);
+ bot.textWithLabel("Provider:").setText("ACME Corp.");
+ bot.button("Finish").click();
+ bot.waitUntil(shellCloses(shell));
+ }
+
+}
diff --git a/org.eclipse.swtbot.releng/test-sandbox/org.eclipse.swtbot.eclipse.ui.test.xml b/org.eclipse.swtbot.releng/test-sandbox/org.eclipse.swtbot.eclipse.ui.test.xml
index 0bbf7d0f..e31f1561 100644
--- a/org.eclipse.swtbot.releng/test-sandbox/org.eclipse.swtbot.eclipse.ui.test.xml
+++ b/org.eclipse.swtbot.releng/test-sandbox/org.eclipse.swtbot.eclipse.ui.test.xml
@@ -57,6 +57,13 @@
<property name="classname" value="org.eclipse.swtbot.eclipse.ui.test.AllTests" />
<property name="vmargs" value=" -Xms128M -Xmx368M -XX:MaxPermSize=256M ${jvmOption}" />
</ant>
+
+ <ant target="swtbot-test" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="data-dir" value="${temp-workspace}" />
+ <property name="plugin-name" value="${plugin-name}" />
+ <property name="classname" value="org.eclipse.swtbot.eclipse.ui.functional.AllTests" />
+ <property name="vmargs" value=" -Xms128M -Xmx368M -XX:MaxPermSize=256M ${jvmOption}" />
+ </ant>
</target>
<target name="test-coverage">

Back to the top