Changeset 806 for trunk/quest-plugin-jfc-test/src/test
- Timestamp:
- 09/10/12 20:52:49 (12 years ago)
- Location:
- trunk/quest-plugin-jfc-test/src/test
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-plugin-jfc-test/src/test/java/de/ugoe/cs/quest/plugin/jfc/JFCReplayIDCalculatorTest.java
r797 r806 26 26 import de.ugoe.cs.quest.plugin.jfc.guimodel.JFCGUIElement; 27 27 import de.ugoe.cs.quest.plugin.jfc.guimodel.JFCGUIElementSpec; 28 import de.ugoe.cs.quest.plugin.mfc.eventcore.MFCEventType; 29 import de.ugoe.cs.quest.plugin.mfc.guimodel.MFCToolBar; 28 30 import de.ugoe.cs.util.console.TextConsole; 29 31 … … 34 36 * @pattern JUnit Test Case 35 37 * 36 * @generatedBy CodePro at 7/30/12 4:50 PM37 *38 38 * @author fabian.glaser 39 39 * … … 41 41 */ 42 42 public class JFCReplayIDCalculatorTest extends TestCase { 43 44 Set<String> knownIDs = new HashSet<String>(); 43 45 44 46 /** … … 107 109 108 110 /** 109 * Run the String calculateReplayID(List<JFCGUIElementSpec>) method test. 111 * Method to test if calculated IDs are included in guitar efg file. 112 * If not more than 75 % can be matched, test fails. 110 113 * 111 114 * @throws Exception … … 115 118 throws Exception { 116 119 // generate list of known replayIDs from guitar efg file 117 File guiFile = new File(ClassLoader.getSystemResource("freemind.efg").getFile()); 118 119 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 120 DocumentBuilder builder = factory.newDocumentBuilder(); 121 Document freemindGUI = builder.parse(guiFile); 122 123 Node currentNode = freemindGUI.getFirstChild().getFirstChild(); 124 NodeList eventNodes = null; 125 List<String> knownIDs = new ArrayList<String>(); 126 127 while ((currentNode = currentNode.getNextSibling()) != null){ 128 if (currentNode.getNodeName().equals("Events")) 129 eventNodes = currentNode.getChildNodes(); 130 } 131 132 for (int i = 0; i < eventNodes.getLength(); i++){ 133 if (eventNodes.item(i).getNodeName().equals("Event")){ 134 NodeList attributes = eventNodes.item(i).getChildNodes(); 135 for (int j = 0; j < attributes.getLength(); j++){ 136 if (attributes.item(j).getNodeName().equals("EventId")){ 137 knownIDs.add(attributes.item(j).getTextContent()); 138 } 139 } 140 } 141 } 120 File guiFile = new File(ClassLoader.getSystemResource("freemind.xml").getFile()); 121 JFCReplayIDValidator validator = new JFCReplayIDValidator(guiFile); 142 122 143 123 // calculate replayIDs from trace file … … 145 125 ignoredEvents.add(JFCEventId.FOCUS_GAINED); 146 126 JFCLogParser parser = new JFCLogParser(ignoredEvents); 147 parser.parseFile(new File(ClassLoader.getSystemResource("freemind_trace 2.xml").getFile()));148 JFCReplayIDCalculator calculator = new JFCReplayIDCalculator( );127 parser.parseFile(new File(ClassLoader.getSystemResource("freemind_trace3.xml").getFile())); 128 JFCReplayIDCalculator calculator = new JFCReplayIDCalculator(validator); 149 129 150 130 Set<String> generatedIDs = new HashSet<String>(); … … 153 133 154 134 assertTrue(sequences.size() > 0); 155 156 135 157 136 for (List<Event> currentSequence: sequences){ … … 160 139 generatedIDs.add(replayID); 161 140 System.out.println("Generated ID: " + replayID); 141 System.out.println(); 162 142 } 163 143 } … … 168 148 int known = 0; 169 149 for (String replayID: generatedIDs){ 170 if ( knownIDs.contains(replayID)){150 if (validator.validateReplayID("w" + replayID.substring(1))){ 171 151 System.out.println(replayID + "\t is known."); 172 152 known++; … … 180 160 System.out.println(percentage + "% of the generated IDs are known."); 181 161 182 assertTrue(percentage > 75); 183 184 162 assertTrue(percentage > 75); 163 } 164 165 166 /** 167 * Method to test if calculateReplayID throws the right exception when 168 * it is called with a target of the wrong type. 169 */ 170 @Test 171 public void testCalculateReplayIDIllegalArgumentException(){ 172 try{ 173 JFCReplayIDCalculator calculator = new JFCReplayIDCalculator(); 174 Event event = new Event(new MFCEventType(null), new MFCToolBar(null, null)); 175 176 calculator.calculateReplayID(event); 177 178 fail("Expected IllegalArgumentException!"); 179 } 180 catch(IllegalArgumentException e){ 181 System.out.println("Expected exception thrown."); 182 } 185 183 } 186 184 -
trunk/quest-plugin-jfc-test/src/test/resources/freemind.efg
r797 r806 219 219 </Event> 220 220 <Event> 221 <EventId>e2 659174690</EventId>222 <WidgetId>w2 659174690</WidgetId>221 <EventId>e2480964382</EventId> 222 <WidgetId>w2480964382</WidgetId> 223 223 <Type>EXPAND</Type> 224 224 <Initial>true</Initial> … … 226 226 </Event> 227 227 <Event> 228 <EventId>e2 261466076</EventId>229 <WidgetId>w2 261466076</WidgetId>228 <EventId>e2606563300</EventId> 229 <WidgetId>w2606563300</WidgetId> 230 230 <Type>EXPAND</Type> 231 231 <Initial>true</Initial> … … 233 233 </Event> 234 234 <Event> 235 <EventId>e3 680670666</EventId>236 <WidgetId>w3 680670666</WidgetId>235 <EventId>e3483508982</EventId> 236 <WidgetId>w3483508982</WidgetId> 237 237 <Type>EXPAND</Type> 238 238 <Initial>true</Initial> … … 240 240 </Event> 241 241 <Event> 242 <EventId>e 3601696666</EventId>243 <WidgetId>w 3601696666</WidgetId>242 <EventId>e2108271642</EventId> 243 <WidgetId>w2108271642</WidgetId> 244 244 <Type>SYSTEM INTERACTION</Type> 245 245 <Initial>true</Initial> … … 279 279 </Event> 280 280 <Event> 281 <EventId>e 2693670138</EventId>282 <WidgetId>w 2693670138</WidgetId>281 <EventId>e3513163942</EventId> 282 <WidgetId>w3513163942</WidgetId> 283 283 <Type>EXPAND</Type> 284 284 <Initial>true</Initial> … … 877 877 </Event> 878 878 <Event> 879 <EventId>e1 027743708</EventId>880 <WidgetId>w1 027743708</WidgetId>879 <EventId>e1152438296</EventId> 880 <WidgetId>w1152438296</WidgetId> 881 881 <Type>EXPAND</Type> 882 882 <Initial>true</Initial> … … 3110 3110 </Event> 3111 3111 <Event> 3112 <EventId>e 3653656934</EventId>3113 <WidgetId>w 3653656934</WidgetId>3112 <EventId>e881280722</EventId> 3113 <WidgetId>w881280722</WidgetId> 3114 3114 <Type>TERMINAL</Type> 3115 3115 <Initial>false</Initial> … … 3118 3118 </Event> 3119 3119 <Event> 3120 <EventId>e 4199161516</EventId>3121 <WidgetId>w 4199161516</WidgetId>3120 <EventId>e1426785304</EventId> 3121 <WidgetId>w1426785304</WidgetId> 3122 3122 <Type>TERMINAL</Type> 3123 3123 <Initial>false</Initial>
Note: See TracChangeset
for help on using the changeset viewer.