Changeset 1880


Ignore:
Timestamp:
02/25/15 12:44:56 (9 years ago)
Author:
funger
Message:
  • Add the position of the element in the original GUI.
  • getSimilarity extended (path + title, path + position now compared)
Location:
trunk/autoquest-plugin-android/src/main/java/de/ugoe/cs/autoquest/plugin/android
Files:
2 edited

Legend:

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

    r1870 r1880  
    328328                    currentParentHash = Long.parseLong(atts.getValue("value")); 
    329329                } 
     330                else if ("position".equals(atts.getValue("name"))) { 
     331                    currentGUIElementSpec.setElementPosition(Integer.parseInt(atts.getValue("value"))); 
     332                } 
    330333            } 
    331334            else if (currentEventId != null) { 
  • trunk/autoquest-plugin-android/src/main/java/de/ugoe/cs/autoquest/plugin/android/guimodel/ANDROIDGUIElementSpec.java

    r1869 r1880  
    5353     * <p> 
    5454     * Path to an element in an activity. e.g. a path of a button could look like 
    55      * MainActivity/DecorView/ActionBarOverlayLayout/FrameLayout/ RelativeLayout/Button 
     55     * MainActivity/DecorView/ActionBarOverlayLayout/FrameLayout/RelativeLayout/Button 
    5656     * </p> 
    5757     */ 
     
    8686    /** 
    8787     * <p> 
     88     * The position of the element in the original GUI. 
     89     * </p> 
     90     */ 
     91    private int elementPosition; 
     92 
     93    /** 
     94     * <p> 
    8895     * Type hierarchy of the class itself. 
    8996     * </p> 
    9097     */ 
    9198    private List<String> typeHierarchy = null; 
    92      
     99 
    93100    /* 
    94101     * (non-Javadoc) 
     
    121128         */ 
    122129 
    123         if (otherSpec.index > 1 && index == otherSpec.index) { 
     130        if (otherSpec.getIndex() > 1 && getIndex() == otherSpec.getIndex()) { 
     131            return true; 
     132        } 
     133 
     134        /* 
     135         * Path and label of the elements fits together. In this case it is most likely that this 
     136         * elements fits together. This only makes since in the case a label exists. 
     137         */ 
     138        if (otherSpec.getName() != "NOT_SET" && getName() != "NOT_SET" && 
     139            !otherSpec.getName().contains("image:") && getName().contains("image:") && 
     140            otherSpec.getName() == getName() && otherSpec.getPath() == getPath()) 
     141        { 
     142            return true; 
     143        } 
     144 
     145        /* 
     146         * Path and position fits together. In this case it is most likely that this elements fits 
     147         * together. 
     148         */ 
     149        if (otherSpec.getPath() == getPath() && 
     150            otherSpec.getElementPosition() == getElementPosition()) 
     151        { 
    124152            return true; 
    125153        } 
     
    142170        return false; 
    143171    } 
    144      
    145172 
    146173    /* 
     
    168195            return typeHierarchy.toArray(new String[typeHierarchy.size()]); 
    169196    } 
    170      
     197 
    171198    /** 
    172199     * <p> 
     
    210237     * @return text or image of the GUI element. 
    211238     */ 
    212     public String getName() {         
     239    public String getName() { 
    213240        if (name == null || name.trim().length() == 0) { 
    214241            return "NOT_SET"; 
     
    218245 
    219246    /** 
     247     *  
     248     * <p> 
     249     * Return the position of the element in the original GUI. 
     250     * </p> 
     251     *  
     252     * @return position of the element in the original GUI. 
     253     */ 
     254    public int getElementPosition() { 
     255        return elementPosition; 
     256    } 
     257 
     258    /** 
     259     *  
     260     * <p> 
     261     * Set the position of the element in the original GUI. 
     262     * </p> 
     263     *  
     264     * @param elementPosition 
     265     */ 
     266    public void setElementPosition(int elementPosition) { 
     267        this.elementPosition = elementPosition; 
     268    } 
     269 
     270    /** 
    220271     * <p> 
    221272     * Sets the GUI element identifier. 
     
    282333        this.typeHierarchy = typeHierarchy; 
    283334    } 
    284      
     335 
    285336    /* 
    286337     * (non-Javadoc) 
     
    303354            (path == null ? otherSpec.path == null : path.equals(otherSpec.path)) && 
    304355            (index == otherSpec.index) && 
     356            (elementPosition == otherSpec.elementPosition) && 
    305357            (name == null ? otherSpec.name == null : name.equals(otherSpec.name)) && 
    306358            (type == null ? otherSpec.type == null : type.equals(otherSpec.type)); 
    307359    } 
    308      
     360 
    309361    /* 
    310362     * (non-Javadoc) 
     
    314366    @Override 
    315367    public int hashCode() { 
    316      // 17 due to the reason that this is a prime number. 
     368        // 17 due to the reason that this is a prime number. 
    317369        int result = 17; 
    318370        /* 
     
    324376        result = 31 * result + index; 
    325377        result = 31 * result + getName().hashCode(); 
    326         result = 31 * result + type.hashCode();      
     378        result = 31 * result + type.hashCode(); 
     379        result = 31 * result + elementPosition; 
    327380        return result; 
    328381    } 
    329      
    330382 
    331383} 
Note: See TracChangeset for help on using the changeset viewer.