aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2011-11-25 08:08:55 (EST)
committerMickael Istria2011-11-25 08:08:55 (EST)
commita69b8a6dd14e9afb4ab66cd44d29aa2c60e0b51d (patch)
treed8887b5757ff02a246078218aa56ad510a106572
parentca96ee48ecc5316db7dff68191de87b45cd0c586 (diff)
downloadorg.eclipse.gmf-tooling-a69b8a6dd14e9afb4ab66cd44d29aa2c60e0b51d.zip
org.eclipse.gmf-tooling-a69b8a6dd14e9afb4ab66cd44d29aa2c60e0b51d.tar.gz
org.eclipse.gmf-tooling-a69b8a6dd14e9afb4ab66cd44d29aa2c60e0b51d.tar.bz2
* Improve test * Fix
-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
-rw-r--r--tests/org.eclipse.gmf.tests/models/tests/267354-FigureRefChildren.gmfgraph37
-rw-r--r--tests/org.eclipse.gmf.tests/pom.xml8
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gen/swtbot/FigureGenerationTest.java60
5 files changed, 111 insertions, 21 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Children.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Children.xpt
index c2abf83..49cd9f4 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 f8f88d2..4653831 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/tests/org.eclipse.gmf.tests/models/tests/267354-FigureRefChildren.gmfgraph b/tests/org.eclipse.gmf.tests/models/tests/267354-FigureRefChildren.gmfgraph
index dbaeacc..5515c06 100644
--- a/tests/org.eclipse.gmf.tests/models/tests/267354-FigureRefChildren.gmfgraph
+++ b/tests/org.eclipse.gmf.tests/models/tests/267354-FigureRefChildren.gmfgraph
@@ -2,13 +2,14 @@
<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">
- <figures>
+ xmlns:gmfgraph="http://www.eclipse.org/gmf/2006/GraphicalDefinition" name="">
+ <figures
+ name="">
<figures
xsi:type="gmfgraph:Rectangle"
name="figure"/>
<descriptors
- name="desc">
+ name="DirectFigureRef">
<actualFigure
xsi:type="gmfgraph:FigureRef"
figure="//@figures.0/@figures.0">
@@ -17,8 +18,34 @@
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="node"
- figure="desc"/>
+ 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 2299afa..8356f81 100644
--- a/tests/org.eclipse.gmf.tests/pom.xml
+++ b/tests/org.eclipse.gmf.tests/pom.xml
@@ -52,7 +52,15 @@
<useUIThread>true</useUIThread>
</configuration>
</execution>
+ <execution>
+ <!-- Skip default test -->
+ <id>default-test</id>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </execution>
</executions>
+ <!-- Inherited configuration -->
<configuration>
<useUIHarness>true</useUIHarness>
<testSuite>org.eclipse.gmf.tests</testSuite>
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
index 95dbdbd..cc2fc97 100644
--- 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
@@ -63,17 +63,55 @@ public class FigureGenerationTest extends SWTBotEclipseTestCase {
return null;
}
}, 40000);
- 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/Desc.java"));
- IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file);
- } catch (Exception ex) {
- ex.printStackTrace();
+ {
+ // 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();
+ }
}
- }
- });
- Assert.assertTrue("Did not find specified background color attribute", bot.editorByTitle("Desc.java").toTextEditor().getText().contains("ColorConstants.lightGreen"));
+ });
+ 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"));
+ }
}
}