Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2011-11-25 08:10:53 -0500
committerMickael Istria2011-11-25 08:10:53 -0500
commit59d1201860b60f71a2c66e7a63f7fcd1c175f9a2 (patch)
tree2f703bd63c86dd22fe66d426ffbe7e479d850c09
parent1264049398e0d6164698f91d9cbafe4a7669fbca (diff)
parenta69b8a6dd14e9afb4ab66cd44d29aa2c60e0b51d (diff)
downloadorg.eclipse.gmf-tooling-59d1201860b60f71a2c66e7a63f7fcd1c175f9a2.tar.gz
org.eclipse.gmf-tooling-59d1201860b60f71a2c66e7a63f7fcd1c175f9a2.tar.xz
org.eclipse.gmf-tooling-59d1201860b60f71a2c66e7a63f7fcd1c175f9a2.zip
Merge branch 'FigureRef-267354' into 2.4.x-maintenance
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Children.xpt13
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt14
-rwxr-xr-xpom.xml16
-rw-r--r--tests/org.eclipse.gmf.tests/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--tests/org.eclipse.gmf.tests/META-INF/MANIFEST.MF11
-rw-r--r--tests/org.eclipse.gmf.tests/models/tests/267354-FigureRefChildren.gmfgraph51
-rw-r--r--tests/org.eclipse.gmf.tests/pom.xml58
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllSWTBotTests.java32
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java30
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/Utils.java46
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gen/swtbot/FigureGenerationTest.java117
-rwxr-xr-xtests/pom.xml8
12 files changed, 346 insertions, 53 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Children.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Children.xpt
index c2abf8345..49cd9f40b 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Children.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Children.xpt
@@ -28,13 +28,22 @@
«ENDDEFINE»
«DEFINE instantiate(count : Integer, parentFigure : gmfgraph::RealFigure, parentFigureVariable : String) FOR gmfgraph::FigureRef-»
-/*FIXME referenced figures are just not yet fully-functional; need process attrs and layout here*/
+«LET figureVariableName(figure, count) AS figureVarName»
«EXPAND instantiate(count, parentFigure, parentFigureVariable) FOR figure-»
+// Process FigureRef details
+«EXPAND populate(count, parentFigure, parentFigureVariable, figureVarName) FOR self-»
+«ENDLET»
«ENDDEFINE»
«DEFINE instantiate(count : Integer, parentFigure : gmfgraph::RealFigure, parentFigureVariable : String) FOR gmfgraph::RealFigure»
«LET figureVariableName(self, count) AS figureVarName»
«EXPAND newFigureInstance(figureVarName)»
+«EXPAND populate(count, parentFigure, parentFigureVariable, figureVarName) FOR self-»
+«EXPAND instantiate(count + 1, self, figureVarName) FOREACH children-»
+«ENDLET»
+«ENDDEFINE»
+
+«DEFINE populate(count : Integer, parentFigure : gmfgraph::RealFigure, parentFigureVariable : String, figureVarName : String) FOR gmfgraph::Figure»
«EXPAND Attrs::Init(figureVarName)-»
«IF null = layoutData or null = parentFigure.layout-»«REM»Check for (parentLayout != null) to avoid generating data that won't be used. Not sure it's essential, but it was that way with old jet templates«ENDREM»
«parentFigureVariable».add(«figureVarName»);
@@ -42,8 +51,6 @@
«EXPAND LayoutData::Init(parentFigureVariable, figureVarName) FOR layoutData-»
«ENDIF-»
«EXPAND Layout::Init(figureVarName) FOR layout-»
-«EXPAND instantiate(count + 1, self, figureVarName) FOREACH children-»
-«ENDLET»
«ENDDEFINE»
«DEFINE newFigureInstance(figureVarName : String) FOR gmfgraph::RealFigure»«IF needsField(self)»«figureVarName» = «EXPAND Runtime::newInstance»;«ELSE»«EXPAND Runtime::newInstance(figureVarName)»«ENDIF»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt
index f8f88d2f4..4653831d6 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt
@@ -17,10 +17,14 @@
«DEFINE ClassBody(cuName : String) FOR gmfgraph::Figure»«ERROR 'abstract ClassBody(Figure)'»«ENDDEFINE»
«DEFINE ClassBody(cuName : String) FOR gmfgraph::FigureRef-»
-«EXPAND ClassBody(cuName) FOR figure-»
+«EXPAND ClassBody(cuName, self) FOR figure-»
«ENDDEFINE»
«DEFINE ClassBody(cuName : String) FOR gmfgraph::RealFigure-»
+«EXPAND ClassBody(cuName, null) FOR self-»
+«ENDDEFINE»
+
+«DEFINE ClassBody(cuName : String, figureRef : gmfgraph::FigureRef) FOR gmfgraph::RealFigure-»
/**
* @generated
*/
@@ -28,6 +32,12 @@
«clearBorders()-»
«EXPAND Layout::Init('this') FOR layout-»
«EXPAND Attrs::Init('this')-»
+«IF not figureRef->isEmpty()-»
+ // «figureRef.figure.name»
+ // Process FigureRef details
+ «EXPAND Layout::Init('this') FOR figureRef.layout-»
+ «EXPAND Attrs::Init('this') FOR figureRef-»
+«ENDIF-»
«IF not (children)[gmfgraph::Figure]->isEmpty()-»
createContents();
}
@@ -40,7 +50,7 @@
«EXPAND additions-»
«ENDDEFINE»
-«DEFINE ClassBody(cuName : String) FOR gmfgraph::PolylineConnection-»
+«DEFINE ClassBody(cuName : String, figureRef : gmfgraph::FigureRef) FOR gmfgraph::PolylineConnection-»
/**
* @generated
*/
diff --git a/pom.xml b/pom.xml
index 1652f3f0e..cce0cce04 100755
--- a/pom.xml
+++ b/pom.xml
@@ -170,20 +170,25 @@
<profile>
<id>indigo</id>
<activation>
- <activeByDefault>false</activeByDefault>
+ <activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>Indigo</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/indigo</url>
- </repository>
+ </repository>
+ <repository>
+ <id>Orbit for Indigo</id>
+ <layout>p2</layout>
+ <url>http://download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository/</url>
+ </repository>
</repositories>
</profile>
<profile>
<id>juno-staging</id>
<activation>
- <activeByDefault>true</activeByDefault>
+ <activeByDefault>false</activeByDefault>
</activation>
<repositories>
<repository>
@@ -191,6 +196,11 @@
<layout>p2</layout>
<url>http://download.eclipse.org/releases/staging/</url>
</repository>
+ <repository>
+ <id>orbit-staging</id>
+ <layout>p2</layout>
+ <url>http://download.eclipse.org/tools/orbit/downloads/drops/S20111018035124/repository/</url>
+ </repository>
</repositories>
</profile>
</profiles>
diff --git a/tests/org.eclipse.gmf.tests/.settings/org.eclipse.core.resources.prefs b/tests/org.eclipse.gmf.tests/.settings/org.eclipse.core.resources.prefs
index d5867d996..bcfc80a7d 100644
--- a/tests/org.eclipse.gmf.tests/.settings/org.eclipse.core.resources.prefs
+++ b/tests/org.eclipse.gmf.tests/.settings/org.eclipse.core.resources.prefs
@@ -1,3 +1,4 @@
-#Thu Mar 19 13:57:27 CET 2009
+#Tue Nov 15 17:44:50 CET 2011
eclipse.preferences.version=1
+encoding//models/tests/267354-FigureRefChildren.gmfgraph=UTF-8
encoding/templates=UTF-8
diff --git a/tests/org.eclipse.gmf.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.gmf.tests/META-INF/MANIFEST.MF
index d243ff52d..360179b85 100644
--- a/tests/org.eclipse.gmf.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.gmf.tests/META-INF/MANIFEST.MF
@@ -24,7 +24,14 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)",
org.eclipse.gmf.codegen;bundle-version="[2.0.0,3.0.0)",
org.eclipse.gmf.xpand;bundle-version="[2.1.0,3.0.0)",
org.eclipse.ant.core;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.pde.core
+ org.eclipse.pde.core,
+ org.eclipse.swtbot.eclipse.core;bundle-version="2.0.5",
+ org.eclipse.swtbot.eclipse.finder;bundle-version="2.0.5",
+ org.eclipse.swtbot.swt.finder;bundle-version="2.0.5",
+ org.eclipse.jdt.ui;bundle-version="3.7.1",
+ org.eclipse.gmf.graphdef.codegen.ui;bundle-version="1.0.100",
+ org.eclipse.gmf.graphdef.editor;bundle-version="1.1.0",
+ org.hamcrest;bundle-version="1.1.0"
Bundle-Activator: org.eclipse.gmf.tests.Plugin
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.gmf.tests;x-friends:="org.eclipse.gmf.tests.lite",
@@ -34,4 +41,4 @@ Export-Package: org.eclipse.gmf.tests;x-friends:="org.eclipse.gmf.tests.lite",
org.eclipse.gmf.tests.setup;x-friends:="org.eclipse.gmf.tests.lite",
org.eclipse.gmf.tests.setup.figures;x-friends:="org.eclipse.gmf.tests.lite",
org.eclipse.gmf.tests.tr;x-friends:="org.eclipse.gmf.tests.lite"
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/tests/org.eclipse.gmf.tests/models/tests/267354-FigureRefChildren.gmfgraph b/tests/org.eclipse.gmf.tests/models/tests/267354-FigureRefChildren.gmfgraph
new file mode 100644
index 000000000..5515c0687
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/models/tests/267354-FigureRefChildren.gmfgraph
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gmfgraph:Canvas xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:gmfgraph="http://www.eclipse.org/gmf/2006/GraphicalDefinition" name="">
+ <figures
+ name="">
+ <figures
+ xsi:type="gmfgraph:Rectangle"
+ name="figure"/>
+ <descriptors
+ name="DirectFigureRef">
+ <actualFigure
+ xsi:type="gmfgraph:FigureRef"
+ figure="//@figures.0/@figures.0">
+ <foregroundColor
+ xsi:type="gmfgraph:ConstantColor"
+ value="lightGreen"/>
+ </actualFigure>
+ </descriptors>
+ <descriptors
+ name="ChildFigureRef">
+ <actualFigure
+ xsi:type="gmfgraph:Rectangle">
+ <layout
+ xsi:type="gmfgraph:XYLayout"/>
+ <children
+ xsi:type="gmfgraph:FigureRef"
+ figure="//@figures.0/@figures.0">
+ <foregroundColor
+ xsi:type="gmfgraph:ConstantColor"
+ value="lightGreen"/>
+ </children>
+ </actualFigure>
+ </descriptors>
+ <descriptors
+ name="NoRefFigure">
+ <actualFigure
+ xsi:type="gmfgraph:Rectangle"/>
+ </descriptors>
+ </figures>
+ <nodes
+ name="DirectFigureRefNode"
+ figure="DirectFigureRef"/>
+ <nodes
+ name="ChildFigureRefNode"
+ figure="ChildFigureRef"/>
+ <nodes
+ name="NoRefNode"
+ figure="NoRefFigure"/>
+</gmfgraph:Canvas>
diff --git a/tests/org.eclipse.gmf.tests/pom.xml b/tests/org.eclipse.gmf.tests/pom.xml
index cdf0f7bb5..8356f8110 100644
--- a/tests/org.eclipse.gmf.tests/pom.xml
+++ b/tests/org.eclipse.gmf.tests/pom.xml
@@ -29,11 +29,41 @@
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
+ <executions>
+ <execution>
+ <id>SWTBot tests</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <testClass>org.eclipse.gmf.tests.AllSWTBotTests</testClass>
+ <useUIThread>false</useUIThread>
+ </configuration>
+ </execution>
+ <execution>
+ <id>non SWTBot tests</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <testClass>org.eclipse.gmf.tests.AllTests</testClass>
+ <useUIThread>true</useUIThread>
+ </configuration>
+ </execution>
+ <execution>
+ <!-- Skip default test -->
+ <id>default-test</id>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </execution>
+ </executions>
+ <!-- Inherited configuration -->
<configuration>
- <testSuite>org.eclipse.gmf.tests</testSuite>
- <testClass>org.eclipse.gmf.tests.AllTests</testClass>
<useUIHarness>true</useUIHarness>
- <useUIThread>true</useUIThread>
+ <testSuite>org.eclipse.gmf.tests</testSuite>
<argLine>${tycho.testArgLine} -Xmx512m -XX:MaxPermSize=128m -DbuildingWithTycho=true</argLine>
<bundleStartLevel>
<bundle>
@@ -44,17 +74,17 @@
</bundleStartLevel>
<dependencies>
<dependency>
- <type>p2-installable-unit</type>
- <artifactId>org.eclipse.gmf.feature.group</artifactId>
- </dependency>
- <dependency>
- <type>p2-installable-unit</type>
- <artifactId>org.eclipse.pde.feature.group</artifactId>
- </dependency>
- <dependency>
- <type>p2-installable-unit</type>
- <artifactId>org.eclipse.emf.validation.ocl</artifactId>
- </dependency>
+ <type>p2-installable-unit</type>
+ <artifactId>org.eclipse.gmf.feature.group</artifactId>
+ </dependency>
+ <dependency>
+ <type>p2-installable-unit</type>
+ <artifactId>org.eclipse.pde.feature.group</artifactId>
+ </dependency>
+ <dependency>
+ <type>p2-installable-unit</type>
+ <artifactId>org.eclipse.emf.validation.ocl</artifactId>
+ </dependency>
</dependencies>
</configuration>
</plugin>
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllSWTBotTests.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllSWTBotTests.java
new file mode 100644
index 000000000..57857de2f
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllSWTBotTests.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+* Copyright (c) 2011 EBM Websourcing (PetalsLink)
+* 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:
+* Mickael Istria (EBM - PetalsLink) : initial implementation
+*******************************************************************************/
+package org.eclipse.gmf.tests;
+
+import org.eclipse.gmf.tests.gen.swtbot.FigureGenerationTest;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({
+ FigureGenerationTest.class
+})
+public class AllSWTBotTests {
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ if (System.getProperty("buildingWithTycho") != null) {
+ System.err.println("Generating a target platform");
+ Utils.setTargetPlatform();
+ }
+ }
+}
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java
index bec657b53..221c2f1a8 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java
@@ -8,6 +8,7 @@
*
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
+ * Mickael Istria (EBM Websourcing) - Support for target platform creation
*/
package org.eclipse.gmf.tests;
@@ -83,38 +84,11 @@ import java.util.ArrayList;
public class AllTests {
- public static void setTargetPlatform() throws Exception {
- ITargetPlatformService tpService = TargetPlatformService.getDefault();
- ITargetDefinition targetDef = tpService.newTarget();
- targetDef.setName("Tycho platform");
- Bundle[] bundles = Platform.getBundle("org.eclipse.core.runtime").getBundleContext().getBundles();
- List<IBundleContainer> bundleContainers = new ArrayList<IBundleContainer>();
- Set<File> dirs = new HashSet<File>();
- for (Bundle bundle : bundles) {
- AbstractBundle aBundle = (AbstractBundle)bundle;
- final BaseData bundleData = (BaseData)aBundle.getBundleData();
- File file = bundleData.getBundleFile().getBaseFile();
- File folder = file.getParentFile();
- if (!dirs.contains(folder)) {
- dirs.add(folder);
- bundleContainers.add(tpService.newDirectoryContainer(folder.getAbsolutePath()));
- }
- }
- targetDef.setBundleContainers(bundleContainers.toArray(new IBundleContainer[0]));
- targetDef.setArch(Platform.getOSArch());
- targetDef.setOS(Platform.getOS());
- targetDef.setWS(Platform.getWS());
- targetDef.setNL(Platform.getNL());
- //targetDef.setJREContainer()
- tpService.saveTargetDefinition(targetDef);
- LoadTargetDefinitionJob.load(targetDef);
- }
-
public static Test suite() throws Exception {
if (System.getProperty("buildingWithTycho") != null) {
System.err.println("Generating a target platform");
- setTargetPlatform();
+ Utils.setTargetPlatform();
}
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/Utils.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/Utils.java
index da5d38209..7eb18e987 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/Utils.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/Utils.java
@@ -8,14 +8,21 @@
*
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
+ * Mickael Istria (EBM Websourcing) - Support for target platform creation
*/
package org.eclipse.gmf.tests;
+import java.io.File;
+import java.util.ArrayList;
import java.util.Calendar;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import junit.framework.Assert;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
import org.eclipse.emf.codegen.ecore.genmodel.GenClassifier;
import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
@@ -24,7 +31,15 @@ import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.gmf.internal.bridge.genmodel.BasicGenModelAccess;
+import org.eclipse.osgi.baseadaptor.BaseData;
+import org.eclipse.osgi.framework.internal.core.AbstractBundle;
+import org.eclipse.pde.internal.core.target.TargetPlatformService;
+import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
+import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
+import org.eclipse.pde.internal.core.target.provisional.ITargetPlatformService;
+import org.eclipse.pde.internal.core.target.provisional.LoadTargetDefinitionJob;
import org.eclipse.swt.widgets.Display;
+import org.osgi.framework.Bundle;
/**
* @author artem
@@ -119,4 +134,35 @@ public class Utils {
boolean conditionSatisfied = Utils.dispatchDisplayMessages(condition, 10);
Assert.assertTrue("Timeout while waiting for jobs to complete", conditionSatisfied);
}
+
+ /**
+ * Sets a target platform in the test platform to get workspace builds OK with PDE.
+ * @throws Exception
+ */
+ public static void setTargetPlatform() throws Exception {
+ ITargetPlatformService tpService = TargetPlatformService.getDefault();
+ ITargetDefinition targetDef = tpService.newTarget();
+ targetDef.setName("Tycho platform");
+ Bundle[] bundles = Platform.getBundle("org.eclipse.core.runtime").getBundleContext().getBundles();
+ List<IBundleContainer> bundleContainers = new ArrayList<IBundleContainer>();
+ Set<File> dirs = new HashSet<File>();
+ for (Bundle bundle : bundles) {
+ AbstractBundle aBundle = (AbstractBundle)bundle;
+ final BaseData bundleData = (BaseData)aBundle.getBundleData();
+ File file = bundleData.getBundleFile().getBaseFile();
+ File folder = file.getParentFile();
+ if (!dirs.contains(folder)) {
+ dirs.add(folder);
+ bundleContainers.add(tpService.newDirectoryContainer(folder.getAbsolutePath()));
+ }
+ }
+ targetDef.setBundleContainers(bundleContainers.toArray(new IBundleContainer[0]));
+ targetDef.setArch(Platform.getOSArch());
+ targetDef.setOS(Platform.getOS());
+ targetDef.setWS(Platform.getWS());
+ targetDef.setNL(Platform.getNL());
+ //targetDef.setJREContainer()
+ tpService.saveTargetDefinition(targetDef);
+ LoadTargetDefinitionJob.load(targetDef);
+ }
}
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gen/swtbot/FigureGenerationTest.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gen/swtbot/FigureGenerationTest.java
new file mode 100644
index 000000000..cc2fc976c
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gen/swtbot/FigureGenerationTest.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+* Copyright (c) 2011 EBM Websourcing (PetalsLink)
+* 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:
+* Mickael Istria (EBM - PetalsLink) : initial implementation
+*******************************************************************************/
+package org.eclipse.gmf.tests.gen.swtbot;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swtbot.eclipse.finder.SWTBotEclipseTestCase;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.waits.ICondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FigureGenerationTest extends SWTBotEclipseTestCase {
+
+ @Test
+ public void testBug267354_FigureRefChildren() throws Exception {
+ // Don't use SWTBot to save time and not related to GMF.
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ try {
+ IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject("testProjectBug267354");
+ proj.create(new NullProgressMonitor());
+ proj.open(new NullProgressMonitor());
+ IFile file = proj.getFile("267354-FigureRefChildren.gmfgraph");
+ file.create(getClass().getClassLoader().getResourceAsStream("/models/tests/267354-FigureRefChildren.gmfgraph"), false, new NullProgressMonitor());
+ IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file, "org.eclipse.gmf.gmfgraph.presentation.GMFGraphEditorID", true);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ });
+ SWTBotTreeItem figureGalleryNode = bot.editorByTitle("267354-FigureRefChildren.gmfgraph").bot().tree().getAllItems()[0].expand().getNode("Canvas").expand().getNode("Figure Gallery").click();
+ figureGalleryNode.contextMenu("Generate Figures Plug-in ...").click();
+ bot.shell("Figure Gallery Generator").bot().text().setText("org.eclipse.gmf.testProjectBug267354");
+ bot.button("OK").click();
+ bot.waitWhile(new ICondition() {
+ @Override
+ public boolean test() throws Exception {
+ return bot.activeShell().getText().equals("Generate Figures Plug-in ...");
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return null;
+ }
+ }, 40000);
+ {
+ // Check in ChildFigureRef
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getProject("org.eclipse.gmf.testProjectBug267354").getFile(new Path("src/org/eclipse/gmf/testProjectBug267354/ChildFigureRef.java"));
+ IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ });
+ String generatedCode = bot.editorByTitle("ChildFigureRef.java").toTextEditor().getText();
+ Assert.assertTrue("No mention of FigureRef details", generatedCode.contains("Process FigureRef details"));
+ Assert.assertTrue("Did not find specified background color attribute", generatedCode.contains("ColorConstants.lightGreen"));
+ }
+ {
+ // Check in DirectFigureRef
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getProject("org.eclipse.gmf.testProjectBug267354").getFile(new Path("src/org/eclipse/gmf/testProjectBug267354/DirectFigureRef.java"));
+ IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ });
+ String generatedCode = bot.editorByTitle("DirectFigureRef.java").toTextEditor().getText();
+ Assert.assertTrue("No mention of FigureRef details", generatedCode.contains("Process FigureRef details"));
+ Assert.assertTrue("Did not find specified background color attribute", generatedCode.contains("ColorConstants.lightGreen"));
+ }
+ {
+ // Check in NoRefFigure: no change for figures without Ref
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getProject("org.eclipse.gmf.testProjectBug267354").getFile(new Path("src/org/eclipse/gmf/testProjectBug267354/NoRefFigure.java"));
+ IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ });
+ String generatedCode = bot.editorByTitle("NoRefFigure.java").toTextEditor().getText();
+ Assert.assertFalse("Mention of 'FigureRef details' in figure without Ref!", generatedCode.contains("Process FigureRef details"));
+ }
+ }
+}
diff --git a/tests/pom.xml b/tests/pom.xml
index 7c892f37f..735d4250c 100755
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -67,5 +67,13 @@
</build>
</profile>
</profiles>
+
+ <repositories>
+ <repository>
+ <id>SWTBot</id>
+ <layout>p2</layout>
+ <url>http://download.eclipse.org/technology/swtbot/helios/dev-build/update-site/</url>
+ </repository>
+ </repositories>
</project> \ No newline at end of file

Back to the top