Add Graphiti SWTBot test plugin

* Move DTP with invalid image provider from ui tests to bot tests where
it is actually used
* Made plugin wizard test more stable

Change-Id: I5becaf4499c911f7442ab5a9ede80a641773b294
diff --git a/parent/pom.xml b/parent/pom.xml
index da1485f..0f43c74 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -29,6 +29,7 @@
 			</activation>

 			<properties>

 				<platform-path>4.5milestones/S-4.5RC4-201506032000/</platform-path>

+				<platform-version>4.5</platform-version>

 				<orbit-version>R20150519210750</orbit-version>

 				<gef-path>milestones/</gef-path>

 				<emf-path>2.11milestones/</emf-path>

@@ -108,6 +109,7 @@
 		<module>../tests/org.eclipse.graphiti.ui.tests</module>

 		<module>../tests/org.eclipse.graphiti.testtool.ecore</module>

 		<module>../tests/org.eclipse.graphiti.testtool.sketch</module>

+		<module>../tests/org.eclipse.graphiti.bot.tests</module>

 	</modules>

 

 	<build>

diff --git a/tests/org.eclipse.graphiti.bot.tests/.classpath b/tests/org.eclipse.graphiti.bot.tests/.classpath
index ad32c83..c72d35a 100644
--- a/tests/org.eclipse.graphiti.bot.tests/.classpath
+++ b/tests/org.eclipse.graphiti.bot.tests/.classpath
@@ -3,5 +3,5 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="output" path="bin"/>
+	<classpathentry kind="output" path="target/classes"/>
 </classpath>
diff --git a/tests/org.eclipse.graphiti.bot.tests/.gitignore b/tests/org.eclipse.graphiti.bot.tests/.gitignore
index e6cf840..46c0b25 100644
--- a/tests/org.eclipse.graphiti.bot.tests/.gitignore
+++ b/tests/org.eclipse.graphiti.bot.tests/.gitignore
@@ -1,2 +1,3 @@
 /bin
-/screenshots
\ No newline at end of file
+/screenshots
+/target/
diff --git a/tests/org.eclipse.graphiti.bot.tests/.project b/tests/org.eclipse.graphiti.bot.tests/.project
index 421dfc3..39a7ba1 100644
--- a/tests/org.eclipse.graphiti.bot.tests/.project
+++ b/tests/org.eclipse.graphiti.bot.tests/.project
@@ -25,8 +25,14 @@
 			<arguments>
 			</arguments>
 		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
 	</buildSpec>
 	<natures>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
 		<nature>org.eclipse.pde.PluginNature</nature>
 		<nature>org.eclipse.jdt.core.javanature</nature>
 		<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
diff --git a/tests/org.eclipse.graphiti.bot.tests/.settings/org.eclipse.core.resources.prefs b/tests/org.eclipse.graphiti.bot.tests/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 99f26c0..0000000
--- a/tests/org.eclipse.graphiti.bot.tests/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,2 +0,0 @@
-eclipse.preferences.version=1
-encoding/<project>=UTF-8
diff --git a/tests/org.eclipse.graphiti.bot.tests/.settings/org.eclipse.m2e.core.prefs b/tests/org.eclipse.graphiti.bot.tests/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/tests/org.eclipse.graphiti.bot.tests/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/tests/org.eclipse.graphiti.bot.tests/plugin.xml b/tests/org.eclipse.graphiti.bot.tests/plugin.xml
index 7cfb612..c923735 100644
--- a/tests/org.eclipse.graphiti.bot.tests/plugin.xml
+++ b/tests/org.eclipse.graphiti.bot.tests/plugin.xml
@@ -56,5 +56,17 @@
          </diagramType>
       </diagramTypeProvider>
    </extension>
-
+   <extension point="org.eclipse.graphiti.ui.diagramTypeProviders">
+      <diagramTypeProvider
+         class="org.eclipse.graphiti.bot.tests.DTPwithInvalidImageProvider"
+         description="Test for an invalid image provider"
+         id="org.eclipse.graphiti.bot.tests.dtpWithInvalidImageProvider"
+         name="Diagram Type Provider with invalid Image Provider">
+         <diagramType id="org.eclipse.graphiti.bot.tests.dtWithInvalidImageProvider">
+         </diagramType>
+         <!-- Define an invalid image provider to see that editor can be opened nevertheless -->
+         <imageProvider id="invalid">
+         </imageProvider>
+      </diagramTypeProvider>
+   </extension>
 </plugin>
diff --git a/tests/org.eclipse.graphiti.bot.tests/pom.xml b/tests/org.eclipse.graphiti.bot.tests/pom.xml
new file mode 100644
index 0000000..c2e496d
--- /dev/null
+++ b/tests/org.eclipse.graphiti.bot.tests/pom.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

+	<modelVersion>4.0.0</modelVersion>

+

+	<parent>

+		<groupId>org.eclipse.graphiti</groupId>

+		<artifactId>parent</artifactId>

+		<version>0.12.0-SNAPSHOT</version>

+		<relativePath>../../parent</relativePath>

+	</parent>

+

+	<name>Robot UI Tests for Graphiti</name>

+	<artifactId>org.eclipse.graphiti.bot.tests</artifactId>

+	<packaging>eclipse-test-plugin</packaging>

+

+	<properties>

+		<local-p2-site>file:/${basedir}/../../features/org.eclipse.graphiti.site/target/repository</local-p2-site>

+		<ui.test.vmargs>-Xmx512m -XX:MaxPermSize=256m</ui.test.vmargs>

+	</properties>

+

+	<repositories>

+		<repository>

+			<id>local-p2</id>

+			<layout>p2</layout>

+			<url>${local-p2-site}</url>

+		</repository>

+	</repositories>

+

+	<profiles>

+		<profile>

+			<id>skip-ui-tests</id>

+			<activation>

+				<property>

+					<name>skip-ui-tests</name>

+				</property>

+			</activation>

+			<properties>

+				<maven.test.skip>true</maven.test.skip>

+			</properties>

+		</profile>

+	</profiles>

+

+	<build>

+		<plugins>

+			<plugin>

+				<groupId>org.eclipse.tycho</groupId>

+				<artifactId>target-platform-configuration</artifactId>

+				<version>${tycho-version}</version>

+				<configuration>

+					<dependency-resolution>

+						<extraRequirements>

+							<requirement>

+								<type>eclipse-feature</type>

+								<id>org.eclipse.sdk</id>

+								<versionRange>0.0.0</versionRange>

+							</requirement>

+							<requirement>

+								<type>eclipse-feature</type>

+								<id>org.eclipse.graphiti.sdk.plus.feature</id>

+								<versionRange>0.12.0</versionRange>

+							</requirement>

+							<requirement>

+								<type>eclipse-feature</type>

+								<id>org.eclipse.graphiti.feature.examples</id>

+								<versionRange>0.12.0</versionRange>

+							</requirement>

+							<requirement>

+								<type>eclipse-feature</type>

+								<id>org.eclipse.graphiti.feature.tools</id>

+								<versionRange>0.12.0</versionRange>

+							</requirement>

+						</extraRequirements>

+					</dependency-resolution>

+				</configuration>

+			</plugin>

+			<plugin>

+				<groupId>org.eclipse.tycho</groupId>

+				<artifactId>tycho-surefire-plugin</artifactId>

+				<version>${tycho-version}</version>

+				<configuration>

+					<testSuite>org.eclipse.graphiti.bot.tests</testSuite>

+					<testClass>org.eclipse.graphiti.bot.tests.GFTestSuite</testClass>

+					<useUIHarness>true</useUIHarness>

+					<!-- Set UIThread to true for UI Tests that do not use SWTBot -->

+					<useUIThread>false</useUIThread>

+					<product>org.eclipse.platform.ide</product>

+					<argLine>${ui.test.vmargs}</argLine>

+					<application>org.eclipse.ui.ide.workbench</application>

+				</configuration>

+			</plugin>

+		</plugins>

+	</build>

+</project>
\ No newline at end of file
diff --git a/tests/org.eclipse.graphiti.ui.tests/src/org/eclipse/graphiti/ui/tests/DTPwithInvalidImageProvider.java b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/DTPwithInvalidImageProvider.java
similarity index 86%
rename from tests/org.eclipse.graphiti.ui.tests/src/org/eclipse/graphiti/ui/tests/DTPwithInvalidImageProvider.java
rename to tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/DTPwithInvalidImageProvider.java
index 8f79de6..1c95b5b 100644
--- a/tests/org.eclipse.graphiti.ui.tests/src/org/eclipse/graphiti/ui/tests/DTPwithInvalidImageProvider.java
+++ b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/DTPwithInvalidImageProvider.java
@@ -8,12 +8,13 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *    mwenz - Bug 352709 - invalid image provider id crashes diagram editor 
+ *    mwenz - Bug 352709 - invalid image provider id crashes diagram editor
+ *    mwenz - Bug 421626 - Moved from ui.test to bot.test plugin
  *
  * </copyright>
  *
  *******************************************************************************/
-package org.eclipse.graphiti.ui.tests;
+package org.eclipse.graphiti.bot.tests;
 
 import org.eclipse.graphiti.dt.AbstractDiagramTypeProvider;
 
@@ -22,5 +23,4 @@
 	public DTPwithInvalidImageProvider() {
 		super();
 	}
-
 }
diff --git a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/ExtensionManagerTest.java b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/ExtensionManagerTest.java
index 1d0bdf6..0c9e5bd 100644
--- a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/ExtensionManagerTest.java
+++ b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/ExtensionManagerTest.java
@@ -54,7 +54,7 @@
 		// Create a diagram type provider which defines an invalid image provider. The DTP must be created nevertheless.
 		// See Bug 352709
 		IDiagramTypeProvider diagramTypeProvider = GraphitiUi.getExtensionManager().createDiagramTypeProvider(
-				"org.eclipse.graphiti.ui.tests.dtpWithInvalidImageProvider");
+				"org.eclipse.graphiti.bot.tests.dtpWithInvalidImageProvider");
 		assertNotNull("Diagram type Provider must not be null", diagramTypeProvider);
 	}
 	
diff --git a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/PluginWizardTests.java b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/PluginWizardTests.java
index 4c88857..fdc5900 100644
--- a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/PluginWizardTests.java
+++ b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/PluginWizardTests.java
@@ -63,6 +63,13 @@
 
 	@Test
 	public void testPluginWizardRun() throws Exception {
+		// Check problems view and remember number of errors before test
+		SWTBotView view = bot.viewById(IPageLayout.ID_PROBLEM_VIEW);
+		view.show();
+		SWTBotTree tree = view.bot().tree();
+		SWTBotTreeItem[] allItems = tree.getAllItems();
+		int numberOfErrorsBeforeTest = allItems.length;
+
 		// Start wizard
 		bot.menu("File").menu("New").menu("Project...").click();
 		SWTBotShell shell = bot.shell("New Project");
@@ -105,11 +112,13 @@
 		assertTrue(newProject.exists());
 
 		// Check problems view for any errors
-		SWTBotView view = bot.viewById(IPageLayout.ID_PROBLEM_VIEW);
+		view = bot.viewById(IPageLayout.ID_PROBLEM_VIEW);
 	    view.show();
-		SWTBotTree tree = view.bot().tree();
-		SWTBotTreeItem[] allItems = tree.getAllItems();
-		assertTrue("Items found in problems view: " + allItems.toString(), allItems.length == 0);
+		tree = view.bot().tree();
+		allItems = tree.getAllItems();
+		assertTrue("Items found in problems view: " + allItems.toString()
+				+ ", expected were (number of errors before test: " + numberOfErrorsBeforeTest,
+				allItems.length == numberOfErrorsBeforeTest);
 
 		// Check that org.eclipse.ui is not part of the dependencies (no
 		// activator is generated), test for Bug 388211
diff --git a/tests/org.eclipse.graphiti.ui.tests/plugin.xml b/tests/org.eclipse.graphiti.ui.tests/plugin.xml
index df02d0c..304ca14 100644
--- a/tests/org.eclipse.graphiti.ui.tests/plugin.xml
+++ b/tests/org.eclipse.graphiti.ui.tests/plugin.xml
@@ -9,21 +9,4 @@
             type="dtWithInvalidImageProvider">
       </diagramType>
    </extension>
-   <extension
-         point="org.eclipse.graphiti.ui.diagramTypeProviders">
-      <diagramTypeProvider
-            class="org.eclipse.graphiti.ui.tests.DTPwithInvalidImageProvider"
-            description="Test for an invalid image provider"
-            id="org.eclipse.graphiti.ui.tests.dtpWithInvalidImageProvider"
-            name="Diagram Type Provider with invalid Image Provider">
-         <diagramType
-               id="org.eclipse.graphiti.ui.tests.dtWithInvalidImageProvider">
-         </diagramType>
-         <!-- Define an invalid image provider to see that editor can be opened nevertheless -->
-         <imageProvider
-               id="invalid">
-         </imageProvider>
-      </diagramTypeProvider>
-   </extension>
-
 </plugin>