Changeset 1803 for trunk/autoquest-plugin-android
- Timestamp:
- 10/22/14 14:25:14 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-plugin-android/src/main/java/de/ugoe/cs/autoquest/plugin/android/AndroidLogParser.java
r1797 r1803 26 26 import java.util.List; 27 27 import java.util.Map; 28 import java.util.logging.Level; 28 29 29 30 import javax.xml.parsers.ParserConfigurationException; … … 108 109 /** 109 110 * <p> 110 * internal handle to the parsed GUI structure, stored in a GUIElementTree111 * Internal handle to the parsed GUI structure, stored in a GUIElementTree 111 112 * </p> 112 113 */ … … 115 116 /** 116 117 * <p> 117 * internal handle to the specification currently parsed for a GUI element118 * Internal handle to the specification currently parsed for a GUI element 118 119 * </p> 119 120 */ … … 136 137 private List<Event> currentSequence; 137 138 138 /** 139 * <p> 140 * Internal handle to the event sequence that is currently being parsed. 141 * </p> 142 */ 143 // private List<Event> currentSequence; 139 144 140 145 141 /** … … 159 155 private Collection<List<Event>> sequences; 160 156 157 /** 158 * 159 */ 160 private Boolean showSteps = false; 161 161 162 /** 162 163 * <p> … … 288 289 public void startElement(String uri, String localName, String qName, 289 290 Attributes atts) throws SAXException { 291 showSteps("start element: " + qName, true); 290 292 if (qName.equals("sessions")) { 291 293 currentSequence = new LinkedList<Event>(); 292 294 if (currentGUIElementTree == null) { 293 295 currentGUIElementTree = new GUIElementTree<Long>(); 294 296 } 295 297 296 298 } 297 299 … … 301 303 currentGUIElementSpec.setHashCode((int) currentGUIElementHash 302 304 .longValue()); 303 305 304 306 } else if (qName.equals("event")) { 305 307 currentEventId = atts.getValue("id"); 306 308 currentEventParameters = new HashMap<String, String>(); 307 308 309 309 310 } else if (qName.equals("param")) { … … 346 347 public void endElement(String uri, String localName, String qName) 347 348 throws SAXException { 348 349 350 showSteps("end element: " + qName, true); 351 349 352 if (qName.equals("sessions")) { 350 353 if (currentSequence != null) { … … 365 368 currentParentHash = null; 366 369 } else if (currentEventId != null && qName.equals("event")) { 367 370 368 371 IGUIElement currentGUIElement; 369 372 currentGUIElement = currentGUIElementTree.find(currentEventSource); … … 373 376 // onclick event is processed as a mouse click 374 377 if (currentGUIElement == null) { 375 378 376 379 } else { 377 378 event = new Event(instantiateInteraction(currentEventId, currentEventParameters), currentGUIElement); 379 ANDROIDGUIElement currentEventTarget = (ANDROIDGUIElement) event.getTarget(); 380 381 event = new Event(instantiateInteraction(currentEventId, 382 currentEventParameters), currentGUIElement); 383 ANDROIDGUIElement currentEventTarget = (ANDROIDGUIElement) event 384 .getTarget(); 380 385 currentEventTarget.markUsed(); 381 386 event.setTimestamp(currentEventTimestamp); … … 406 411 */ 407 412 private IInteraction instantiateInteraction(String event, 408 Map<String, String> eventParameters) 409 throws SAXException 410 { 411 412 switch(event) 413 { 413 Map<String, String> eventParameters) throws SAXException { 414 415 switch (event) { 414 416 case "onClick": 415 int x = Integer.parseInt(currentEventParameters.get("X")); 416 int y = Integer.parseInt(currentEventParameters.get("Y")); 417 /* 418 * due to the reason that android uses float instead of integer it 419 * is necessary to parse the float values to integer values 420 * this is simply done by removing the dot 421 */ 422 423 int x = Integer.parseInt(currentEventParameters.get("X").replace(".", "")); 424 int y = Integer.parseInt(currentEventParameters.get("Y").replace(".", "")); 417 425 MouseButtonInteraction.Button button = null; 418 426 button = MouseButtonInteraction.Button.LEFT; 419 427 420 428 return new MouseClick(button, x, y); 421 429 422 430 default: 423 throw new SAXException("unhandled event id " + event); 424 } 425 431 throw new SAXException("unhandled event id " + event); 432 } 433 434 } 435 436 private void showSteps(String message, Boolean ln) { 437 if (showSteps) { 438 if (ln) { 439 Console.traceln(Level.INFO, message); 440 } else { 441 Console.trace(Level.INFO, message); 442 } 443 444 } 445 } 446 447 public void setShowSteps(Boolean showSteps) { 448 this.showSteps = showSteps; 426 449 } 427 450
Note: See TracChangeset
for help on using the changeset viewer.