Changeset 1803


Ignore:
Timestamp:
10/22/14 14:25:14 (10 years ago)
Author:
funger
Message:
  • bug fix: format of onClick position adapted to mouseClick
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-plugin-android/src/main/java/de/ugoe/cs/autoquest/plugin/android/AndroidLogParser.java

    r1797 r1803  
    2626import java.util.List; 
    2727import java.util.Map; 
     28import java.util.logging.Level; 
    2829 
    2930import javax.xml.parsers.ParserConfigurationException; 
     
    108109        /** 
    109110         * <p> 
    110          * internal handle to the parsed GUI structure, stored in a GUIElementTree 
     111         * Internal handle to the parsed GUI structure, stored in a GUIElementTree 
    111112         * </p> 
    112113         */ 
     
    115116        /** 
    116117         * <p> 
    117          * internal handle to the specification currently parsed for a GUI element 
     118         * Internal handle to the specification currently parsed for a GUI element 
    118119         * </p> 
    119120         */ 
     
    136137        private List<Event> currentSequence; 
    137138 
    138         /** 
    139          * <p> 
    140          * Internal handle to the event sequence that is currently being parsed. 
    141          * </p> 
    142          */ 
    143         // private List<Event> currentSequence; 
     139         
    144140 
    145141        /** 
     
    159155        private Collection<List<Event>> sequences; 
    160156 
     157        /** 
     158         *  
     159         */ 
     160        private Boolean showSteps = false; 
     161         
    161162        /** 
    162163         * <p> 
     
    288289        public void startElement(String uri, String localName, String qName, 
    289290                        Attributes atts) throws SAXException { 
     291                showSteps("start element: " + qName, true); 
    290292                if (qName.equals("sessions")) { 
    291                          currentSequence = new LinkedList<Event>(); 
     293                        currentSequence = new LinkedList<Event>(); 
    292294                        if (currentGUIElementTree == null) { 
    293295                                currentGUIElementTree = new GUIElementTree<Long>(); 
    294296                        } 
    295                          
     297 
    296298                } 
    297299 
     
    301303                        currentGUIElementSpec.setHashCode((int) currentGUIElementHash 
    302304                                        .longValue()); 
    303                          
     305 
    304306                } else if (qName.equals("event")) { 
    305307                        currentEventId = atts.getValue("id"); 
    306308                        currentEventParameters = new HashMap<String, String>(); 
    307                          
    308309 
    309310                } else if (qName.equals("param")) { 
     
    346347        public void endElement(String uri, String localName, String qName) 
    347348                        throws SAXException { 
    348                  
     349 
     350                showSteps("end element: " + qName, true); 
     351 
    349352                if (qName.equals("sessions")) { 
    350353                        if (currentSequence != null) { 
     
    365368                        currentParentHash = null; 
    366369                } else if (currentEventId != null && qName.equals("event")) { 
    367                          
     370 
    368371                        IGUIElement currentGUIElement; 
    369372                        currentGUIElement = currentGUIElementTree.find(currentEventSource); 
     
    373376                        // onclick event is processed as a mouse click 
    374377                        if (currentGUIElement == null) { 
    375                                  
     378 
    376379                        } 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(); 
    380385                                currentEventTarget.markUsed(); 
    381386                                event.setTimestamp(currentEventTimestamp); 
     
    406411         */ 
    407412        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) { 
    414416                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(".", "")); 
    417425                        MouseButtonInteraction.Button button = null; 
    418426                        button = MouseButtonInteraction.Button.LEFT; 
    419427 
    420428                        return new MouseClick(button, x, y); 
    421                          
     429 
    422430                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; 
    426449        } 
    427450 
Note: See TracChangeset for help on using the changeset viewer.