Commit dd05ae21 authored by Minh Hiep Pham's avatar Minh Hiep Pham 💬
Browse files

Updated test for cloning component

parent 30e7d012
......@@ -2404,7 +2404,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree {
public void cloneComponent(TGComponent _tgc) {
cloneComponent(_tgc, false);
cloneComponent(_tgc, true);
}
/*
......@@ -2435,6 +2435,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree {
}
clone = mgui.gtm.makeXMLFromSelectedComponentOfADiagram(this, getMaxIdSelected(), _tgc.getX(), _tgc.getY(), cloneEvenIfNonNullFather);
//TraceManager.addDev(clone);
_tgc.select(false);
for(int i = 0; i < connectorList.size(); i++){
......
......@@ -15,8 +15,12 @@ import static org.junit.Assert.*;
public class TDiagramPanelCloneTest extends AbstractUITest {
static TDiagramPanel diagramPanel;
static TGComponent tgComponent;
final static String EXPECTED_FILE = getBaseResourcesDir() + "tmltranslator/expected/expected_spec.tml";
static TGComponent tgComponent1;
static TGComponent tgComponent2;
static TGComponent tgComponent3;
final static String EXPECTED_FILE1 = getBaseResourcesDir() + "tmltranslator/expected/expected_spec1.tml";
final static String EXPECTED_FILE2 = getBaseResourcesDir() + "tmltranslator/expected/expected_spec2.tml";
final static String EXPECTED_FILE3 = getBaseResourcesDir() + "tmltranslator/expected/expected_spec3.tml";
@BeforeClass
......@@ -45,23 +49,58 @@ public class TDiagramPanelCloneTest extends AbstractUITest {
}
}
//tgComponent = findDiagComponent(238, diagramPanel);
for (TGComponent tgc : diagramPanel.getComponentList()) {
if (tgc instanceof TMLCCompositeComponent) {
tgComponent = tgc;
for (TGComponent tgc : diagramPanel.getAllComponent()) {
if (tgc.getValue().equals("CompositeComp1")) {
tgComponent1 = tgc;
}
if (tgc.getValue().equals("CompositeComp2")) {
tgComponent2 = tgc;
}
if (tgc.getValue().equals("PrimitiveComp5")) {
tgComponent3 = tgc;
}
}
}
@Test
public void testCloneComponent() throws Exception{
@Test
public void testCloneCompositeComponentWithNullFather() throws Exception{
CompareTML compTML = new CompareTML();
diagramPanel.cloneComponent(tgComponent);
diagramPanel.cloneComponent(tgComponent1);
// mainGUI.modelChecking();
mainGUI.checkModelingSyntax(true);
mainGUI.generateTMLTxt();
File f1 = new File(EXPECTED_FILE);
File f1 = new File(EXPECTED_FILE1);
File f2 = new File("spec.tml"); // Generated file after executing "TML generation"
assertTrue(compTML.compareTML(f1,f2));
}
@Test
public void testCloneCompositeComponentWithNonNullFather() throws Exception {
CompareTML compTML = new CompareTML();
diagramPanel.cloneComponent(tgComponent2);
// mainGUI.modelChecking();
mainGUI.checkModelingSyntax(true);
mainGUI.generateTMLTxt();
File f1 = new File(EXPECTED_FILE2);
File f2 = new File("spec.tml"); // Generated file after executing "TML generation"
assertTrue(compTML.compareTML(f1,f2));
}
@Test
public void testClonePrimitiveComponent() throws Exception {
CompareTML compTML = new CompareTML();
diagramPanel.cloneComponent(tgComponent3);
// mainGUI.modelChecking();
mainGUI.checkModelingSyntax(true);
mainGUI.generateTMLTxt();
File f1 = new File(EXPECTED_FILE3);
File f2 = new File("spec.tml"); // Generated file after executing "TML generation"
assertTrue(compTML.compareTML(f1,f2));
}
}
\ No newline at end of file
// TML Application - FORMAT 0.1
// Application: /home/pham/Documents/TToolHelp/TTool/modeling/DIPLODOCUS/CloneCompositeComponentTest.xml
// Generated: Wed Mar 20 17:19:43 CET 2019
// Channels
CHANNEL DIPLODOCUS_C_Design__channel BRBW 4 8 OUT DIPLODOCUS_C_Design__PrimitiveComp1 IN DIPLODOCUS_C_Design__PrimitiveComp2
CHANNEL DIPLODOCUS_C_Design__channel2 BRBW 4 8 OUT DIPLODOCUS_C_Design__PrimitiveComp3 IN DIPLODOCUS_C_Design__PrimitiveComp4
CHANNEL DIPLODOCUS_C_Design__channel2_0 BRBW 4 8 OUT DIPLODOCUS_C_Design__PrimitiveComp3_0 IN DIPLODOCUS_C_Design__PrimitiveComp4_0
CHANNEL DIPLODOCUS_C_Design__channel3 BRBW 4 8 OUT DIPLODOCUS_C_Design__PrimitiveComp5 IN DIPLODOCUS_C_Design__PrimitiveComp5
CHANNEL DIPLODOCUS_C_Design__channel3_0 BRBW 4 8 OUT DIPLODOCUS_C_Design__PrimitiveComp5_0 IN DIPLODOCUS_C_Design__PrimitiveComp5_0
CHANNEL DIPLODOCUS_C_Design__channel_0 BRBW 4 8 OUT DIPLODOCUS_C_Design__PrimitiveComp1_0 IN DIPLODOCUS_C_Design__PrimitiveComp2_0
// Events
EVENT DIPLODOCUS_C_Design__event_0__DIPLODOCUS_C_Design__event_0() NIB 8 DIPLODOCUS_C_Design__PrimitiveComp1_0 DIPLODOCUS_C_Design__PrimitiveComp2_0
EVENT DIPLODOCUS_C_Design__event__DIPLODOCUS_C_Design__event() NIB 8 DIPLODOCUS_C_Design__PrimitiveComp1 DIPLODOCUS_C_Design__PrimitiveComp2
// Requests
TASK DIPLODOCUS_C_Design__PrimitiveComp1
TASKOP
//Local variables
//Behavior
RAND
CASERAND 50
NOTIFY DIPLODOCUS_C_Design__event__DIPLODOCUS_C_Design__event
ENDCASERAND
CASERAND 50
WRITE DIPLODOCUS_C_Design__channel 1
ENDCASERAND
ENDRAND
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp1_0
TASKOP
//Local variables
//Behavior
RAND
CASERAND 50
NOTIFY DIPLODOCUS_C_Design__event_0__DIPLODOCUS_C_Design__event_0
ENDCASERAND
CASERAND 50
WRITE DIPLODOCUS_C_Design__channel_0 1
ENDCASERAND
ENDRAND
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp2
TASKOP
//Local variables
//Behavior
RAND
CASERAND 50
WAIT DIPLODOCUS_C_Design__event__DIPLODOCUS_C_Design__event
ENDCASERAND
CASERAND 50
READ DIPLODOCUS_C_Design__channel 1
ENDCASERAND
ENDRAND
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp2_0
TASKOP
//Local variables
//Behavior
RAND
CASERAND 50
WAIT DIPLODOCUS_C_Design__event_0__DIPLODOCUS_C_Design__event_0
ENDCASERAND
CASERAND 50
READ DIPLODOCUS_C_Design__channel_0 1
ENDCASERAND
ENDRAND
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp3
TASKOP
//Local variables
//Behavior
WRITE DIPLODOCUS_C_Design__channel2 1
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp3_0
TASKOP
//Local variables
//Behavior
WRITE DIPLODOCUS_C_Design__channel2_0 1
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp4
TASKOP
//Local variables
//Behavior
READ DIPLODOCUS_C_Design__channel2 1
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp4_0
TASKOP
//Local variables
//Behavior
READ DIPLODOCUS_C_Design__channel2_0 1
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp5
TASKOP
//Local variables
//Behavior
WRITE DIPLODOCUS_C_Design__channel3 1
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp5_0
TASKOP
//Local variables
//Behavior
WRITE DIPLODOCUS_C_Design__channel3_0 1
ENDTASK
// TML Application - FORMAT 0.1
// Application: /home/pham/Documents/TToolHelp/TTool/modeling/DIPLODOCUS/CloneCompositeComponentTest.xml
// Generated: Wed Mar 20 17:20:10 CET 2019
// Channels
CHANNEL DIPLODOCUS_C_Design__channel BRBW 4 8 OUT DIPLODOCUS_C_Design__PrimitiveComp1 IN DIPLODOCUS_C_Design__PrimitiveComp2
CHANNEL DIPLODOCUS_C_Design__channel2 BRBW 4 8 OUT DIPLODOCUS_C_Design__PrimitiveComp3 IN DIPLODOCUS_C_Design__PrimitiveComp4
CHANNEL DIPLODOCUS_C_Design__channel2_0 BRBW 4 8 OUT DIPLODOCUS_C_Design__PrimitiveComp3_0 IN DIPLODOCUS_C_Design__PrimitiveComp4_0
CHANNEL DIPLODOCUS_C_Design__channel3 BRBW 4 8 OUT DIPLODOCUS_C_Design__PrimitiveComp5 IN DIPLODOCUS_C_Design__PrimitiveComp5
CHANNEL DIPLODOCUS_C_Design__channel3_0 BRBW 4 8 OUT DIPLODOCUS_C_Design__PrimitiveComp5_0 IN DIPLODOCUS_C_Design__PrimitiveComp5_0
// Events
EVENT DIPLODOCUS_C_Design__event__DIPLODOCUS_C_Design__event() NIB 8 DIPLODOCUS_C_Design__PrimitiveComp1 DIPLODOCUS_C_Design__PrimitiveComp2
// Requests
TASK DIPLODOCUS_C_Design__PrimitiveComp1
TASKOP
//Local variables
//Behavior
RAND
CASERAND 50
NOTIFY DIPLODOCUS_C_Design__event__DIPLODOCUS_C_Design__event
ENDCASERAND
CASERAND 50
WRITE DIPLODOCUS_C_Design__channel 1
ENDCASERAND
ENDRAND
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp2
TASKOP
//Local variables
//Behavior
RAND
CASERAND 50
WAIT DIPLODOCUS_C_Design__event__DIPLODOCUS_C_Design__event
ENDCASERAND
CASERAND 50
READ DIPLODOCUS_C_Design__channel 1
ENDCASERAND
ENDRAND
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp3
TASKOP
//Local variables
//Behavior
WRITE DIPLODOCUS_C_Design__channel2 1
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp3_0
TASKOP
//Local variables
//Behavior
WRITE DIPLODOCUS_C_Design__channel2_0 1
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp4
TASKOP
//Local variables
//Behavior
READ DIPLODOCUS_C_Design__channel2 1
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp4_0
TASKOP
//Local variables
//Behavior
READ DIPLODOCUS_C_Design__channel2_0 1
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp5
TASKOP
//Local variables
//Behavior
WRITE DIPLODOCUS_C_Design__channel3 1
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp5_0
TASKOP
//Local variables
//Behavior
WRITE DIPLODOCUS_C_Design__channel3_0 1
ENDTASK
// TML Application - FORMAT 0.1
// Application: /home/pham/Documents/TToolHelp/TTool/modeling/DIPLODOCUS/CloneCompositeComponentTest.xml
// Generated: Wed Mar 20 17:20:50 CET 2019
// Channels
CHANNEL DIPLODOCUS_C_Design__channel BRBW 4 8 OUT DIPLODOCUS_C_Design__PrimitiveComp1 IN DIPLODOCUS_C_Design__PrimitiveComp2
CHANNEL DIPLODOCUS_C_Design__channel2 BRBW 4 8 OUT DIPLODOCUS_C_Design__PrimitiveComp3 IN DIPLODOCUS_C_Design__PrimitiveComp4
CHANNEL DIPLODOCUS_C_Design__channel3 BRBW 4 8 OUT DIPLODOCUS_C_Design__PrimitiveComp5 IN DIPLODOCUS_C_Design__PrimitiveComp5
CHANNEL DIPLODOCUS_C_Design__channel3_0 BRBW 4 8 OUT DIPLODOCUS_C_Design__PrimitiveComp5_0 IN DIPLODOCUS_C_Design__PrimitiveComp5_0
// Events
EVENT DIPLODOCUS_C_Design__event__DIPLODOCUS_C_Design__event() NIB 8 DIPLODOCUS_C_Design__PrimitiveComp1 DIPLODOCUS_C_Design__PrimitiveComp2
// Requests
TASK DIPLODOCUS_C_Design__PrimitiveComp1
TASKOP
//Local variables
//Behavior
RAND
CASERAND 50
NOTIFY DIPLODOCUS_C_Design__event__DIPLODOCUS_C_Design__event
ENDCASERAND
CASERAND 50
WRITE DIPLODOCUS_C_Design__channel 1
ENDCASERAND
ENDRAND
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp2
TASKOP
//Local variables
//Behavior
RAND
CASERAND 50
WAIT DIPLODOCUS_C_Design__event__DIPLODOCUS_C_Design__event
ENDCASERAND
CASERAND 50
READ DIPLODOCUS_C_Design__channel 1
ENDCASERAND
ENDRAND
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp3
TASKOP
//Local variables
//Behavior
WRITE DIPLODOCUS_C_Design__channel2 1
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp4
TASKOP
//Local variables
//Behavior
READ DIPLODOCUS_C_Design__channel2 1
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp5
TASKOP
//Local variables
//Behavior
WRITE DIPLODOCUS_C_Design__channel3 1
ENDTASK
TASK DIPLODOCUS_C_Design__PrimitiveComp5_0
TASKOP
//Local variables
//Behavior
WRITE DIPLODOCUS_C_Design__channel3_0 1
ENDTASK
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment