source: trunk/quest-plugin-jfc-test/src/test/java/de/ugoe/cs/quest/plugin/jfc/JFCReplayIDCalculatorTest.java @ 796

Last change on this file since 796 was 796, checked in by fglaser, 12 years ago
  • Interface for replayID calculation and corresponding test case extended
  • Property svn:mime-type set to text/plain
File size: 4.3 KB
Line 
1package de.ugoe.cs.quest.plugin.jfc;
2
3import java.io.File;
4import java.util.ArrayList;
5import java.util.Collection;
6import java.util.HashSet;
7import java.util.List;
8
9import junit.framework.TestCase;
10
11import org.junit.After;
12import org.junit.Before;
13import org.junit.Test;
14
15import de.ugoe.cs.quest.eventcore.Event;
16import de.ugoe.cs.quest.eventcore.IEventTarget;
17import de.ugoe.cs.quest.plugin.jfc.eventcore.JFCEventId;
18import de.ugoe.cs.quest.plugin.jfc.guimodel.JFCGUIElement;
19import de.ugoe.cs.quest.plugin.jfc.guimodel.JFCGUIElementSpec;
20
21/**
22 * The class <code>EFGReplayIDCalculatorTest</code> contains tests for the class
23 * {@link <code>EFGReplayIDCalculator</code>}
24 *
25 * @pattern JUnit Test Case
26 *
27 * @generatedBy CodePro at 7/30/12 4:50 PM
28 *
29 * @author fabian.glaser
30 *
31 * @version $Revision$
32 */
33public class JFCReplayIDCalculatorTest extends TestCase {
34
35        /**
36         * Construct new test instance
37         *
38         * @param name the test name
39         */
40        public JFCReplayIDCalculatorTest(String name) {
41                super(name);
42        }
43
44        /**
45         * Run the String calculateReplayID(JFCEvent) method test.
46         *
47         * @throws Exception
48         *
49         * @generatedBy CodePro at 7/30/12 4:58 PM
50         */
51        @Test
52        public void testCalculateReplayIDwithEvent()
53                throws Exception {
54                Collection<JFCEventId> ignoredEvents = new HashSet<JFCEventId>();
55                ignoredEvents.add(JFCEventId.FOCUS_GAINED);
56                JFCLogParser parser = new JFCLogParser(ignoredEvents);
57                parser.parseFile(new File(ClassLoader.getSystemResource("freemind_trace.xml").getFile()));
58               
59                Collection<List<Event>> sequences = parser.getSequences();
60                Event event = sequences.iterator().next().get(0);
61               
62                String result = new JFCReplayIDCalculator().calculateReplayID(event);
63                assertEquals("e3561778462", result);
64        }
65       
66        /**
67         * Run the String calculateReplayID(List<JFCGUIElementSpec>) method test.
68         *
69         * @throws Exception
70         */
71        @Test
72        public void testCalculateReplayIDwithGuiElementPath()
73                throws Exception {
74                Collection<JFCEventId> ignoredEvents = new HashSet<JFCEventId>();
75                ignoredEvents.add(JFCEventId.FOCUS_GAINED);
76                JFCLogParser parser = new JFCLogParser(ignoredEvents);
77                parser.parseFile(new File(ClassLoader.getSystemResource("freemind_trace.xml").getFile()));
78               
79                Collection<List<Event>> sequences = parser.getSequences();
80                Event event = sequences.iterator().next().get(0);
81               
82                List<JFCGUIElementSpec> guiElementPath = new ArrayList<JFCGUIElementSpec>();
83               
84                IEventTarget target = event.getTarget();
85                JFCGUIElement jfcTarget = (JFCGUIElement) target;
86               
87                // extract element path
88                JFCGUIElement currentTarget = jfcTarget;
89                while (currentTarget != null){
90                        JFCGUIElementSpec currentSpec = (JFCGUIElementSpec) currentTarget.getSpecification();
91                        guiElementPath.add(0, currentSpec);
92                        currentTarget = (JFCGUIElement) currentTarget.getParent();
93                }
94               
95                String result = new JFCReplayIDCalculator().calculateReplayID(guiElementPath);
96                assertEquals("e3561778462", result);
97        }
98
99        /**
100         * Perform pre-test initialization.
101         *
102         * @throws Exception
103         *         if the initialization fails for some reason
104         *
105         * @generatedBy CodePro at 7/30/12 4:58 PM
106         */
107        @Before
108        public void setUp()
109                throws Exception {
110                // add additional set up code here
111        }
112
113        /**
114         * Perform post-test clean-up.
115         *
116         * @throws Exception
117         *         if the clean-up fails for some reason
118         *
119         * @generatedBy CodePro at 7/30/12 4:58 PM
120         */
121        @After
122        public void tearDown()
123                throws Exception {
124                // Add additional tear down code here
125        }
126
127        /**
128         * Launch the test.
129         *
130         * @param args the command line arguments
131         *
132         * @generatedBy CodePro at 7/30/12 4:58 PM
133         */
134        public static void main(String[] args) {
135                new org.junit.runner.JUnitCore().run(JFCReplayIDCalculatorTest.class);
136        }
137}
138
139/*$CPS$ This comment was generated by CodePro. Do not edit it.
140 * patternId = com.instantiations.assist.eclipse.pattern.testCasePattern
141 * strategyId = com.instantiations.assist.eclipse.pattern.testCasePattern.junitTestCase
142 * additionalTestNames =
143 * assertTrue = false
144 * callTestMethod = true
145 * createMain = false
146 * createSetUp = false
147 * createTearDown = false
148 * createTestFixture = false
149 * createTestStubs = false
150 * methods =
151 * package = de.ugoe.cs.eventbench.efg
152 * package.sourceFolder = EventBenchConsoleTest/src
153 * superclassType = junit.framework.TestCase
154 * testCase = EFGEventIDCalculatorTest
155 * testClassType = de.ugoe.cs.eventbench.efg.EFGEventIDCalculator
156 */
Note: See TracBrowser for help on using the repository browser.