Changeset 1882


Ignore:
Timestamp:
02/25/15 12:53:12 (9 years ago)
Author:
funger
Message:
  • Monitor the position of the element in the original GUI.
Location:
trunk/autoquest-androidmonitor/src/main/java/de/ugoe/cs/autoquest/androidmonitor
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-androidmonitor/src/main/java/de/ugoe/cs/autoquest/androidmonitor/AndroidMonitor.java

    r1871 r1882  
    5454 
    5555    /** 
     56     * <p> 
     57     * Represents the position of the current view element in the tree structure of an activity. 
     58     * </p> 
     59     */ 
     60    private int elementPosition = 0; 
     61 
     62    /** 
    5663     * Constructor method to get a monitor object. 
    5764     *  
     
    118125     */ 
    119126    private View findFirstView(View view) { 
     127        elementPosition = 0; 
    120128        if (view.getParent() != null && (view.getParent() instanceof ViewGroup)) { 
    121129            return findFirstView((View) view.getParent()); 
     
    149157 
    150158        if (!AndroidMonitorLogFile.isComponentLogged(view.hashCode())) { 
    151             AndroidMonitor.logFile.addComponent(view, parentHash, activityName); 
    152  
    153             Log.i("object type", ""); 
     159            AndroidMonitor.logFile.addComponent(view, parentHash, activityName, getElementPosition()); 
     160 
     161            // Log.i("object type", ""); 
    154162 
    155163            // save original listener to add it later on to the groupLisatener 
     
    167175                groupListener.addOnClickListener(new View.OnClickListener() { 
    168176                    public void onClick(View v) { 
    169  
    170177                        AndroidMonitor.logFile.addEvent(v, "onClick"); 
    171178                        // check if something changed in the activity 
     
    202209        parentHash = view.hashCode(); 
    203210        // traverse all views of the activity 
    204         if (view instanceof ViewGroup) { 
     211        if (view instanceof ViewGroup) {             
    205212            ViewGroup group = (ViewGroup) view; 
    206             for (int i = 0; i < group.getChildCount(); i++) { 
     213            for (int i = 0; i < group.getChildCount(); i++) {                 
    207214                View child = group.getChildAt(i); 
    208215                addLogListenerToView(child, parentHash); 
     
    299306        return logFile; 
    300307    } 
     308     
     309    private int getElementPosition(){ 
     310        int element = elementPosition; 
     311        elementPosition ++; 
     312        return element; 
     313    } 
    301314} 
  • trunk/autoquest-androidmonitor/src/main/java/de/ugoe/cs/autoquest/androidmonitor/AndroidMonitorLogFile.java

    r1871 r1882  
    260260     *            name of the activity that is analyzed 
    261261     */ 
    262     public void addComponent(View view, int parentHash, String activityName) { 
     262    public void addComponent(View view, int parentHash, String activityName, int position) { 
    263263        XmlSerializer serializer = Xml.newSerializer(); 
    264264        StringWriter writer = new StringWriter(); 
     
    290290            serializer.attribute("", "value", "" + view.getId()); 
    291291            serializer.endTag("", "param"); 
     292             
     293            serializer.startTag("", "param"); 
     294            serializer.attribute("", "name", "position"); 
     295            serializer.attribute("", "value", "" + position); 
     296            serializer.endTag("", "param"); 
    292297 
    293298            if (view instanceof TextView) { 
Note: See TracChangeset for help on using the changeset viewer.