소스 검색

Added EntryChoice TestModel

Andreas Mülder 12 년 전
부모
커밋
f49b9e8338

+ 22 - 0
test-plugins/org.yakindu.sct.generator.c.test/gtests/EntryChoice/EntryChoice.cc

@@ -0,0 +1,22 @@
+/**
+* Copyright (c) 2013 committers of YAKINDU and others.
+* 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:
+*     committers of YAKINDU - initial API and implementation
+*/
+#include <string>
+#include "gtest/gtest.h"
+#include "EntryChoice.h"
+
+TEST(StatemachineTest, EntryChoiceTest) {
+	EntryChoice handle;
+	entryChoice_init(&handle);
+	entryChoice_enter(&handle);
+	entryChoice_runCycle(&handle);
+	entryChoice_runCycle(&handle);
+	EXPECT_TRUE(entryChoice_isActive(&handle, EntryChoice_main_region_A));
+}

+ 8 - 0
test-plugins/org.yakindu.sct.generator.c.test/gtests/EntryChoice/EntryChoice.sgen

@@ -0,0 +1,8 @@
+GeneratorModel for yakindu::c {
+	statechart EntryChoice {
+		feature Outlet {
+			targetProject = "gtests"
+			targetFolder = "EntryChoice"
+		}
+	}
+}

+ 8 - 0
test-plugins/org.yakindu.sct.generator.c.test/model/test.sgen

@@ -80,6 +80,14 @@ GeneratorModel for sctunit::c {
 		}			
 	}
 	
+	test EntryChoice{
+		
+		feature Outlet{ 
+			targetProject = "org.yakindu.sct.generator.c.test" 
+			targetFolder = "test-gen"			
+		}			
+	}
+	
 	test ExitOnSelfTransition{
 		
 		feature Outlet{ 

+ 39 - 0
test-plugins/org.yakindu.sct.generator.c.test/test-gen/org/yakindu/sct/generator/c/test/EntryChoice.java

@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2013 committers of YAKINDU and others.
+ * 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:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.c.test;
+
+import java.util.Collection;
+
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.yakindu.sct.generator.c.gtest.GTest;
+import org.yakindu.sct.generator.c.gtest.GTestRunner;
+import org.yakindu.sct.generator.c.gtest.GTestHelper;
+
+@GTest(sourceFile = "gtests/EntryChoice/EntryChoice.cc", program = "gtests/EntryChoice/EntryChoice", model = "testmodels/SCTUnit/EntryChoice.sct")
+@RunWith(GTestRunner.class)
+public class EntryChoice {
+
+	protected final GTestHelper helper = new GTestHelper(this) {
+
+		@Override
+		protected void getSourceFiles(Collection<String> files) {
+			super.getSourceFiles(files);
+			files.add(getFileName(getTestProgram()) + ".c");
+		}
+	};
+
+	@Before
+	public void setUp() {
+		helper.generate();
+		helper.compile();
+	}
+}

+ 9 - 0
test-plugins/org.yakindu.sct.generator.java.test/model/model.sgen

@@ -82,6 +82,15 @@ GeneratorModel for yakindu::java {
 		}
 		
 	}
+	
+	statechart EntryChoice {
+		feature Outlet {
+			targetProject = "org.yakindu.sct.generator.java.test"
+			targetFolder = "src-gen"
+		}
+
+	}
+	
 	statechart EnterState {
 		feature Outlet {
 			targetProject = "org.yakindu.sct.generator.java.test"

+ 8 - 0
test-plugins/org.yakindu.sct.generator.java.test/model/test.sgen

@@ -80,6 +80,14 @@ GeneratorModel for sctunit::java {
 		}			
 	}
 	
+	test EntryChoice{
+		
+		feature Outlet{ 
+			targetProject = "org.yakindu.sct.generator.java.test" 
+			targetFolder = "test-gen"			
+		}			
+	}
+	
 	test ExitOnSelfTransition{
 		
 		feature Outlet{ 

+ 91 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/entrychoice/EntryChoiceStatemachine.java

@@ -0,0 +1,91 @@
+package org.yakindu.scr.entrychoice;
+
+public class EntryChoiceStatemachine implements IEntryChoiceStatemachine {
+
+	public enum State {
+		main_region_A, $NullState$
+	};
+
+	private final State[] stateVector = new State[1];
+
+	private int nextStateIndex;
+
+	public EntryChoiceStatemachine() {
+
+	}
+
+	public void init() {
+		for (int i = 0; i < 1; i++) {
+			stateVector[i] = State.$NullState$;
+		}
+
+		clearEvents();
+		clearOutEvents();
+
+	}
+
+	public void enter() {
+		entryAction();
+
+	}
+
+	public void exit() {
+		switch (stateVector[0]) {
+			case main_region_A :
+				nextStateIndex = 0;
+				stateVector[0] = State.$NullState$;
+				break;
+
+			default :
+				break;
+		}
+
+		exitAction();
+	}
+
+	protected void clearEvents() {
+
+	}
+
+	protected void clearOutEvents() {
+	}
+
+	public boolean isStateActive(State state) {
+		switch (state) {
+			case main_region_A :
+				return stateVector[0] == State.main_region_A;
+			default :
+				return false;
+		}
+	}
+
+	/* Entry action for statechart 'EntryChoice'. */
+	private void entryAction() {
+	}
+
+	/* Exit action for state 'EntryChoice'. */
+	private void exitAction() {
+	}
+
+	/* The reactions of state A. */
+	private void reactMain_region_A() {
+	}
+
+	public void runCycle() {
+
+		clearOutEvents();
+
+		for (nextStateIndex = 0; nextStateIndex < stateVector.length; nextStateIndex++) {
+
+			switch (stateVector[nextStateIndex]) {
+				case main_region_A :
+					reactMain_region_A();
+					break;
+				default :
+					// $NullState$
+			}
+		}
+
+		clearEvents();
+	}
+}

+ 6 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/entrychoice/IEntryChoiceStatemachine.java

@@ -0,0 +1,6 @@
+package org.yakindu.scr.entrychoice;
+import org.yakindu.scr.IStatemachine;
+
+public interface IEntryChoiceStatemachine extends IStatemachine {
+
+}

+ 2 - 1
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/AllTestsTest.java

@@ -30,6 +30,7 @@ import org.junit.runners.Suite.SuiteClasses;
 		SimpleHierachyTest.class, StateIsActiveTest.class,
 		STextKeywordsInStatesAndRegionsTest.class, StringExpressionsTest.class,
 		SyncForkTest.class, SyncJoinTest.class,
-		TransitionWithoutConditionTest.class, ValuedEventsTest.class})
+		TransitionWithoutConditionTest.class, ValuedEventsTest.class,
+		EntryChoiceTest.class})
 public class AllTestsTest {
 }

+ 46 - 0
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/EntryChoiceTest.java

@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) 2013 committers of YAKINDU and others.
+ * 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:
+ *     committers of YAKINDU - initial API and implementation
+ */
+
+package org.yakindu.sct.generator.java.test;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.yakindu.scr.entrychoice.EntryChoiceStatemachine;
+import org.yakindu.scr.entrychoice.EntryChoiceStatemachine.State;
+/**
+ *  Unit TestCase for EntryChoice
+ */
+@SuppressWarnings("all")
+public class EntryChoiceTest {
+
+	private EntryChoiceStatemachine statemachine;
+
+	@Before
+	public void setUp() {
+		statemachine = new EntryChoiceStatemachine();
+		statemachine.init();
+	}
+
+	@After
+	public void tearDown() {
+		statemachine = null;
+	}
+
+	@Test
+	public void testEntryChoiceTest() {
+		statemachine.enter();
+		statemachine.runCycle();
+		statemachine.runCycle();
+		assertTrue(statemachine.isStateActive(State.main_region_A));
+	}
+}

+ 89 - 0
test-plugins/org.yakindu.sct.test.models/testmodels/SCTUnit/EntryChoice.sct

@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:sgraph="http://www.yakindu.org/sct/sgraph/2.0.0">
+  <sgraph:Statechart xmi:id="_zj4QIFOAEeOER5CRer9eDw" name="EntryChoice">
+    <regions xmi:id="_zj5eQlOAEeOER5CRer9eDw" name="main region">
+      <vertices xsi:type="sgraph:Entry" xmi:id="_zj9vsVOAEeOER5CRer9eDw">
+        <outgoingTransitions xmi:id="_zj_k41OAEeOER5CRer9eDw" target="_0Vt8wFOAEeOER5CRer9eDw"/>
+      </vertices>
+      <vertices xsi:type="sgraph:State" xmi:id="_zj-Wx1OAEeOER5CRer9eDw" name="A" incomingTransitions="_1CN2YFOAEeOER5CRer9eDw"/>
+      <vertices xsi:type="sgraph:Choice" xmi:id="_0Vt8wFOAEeOER5CRer9eDw" incomingTransitions="_zj_k41OAEeOER5CRer9eDw">
+        <outgoingTransitions xmi:id="_1CN2YFOAEeOER5CRer9eDw" specification="default" target="_zj-Wx1OAEeOER5CRer9eDw"/>
+      </vertices>
+    </regions>
+  </sgraph:Statechart>
+  <notation:Diagram xmi:id="_zj5eQFOAEeOER5CRer9eDw" type="org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor" element="_zj4QIFOAEeOER5CRer9eDw" measurementUnit="Pixel">
+    <children xmi:id="_zj7TcFOAEeOER5CRer9eDw" type="Region" element="_zj5eQlOAEeOER5CRer9eDw">
+      <children xsi:type="notation:DecorationNode" xmi:id="_zj9IoFOAEeOER5CRer9eDw" type="RegionName">
+        <styles xsi:type="notation:ShapeStyle" xmi:id="_zj9IoVOAEeOER5CRer9eDw"/>
+        <layoutConstraint xsi:type="notation:Location" xmi:id="_zj9IolOAEeOER5CRer9eDw"/>
+      </children>
+      <children xsi:type="notation:Shape" xmi:id="_zj9Io1OAEeOER5CRer9eDw" type="RegionCompartment" fontName="Verdana" lineColor="4210752">
+        <children xmi:id="_zj9vslOAEeOER5CRer9eDw" type="Entry" element="_zj9vsVOAEeOER5CRer9eDw">
+          <children xmi:id="_zj-WwFOAEeOER5CRer9eDw" type="BorderItemLabelContainer">
+            <children xsi:type="notation:DecorationNode" xmi:id="_zj-Ww1OAEeOER5CRer9eDw" type="BorderItemLabel">
+              <styles xsi:type="notation:ShapeStyle" xmi:id="_zj-WxFOAEeOER5CRer9eDw"/>
+              <layoutConstraint xsi:type="notation:Location" xmi:id="_zj-WxVOAEeOER5CRer9eDw"/>
+            </children>
+            <styles xsi:type="notation:ShapeStyle" xmi:id="_zj-WwVOAEeOER5CRer9eDw" fontName="Verdana" lineColor="4210752"/>
+            <layoutConstraint xsi:type="notation:Bounds" xmi:id="_zj-WwlOAEeOER5CRer9eDw"/>
+          </children>
+          <styles xsi:type="notation:ShapeStyle" xmi:id="_zj9vs1OAEeOER5CRer9eDw" fontName="Verdana" lineColor="4210752"/>
+          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_zj-WxlOAEeOER5CRer9eDw" x="70" y="20"/>
+        </children>
+        <children xmi:id="_zj-WyVOAEeOER5CRer9eDw" type="State" element="_zj-Wx1OAEeOER5CRer9eDw">
+          <children xsi:type="notation:DecorationNode" xmi:id="_zj-90FOAEeOER5CRer9eDw" type="StateName">
+            <styles xsi:type="notation:ShapeStyle" xmi:id="_zj-90VOAEeOER5CRer9eDw"/>
+            <layoutConstraint xsi:type="notation:Location" xmi:id="_zj-90lOAEeOER5CRer9eDw"/>
+          </children>
+          <children xsi:type="notation:Compartment" xmi:id="_zj-901OAEeOER5CRer9eDw" type="StateTextCompartment">
+            <children xsi:type="notation:Shape" xmi:id="_zj-91FOAEeOER5CRer9eDw" type="StateTextCompartmentExpression" fontName="Verdana" lineColor="4210752">
+              <layoutConstraint xsi:type="notation:Bounds" xmi:id="_zj-91VOAEeOER5CRer9eDw"/>
+            </children>
+          </children>
+          <children xsi:type="notation:Compartment" xmi:id="_zj_k4FOAEeOER5CRer9eDw" type="StateFigureCompartment"/>
+          <styles xsi:type="notation:ShapeStyle" xmi:id="_zj-WylOAEeOER5CRer9eDw" fontName="Verdana" fillColor="15981773" lineColor="12632256"/>
+          <styles xsi:type="notation:FontStyle" xmi:id="_zj-Wy1OAEeOER5CRer9eDw"/>
+          <styles xsi:type="notation:BooleanValueStyle" xmi:id="_zj_k4VOAEeOER5CRer9eDw" name="isHorizontal" booleanValue="true"/>
+          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_zj_k4lOAEeOER5CRer9eDw" x="139" y="112"/>
+        </children>
+        <children xsi:type="notation:Shape" xmi:id="_0V3GsFOAEeOER5CRer9eDw" type="Choice" element="_0Vt8wFOAEeOER5CRer9eDw" fontName="Verdana" lineColor="4210752">
+          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_0V3GsVOAEeOER5CRer9eDw" x="104" y="72"/>
+        </children>
+        <layoutConstraint xsi:type="notation:Bounds" xmi:id="_zj9IpFOAEeOER5CRer9eDw"/>
+      </children>
+      <styles xsi:type="notation:ShapeStyle" xmi:id="_zj7TcVOAEeOER5CRer9eDw" fontName="Verdana" fillColor="15790320" lineColor="12632256"/>
+      <layoutConstraint xsi:type="notation:Bounds" xmi:id="_zj9vsFOAEeOER5CRer9eDw" x="220" y="10" width="400" height="400"/>
+    </children>
+    <children xsi:type="notation:Shape" xmi:id="_zkAzA1OAEeOER5CRer9eDw" type="StatechartText" fontName="Verdana" lineColor="4210752">
+      <children xsi:type="notation:DecorationNode" xmi:id="_zkAzBVOAEeOER5CRer9eDw" type="StatechartName">
+        <styles xsi:type="notation:ShapeStyle" xmi:id="_zkAzBlOAEeOER5CRer9eDw"/>
+        <layoutConstraint xsi:type="notation:Location" xmi:id="_zkAzB1OAEeOER5CRer9eDw"/>
+      </children>
+      <children xsi:type="notation:Shape" xmi:id="_zkAzCFOAEeOER5CRer9eDw" type="StatechartTextExpression" fontName="Verdana" lineColor="4210752">
+        <layoutConstraint xsi:type="notation:Bounds" xmi:id="_zkAzCVOAEeOER5CRer9eDw"/>
+      </children>
+      <layoutConstraint xsi:type="notation:Bounds" xmi:id="_zkBaEFOAEeOER5CRer9eDw" x="10" y="10" width="200" height="400"/>
+    </children>
+    <styles xsi:type="notation:DiagramStyle" xmi:id="_zj5eQVOAEeOER5CRer9eDw"/>
+    <edges xmi:id="_zkAL8FOAEeOER5CRer9eDw" type="Transition" element="_zj_k41OAEeOER5CRer9eDw" source="_zj9vslOAEeOER5CRer9eDw" target="_0V3GsFOAEeOER5CRer9eDw">
+      <children xsi:type="notation:DecorationNode" xmi:id="_zkAzAFOAEeOER5CRer9eDw" type="TransitionExpression">
+        <styles xsi:type="notation:ShapeStyle" xmi:id="_zkAzAVOAEeOER5CRer9eDw"/>
+        <layoutConstraint xsi:type="notation:Location" xmi:id="_zkAzAlOAEeOER5CRer9eDw" y="10"/>
+      </children>
+      <styles xsi:type="notation:ConnectorStyle" xmi:id="_zkAL8VOAEeOER5CRer9eDw" lineColor="4210752"/>
+      <styles xsi:type="notation:FontStyle" xmi:id="_zkAL81OAEeOER5CRer9eDw" fontName="Verdana"/>
+      <bendpoints xsi:type="notation:RelativeBendpoints" xmi:id="_zkAL8lOAEeOER5CRer9eDw" points="[0, 0, 0, 0]$[0, 0, 0, 0]"/>
+      <targetAnchor xsi:type="notation:IdentityAnchor" xmi:id="_0q3GUFOAEeOER5CRer9eDw" id="(0.8,0.6666666666666666)"/>
+    </edges>
+    <edges xmi:id="_1CQSoFOAEeOER5CRer9eDw" type="Transition" element="_1CN2YFOAEeOER5CRer9eDw" source="_0V3GsFOAEeOER5CRer9eDw" target="_zj-WyVOAEeOER5CRer9eDw">
+      <children xsi:type="notation:DecorationNode" xmi:id="_1CQ5sFOAEeOER5CRer9eDw" type="TransitionExpression">
+        <styles xsi:type="notation:ShapeStyle" xmi:id="_1CQ5sVOAEeOER5CRer9eDw"/>
+        <layoutConstraint xsi:type="notation:Location" xmi:id="_1CQ5slOAEeOER5CRer9eDw" y="10"/>
+      </children>
+      <styles xsi:type="notation:ConnectorStyle" xmi:id="_1CQSoVOAEeOER5CRer9eDw" lineColor="4210752"/>
+      <styles xsi:type="notation:FontStyle" xmi:id="_1CQSo1OAEeOER5CRer9eDw" fontName="Verdana"/>
+      <bendpoints xsi:type="notation:RelativeBendpoints" xmi:id="_1CQSolOAEeOER5CRer9eDw" points="[-7, 4, 87, -38]$[-90, 25, 4, -17]"/>
+      <targetAnchor xsi:type="notation:IdentityAnchor" xmi:id="_1CUkEFOAEeOER5CRer9eDw" id="(0.7866666666666666,0.3584905660377358)"/>
+    </edges>
+  </notation:Diagram>
+</xmi:XMI>

+ 9 - 0
test-plugins/org.yakindu.sct.test.models/tests/EntryChoice.sctunit

@@ -0,0 +1,9 @@
+testgroup EntryChoice for statechart EntryChoice {
+	test EntryChoiceTest {
+		enter
+		cycle
+		cycle
+		assert active ( EntryChoice.main_region.A )
+	}
+}
+