diff options
author | Henrik Rentz-Reichert | 2011-01-28 17:06:39 +0000 |
---|---|---|
committer | Henrik Rentz-Reichert | 2011-01-28 17:06:39 +0000 |
commit | a9e210d4416699b4595d30bb1107f8fed4b4bc09 (patch) | |
tree | 201f56055e097d4ea5ba24b39eb3d42183c78f40 /tests | |
parent | 635957ae0eaf508602216ec555e500908de4a232 (diff) | |
download | org.eclipse.etrice-a9e210d4416699b4595d30bb1107f8fed4b4bc09.tar.gz org.eclipse.etrice-a9e210d4416699b4595d30bb1107f8fed4b4bc09.tar.xz org.eclipse.etrice-a9e210d4416699b4595d30bb1107f8fed4b4bc09.zip |
ui.structure.tests: new test plug-in for structure diagrams
Diffstat (limited to 'tests')
9 files changed, 188 insertions, 0 deletions
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/.classpath b/tests/org.eclipse.etrice.ui.structure.tests/.classpath new file mode 100644 index 000000000..ad32c83a7 --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <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"/> +</classpath> diff --git a/tests/org.eclipse.etrice.ui.structure.tests/.project b/tests/org.eclipse.etrice.ui.structure.tests/.project new file mode 100644 index 000000000..aa27fa17a --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.etrice.ui.structure.tests</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/tests/org.eclipse.etrice.ui.structure.tests/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.etrice.ui.structure.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..7f8e6f7b4 --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Fri Jan 28 15:16:58 CET 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.etrice.ui.structure.tests/META-INF/MANIFEST.MF new file mode 100644 index 000000000..71c8a75a5 --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: eTrice Structure Diagram Tests +Bundle-SymbolicName: org.eclipse.etrice.ui.structure.tests +Bundle-Version: 0.1.0 +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.junit;bundle-version="4.8.1", + org.eclipse.etrice.core.room;bundle-version="0.1.0", + org.eclipse.etrice.ui.structure;bundle-version="0.1.0", + org.eclipse.xtext;bundle-version="1.0.1", + org.eclipse.graphiti;bundle-version="0.7.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-Vendor: eTrice (Incubation) +Bundle-ActivationPolicy: lazy +Bundle-Activator: org.eclipse.etrice.ui.structure.StructureTestActivator diff --git a/tests/org.eclipse.etrice.ui.structure.tests/build.properties b/tests/org.eclipse.etrice.ui.structure.tests/build.properties new file mode 100644 index 000000000..41eb6ade2 --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/build.properties @@ -0,0 +1,4 @@ +source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClass.room b/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClass.room new file mode 100644 index 000000000..53c3c3275 --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/models/ActorClass.room @@ -0,0 +1,4 @@ +RoomModel ActorClass1 {
+ ActorClass MyActorClass {
+ }
+}
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/StructureTestActivator.java b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/StructureTestActivator.java new file mode 100644 index 000000000..a9f5b1037 --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/StructureTestActivator.java @@ -0,0 +1,22 @@ +package org.eclipse.etrice.ui.structure;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class StructureTestActivator extends Plugin implements BundleActivator {
+
+ private static StructureTestActivator instance = null;
+
+ public static StructureTestActivator getInstance() {
+ return instance;
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+
+ instance = this;
+ }
+
+}
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClass.java b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClass.java new file mode 100644 index 000000000..6fd66b363 --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClass.java @@ -0,0 +1,47 @@ +package org.eclipse.etrice.ui.structure.commands;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.ui.structure.DiagramAccess;
+import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.graphiti.services.Graphiti;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestActorClass extends TestBase {
+
+ @Before
+ public void setUp() {
+ loadModelFile();
+ }
+
+ @Override
+ protected String getModelFileName() {
+ return "ActorClass.room";
+ }
+
+ @Test
+ public void checkModel() {
+ assertEquals("models read", 1, getModels().size());
+ assertEquals("actor classes in our model", 1, getModels().get(0).getActorClasses().size());
+ }
+
+ @Test
+ public void testActorClass() {
+ ActorClass ac = getModels().get(0).getActorClasses().get(0);
+ Diagram diagram = DiagramAccess.getDiagram(ac);
+
+ assertEquals("diagram children", 1, diagram.getChildren().size());
+
+ Shape shape = diagram.getChildren().get(0);
+ assertTrue("top level shape is container shape", shape instanceof ContainerShape);
+
+ EObject bo = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(shape);
+ assertTrue("top level business object is ActorClass", bo instanceof ActorClass);
+ }
+}
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestBase.java b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestBase.java new file mode 100644 index 000000000..74e66b2aa --- /dev/null +++ b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestBase.java @@ -0,0 +1,52 @@ +package org.eclipse.etrice.ui.structure.commands;
+
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.LinkedList;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.ui.structure.StructureTestActivator;
+import org.eclipse.xtext.resource.XtextResource;
+import org.eclipse.xtext.resource.XtextResourceSet;
+
+public abstract class TestBase {
+
+ private String basePath;
+ private LinkedList<RoomModel> models = new LinkedList<RoomModel>();
+
+ protected void loadModelFile() {
+ try {
+ URL modelsDir = StructureTestActivator.getInstance().getBundle().getEntry("models");
+ URL fileURL = FileLocator.toFileURL(modelsDir);
+ basePath = fileURL.getFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ loadModels(getModelFileName());
+ }
+
+ private void loadModels(String modelName) {
+ XtextResourceSet rs = new XtextResourceSet();
+ rs.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
+ String path = basePath + modelName;
+ URI uri = URI.createFileURI(path);
+ Resource resource = rs.getResource(uri, true);
+ Object root = resource.getContents().get(0);
+ if (root instanceof RoomModel)
+ models.add((RoomModel) root);
+ else
+ fail("File contains no RoomModel as root object");
+ }
+
+ public LinkedList<RoomModel> getModels() {
+ return models;
+ }
+
+ protected abstract String getModelFileName();
+}
|