Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-10-31 20:08:03 +0000
committeratikhomirov2006-10-31 20:08:03 +0000
commit34a7221896f88228081cc455c3a320985125e80c (patch)
tree8e16ad0e4b7424b021e62b38893eb21457db655c
parent8f229622fb4540856ad733b3d663d27763e23357 (diff)
downloadorg.eclipse.gmf-tooling-34a7221896f88228081cc455c3a320985125e80c.tar.gz
org.eclipse.gmf-tooling-34a7221896f88228081cc455c3a320985125e80c.tar.xz
org.eclipse.gmf-tooling-34a7221896f88228081cc455c3a320985125e80c.zip
move performTest logic out from CodegenUtil (and get rid of duplication with AbstractFigureGeneratorSetup#performTests)
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gen/StandaloneMapModeTest.java22
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/figures/FigureGeneratorUtil.java24
2 files changed, 23 insertions, 23 deletions
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gen/StandaloneMapModeTest.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gen/StandaloneMapModeTest.java
index 778c4c4d3..f1ae79b4d 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gen/StandaloneMapModeTest.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gen/StandaloneMapModeTest.java
@@ -28,8 +28,12 @@ import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode;
import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeTypes;
import org.eclipse.gmf.tests.setup.figures.FigureCheck;
import org.eclipse.gmf.tests.setup.figures.FigureGeneratorUtil;
+import org.eclipse.gmf.tests.setup.figures.FigureGeneratorUtil.GeneratedClassData;
import org.osgi.framework.Bundle;
+/**
+ * @see MapModeStrategyTest
+ */
public class StandaloneMapModeTest extends TestCase {
public StandaloneMapModeTest(String name) {
@@ -38,17 +42,19 @@ public class StandaloneMapModeTest extends TestCase {
public void testStaticIdentityMapMode(){
Config config = FigureGeneratorUtil.createStandaloneGeneratorConfig(FigureGeneratorUtil.DEFAULT_FIGURE_PACKAGE, false);
- FigureGeneratorUtil.performTests(createTestFigure(), new FigureSizeCheck(123, 456), config);
- }
-
- public void testRuntimeIdentityMapMode(){
- Config config = FigureGeneratorUtil.createStandaloneGeneratorConfig(FigureGeneratorUtil.DEFAULT_FIGURE_PACKAGE, true);
- FigureGeneratorUtil.performTests(createTestFigure(), new InstantiateFigureHook(123, 456, MapModeTypes.IDENTITY_MM, config), config);
+ GeneratedClassData[] theOnly = FigureGeneratorUtil.generateAndCompile(config, createTestFigure());
+ assertEquals(1, theOnly.length);
+ new FigureSizeCheck(123, 456).go(theOnly[0].getLoadedClass());
}
- public void testRuntimeHiMetricsMapMode(){
+ public void testRuntimeIdentityAndHiMetricMapMode(){
Config config = FigureGeneratorUtil.createStandaloneGeneratorConfig(FigureGeneratorUtil.DEFAULT_FIGURE_PACKAGE, true);
- FigureGeneratorUtil.performTests(createTestFigure(), new InstantiateFigureHook(123, 456, MapModeTypes.HIMETRIC_MM, config), config);
+ GeneratedClassData[] theOnly = FigureGeneratorUtil.generateAndCompile(config, createTestFigure());
+ assertNotNull(theOnly);
+ assertEquals(1, theOnly.length);
+ Class figureClass = theOnly[0].getLoadedClass();
+ new InstantiateFigureHook(123, 456, MapModeTypes.IDENTITY_MM, config).go(figureClass);
+ new InstantiateFigureHook(123, 456, MapModeTypes.HIMETRIC_MM, config).go(figureClass);
}
private Figure createTestFigure(){
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/figures/FigureGeneratorUtil.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/figures/FigureGeneratorUtil.java
index 4c01bc253..c0c9b4203 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/figures/FigureGeneratorUtil.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/figures/FigureGeneratorUtil.java
@@ -12,6 +12,7 @@
package org.eclipse.gmf.tests.setup.figures;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@@ -62,20 +63,6 @@ public class FigureGeneratorUtil {
// FigureGenerator: utility methods to generate/compile/instantiate figures
- public static void performTests(Figure f, FigureCheck check, Config config) {
- Assert.assertNotNull(check);
- generateAndParse(f);
- FigureGallery gallery = GMFGraphFactory.eINSTANCE.createFigureGallery();
- gallery.setName("bb");
- gallery.getFigures().add(f);
-
- GeneratedClassData[] theOnly = generateAndCompile(gallery, config);
- Assert.assertNotNull(theOnly);
- Assert.assertEquals(1, theOnly.length);
- Class figureClass = theOnly[0].getLoadedClass();
- check.go(figureClass);
- }
-
public static void generate(StandaloneGenerator.Config config, Processor processor) {
StandaloneGenerator generator = new StandaloneGenerator(processor, config, new RuntimeFQNSwitch());
generator.run();
@@ -86,6 +73,13 @@ public class FigureGeneratorUtil {
return generateAndCompile(gallery, createStandaloneGeneratorConfig());
}
+ public static GeneratedClassData[] generateAndCompile(StandaloneGenerator.Config config, Figure... figures) {
+ FigureGallery gallery = GMFGraphFactory.eINSTANCE.createFigureGallery();
+ gallery.setName("bb");
+ gallery.getFigures().addAll(Arrays.asList(figures));
+ return generateAndCompile(gallery, config);
+ }
+
public static GeneratedClassData[] generateAndCompile(FigureGallery gallery, StandaloneGenerator.Config config) {
Assert.assertTrue(gallery.getName() != null && gallery.getName().trim().length() > 0);
Assert.assertFalse(gallery.getFigures().isEmpty());
@@ -129,7 +123,7 @@ public class FigureGeneratorUtil {
generateAndParse(f, generator, DEFAULT_FIGURE_PACKAGE);
}
- public static void generateAndParse(Figure f, FigureGenerator generator, String packageName) {
+ private static void generateAndParse(Figure f, FigureGenerator generator, String packageName) {
ImportAssistant importManager = createImportManager(packageName, f);
String res = generator.go(f, importManager);

Back to the top