Changeset 1490


Ignore:
Timestamp:
04/07/14 08:42:08 (10 years ago)
Author:
pharms
Message:
  • added support and initial implementation of a platform specific distance measure between GUI elements
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-events-test/src/test/java/de/ugoe/cs/autoquest/eventcore/guimodel/AbstractDefaultGUIElementTest.java

    r1436 r1490  
    112112 
    113113        /* (non-Javadoc) 
    114          * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#updateSpecification(de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec) 
     114         * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#updateSpecification(IGUIElementSpec) 
    115115         */ 
    116116        @Override 
     
    124124        } 
    125125 
     126        /* (non-Javadoc) 
     127         * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement) 
     128         */ 
     129        @Override 
     130        public double getDistanceTo(IGUIElement otherElement) { 
     131            if (this == otherElement) { 
     132                return 0.0; 
     133            } 
     134            else { 
     135                return 1.0; 
     136            } 
     137        } 
     138 
    126139    } 
    127140 
  • trunk/autoquest-core-events-test/src/test/java/de/ugoe/cs/autoquest/eventcore/guimodel/GUIModelTest.java

    r1386 r1490  
    11091109        } 
    11101110 
     1111        /* (non-Javadoc) 
     1112         * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement) 
     1113         */ 
     1114        @Override 
     1115        public double getDistanceTo(IGUIElement otherElement) { 
     1116            if (this == otherElement) { 
     1117                return 0.0; 
     1118            } 
     1119            else { 
     1120                return 1.0; 
     1121            } 
     1122        } 
     1123 
    11111124    } 
    11121125 
  • trunk/autoquest-core-events-test/src/test/java/de/ugoe/cs/autoquest/eventcore/guimodel/MockGUIElement.java

    r1433 r1490  
    6161 
    6262    @Override 
     63    public double getDistanceTo(IGUIElement otherElement) { 
     64        return 0.0; 
     65    } 
     66 
     67    @Override 
    6368    public boolean isUsed() { 
    6469        return false; 
  • trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/guimodel/GUIElementGroup.java

    r1433 r1490  
    8787    public String toString() { 
    8888        return getStringIdentifier(); 
     89    } 
     90 
     91    /* (non-Javadoc) 
     92     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement) 
     93     */ 
     94    @Override 
     95    public double getDistanceTo(IGUIElement otherElement) { 
     96        if (equals(otherElement)) { 
     97            return 0.0; 
     98        } 
     99        else if (super.getParent() != null) { 
     100            return super.getParent().getDistanceTo(otherElement); 
     101        } 
     102        else { 
     103            return 1.0; 
     104        } 
    89105    } 
    90106 
  • trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/guimodel/IGUIElement.java

    r1433 r1490  
    109109     */ 
    110110    public void addEqualGUIElement(IGUIElement equalElement); 
     111 
     112    /** 
     113     * <p> 
     114     * Returns a measure for the distance of this {@link IGUIElement} to the provided one. Distance 
     115     * means a measure for the distance in display of the rendered GUI. The returned values must be 
     116     * between 0.0 and 1.0 inclusive. 0.0 means no distance, e.g., if the distance to itself shall be 
     117     * returned. 1.0 means the highest distance possible. Two GUI elements that are not visible 
     118     * at the same time independent of the screen resolution (e.g., because they resist in separate 
     119     * views) must have a distance of at least 0.5.   
     120     * </p> 
     121     *  
     122     * @param guiElement 
     123     *            the GUI element to measure the distance for 
     124     */ 
     125    public double getDistanceTo(IGUIElement otherElement); 
    111126} 
  • trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLDocument.java

    r1276 r1490  
    1616 
    1717import de.ugoe.cs.autoquest.eventcore.guimodel.IDialog; 
     18import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement; 
    1819 
    1920/** 
     
    6970    } 
    7071 
     72    /* (non-Javadoc) 
     73     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement) 
     74     */ 
     75    @Override 
     76    public double getDistanceTo(IGUIElement otherElement) { 
     77        if (otherElement instanceof HTMLServer) { 
     78            // use the implementation provided by the server 
     79            return otherElement.getDistanceTo(this); 
     80        } 
     81        else if (otherElement instanceof HTMLDocument) { 
     82            if (this.getSpecification().getSimilarity(otherElement.getSpecification())) { 
     83                return DISTANCE_NONE; 
     84            } 
     85            else { 
     86                // use the implementation provided by the server to check if the document resists 
     87                // at least on the same server 
     88                return getServer().getDistanceTo(otherElement); 
     89            } 
     90        } 
     91        else if (otherElement instanceof HTMLPageElement) { 
     92            HTMLDocumentSpec documentSpec = 
     93                ((HTMLPageElementSpec) otherElement.getSpecification()).getPage(); 
     94             
     95            if (this.getSpecification().getSimilarity(documentSpec)) { 
     96                return DISTANCE_SAME_DOCUMENT; 
     97            } 
     98            else { 
     99                // use the implementation provided by the server to check if the document resists 
     100                // at least on the same server 
     101                return getServer().getDistanceTo(otherElement); 
     102            } 
     103        } 
     104         
     105        return DISTANCE_DISTINCT_SERVER; 
     106    } 
     107 
    71108    /** 
    72109     * <p> 
  • trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLGUIElement.java

    r1264 r1490  
    2626 * @author Patrick Harms 
    2727 */ 
    28 public class HTMLGUIElement extends AbstractDefaultGUIElement { 
     28public abstract class HTMLGUIElement extends AbstractDefaultGUIElement { 
    2929 
    3030    /** 
     
    3434     */ 
    3535    private static final long serialVersionUID = 1L; 
     36     
     37    /** 
     38     * <p> 
     39     * the default distance value for different servers 
     40     * </p> 
     41     */ 
     42    protected static final double DISTANCE_DISTINCT_SERVER = 1.0; 
     43 
     44    /** 
     45     * <p> 
     46     * the default distance value for same server but different documents 
     47     * </p> 
     48     */ 
     49    protected static final double DISTANCE_SAME_SERVER = 0.75; 
     50 
     51    /** 
     52     * <p> 
     53     * the default distance value for same document but different page elements 
     54     * </p> 
     55     */ 
     56    protected static final double DISTANCE_SAME_DOCUMENT = 0.5; 
     57 
     58    /** 
     59     * <p> 
     60     * the default distance value for same parent div but different page elements  
     61     * </p> 
     62     */ 
     63    protected static final double DISTANCE_SAME_DIV = 0.2; 
     64 
     65    /** 
     66     * <p> 
     67     * the default distance value for identical elements 
     68     * </p> 
     69     */ 
     70    protected static final double DISTANCE_NONE = 0.0; 
    3671 
    3772    /** 
  • trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLPageElement.java

    r1276 r1490  
    1414 
    1515package de.ugoe.cs.autoquest.plugin.html.guimodel; 
     16 
     17import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement; 
    1618 
    1719/** 
     
    7880    } 
    7981 
     82    /* (non-Javadoc) 
     83     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement) 
     84     */ 
     85    @Override 
     86    public double getDistanceTo(IGUIElement otherElement) { 
     87        if ((otherElement instanceof HTMLServer) || (otherElement instanceof HTMLDocument)) { 
     88            // use the implementation provided by the server or document 
     89            return otherElement.getDistanceTo(this); 
     90        } 
     91        else if (otherElement instanceof HTMLPageElement) { 
     92            if (this == otherElement) { 
     93                return DISTANCE_NONE; 
     94            } 
     95             
     96            HTMLDocumentSpec documentSpec1 = 
     97                ((HTMLPageElementSpec) this.getSpecification()).getPage(); 
     98            HTMLDocumentSpec documentSpec2 = 
     99                ((HTMLPageElementSpec) otherElement.getSpecification()).getPage(); 
     100             
     101            if (!documentSpec1.getSimilarity(documentSpec2)) { 
     102                if (!documentSpec1.getServer().getSimilarity(documentSpec2.getServer())) { 
     103                    return DISTANCE_DISTINCT_SERVER; 
     104                } 
     105                else { 
     106                    return DISTANCE_SAME_SERVER; 
     107                } 
     108            } 
     109            else { 
     110                // check if they have the same parent div element. If so, they are very close. 
     111                // If not, they may be structured completely differently 
     112                IGUIElement parentDiv1 = this; 
     113                 
     114                while (parentDiv1 != null) { 
     115                    if ((parentDiv1 instanceof HTMLPageElement) && 
     116                        ("div".equals(((HTMLPageElement) parentDiv1).getTagName()))) 
     117                    { 
     118                        break; 
     119                    } 
     120                    else { 
     121                        parentDiv1 = parentDiv1.getParent(); 
     122                    } 
     123                } 
     124                 
     125                IGUIElement parentDiv2 = (HTMLPageElement) otherElement; 
     126                 
     127                while (parentDiv2 != null) { 
     128                    if ((parentDiv2 instanceof HTMLPageElement) && 
     129                        ("div".equals(((HTMLPageElement) parentDiv2).getTagName()))) 
     130                    { 
     131                        break; 
     132                    } 
     133                    else { 
     134                        parentDiv2 = parentDiv2.getParent(); 
     135                    } 
     136                } 
     137                 
     138                // a check for the identity of the objects is sufficient. That they resist on the 
     139                // same document was checked beforehand. So even a condense of the GUI model should 
     140                // not cause an invalid result here. 
     141                if ((parentDiv1 == parentDiv2) || 
     142                    ((parentDiv1 != null) && (parentDiv1.equals(parentDiv2)))) 
     143                { 
     144                    return DISTANCE_SAME_DIV; 
     145                } 
     146                else { 
     147                    return DISTANCE_SAME_DOCUMENT; 
     148                } 
     149            } 
     150        } 
     151         
     152        return DISTANCE_DISTINCT_SERVER; 
     153    } 
     154     
    80155    /* 
    81156     * (non-Javadoc) 
  • trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLServer.java

    r1276 r1490  
    1616 
    1717import de.ugoe.cs.autoquest.eventcore.guimodel.IFrame; 
     18import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement; 
    1819 
    1920/** 
     
    8687    } 
    8788 
     89    /* (non-Javadoc) 
     90     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement) 
     91     */ 
     92    @Override 
     93    public double getDistanceTo(IGUIElement otherElement) { 
     94        if (otherElement instanceof HTMLServer) { 
     95            if (this.equals(otherElement)) { 
     96                return DISTANCE_NONE; 
     97            } 
     98            else { 
     99                return DISTANCE_DISTINCT_SERVER; 
     100            } 
     101        } 
     102        else if (otherElement instanceof HTMLDocument) { 
     103            if (this.equals(((HTMLDocument) otherElement).getServer())) { 
     104                return DISTANCE_SAME_SERVER; 
     105            } 
     106            else { 
     107                return DISTANCE_DISTINCT_SERVER; 
     108            } 
     109        } 
     110        else if (otherElement instanceof HTMLPageElement) { 
     111            HTMLServerSpec serverSpec = 
     112                ((HTMLPageElementSpec) otherElement.getSpecification()).getPage().getServer(); 
     113             
     114            if (this.getSpecification().getSimilarity(serverSpec)) { 
     115                return DISTANCE_SAME_SERVER; 
     116            } 
     117            else { 
     118                return DISTANCE_DISTINCT_SERVER; 
     119            } 
     120        } 
     121         
     122        return DISTANCE_DISTINCT_SERVER; 
     123    } 
     124 
    88125} 
  • trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCGUIElement.java

    r994 r1490  
    1616 
    1717import de.ugoe.cs.autoquest.eventcore.guimodel.AbstractDefaultGUIElement; 
     18import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement; 
    1819import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec; 
    1920 
     
    164165    } 
    165166 
     167    /* (non-Javadoc) 
     168     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement) 
     169     */ 
     170    @Override 
     171    public double getDistanceTo(IGUIElement otherElement) { 
     172        throw new UnsupportedOperationException("not implemented yet"); 
     173    } 
     174 
    166175    /** 
    167176     * <p> 
  • trunk/autoquest-plugin-mfc/src/main/java/de/ugoe/cs/autoquest/plugin/mfc/guimodel/MFCGUIElement.java

    r994 r1490  
    1616 
    1717import de.ugoe.cs.autoquest.eventcore.guimodel.AbstractDefaultGUIElement; 
     18import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement; 
    1819import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec; 
    1920 
     
    151152    } 
    152153 
     154    /* (non-Javadoc) 
     155     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement) 
     156     */ 
     157    @Override 
     158    public double getDistanceTo(IGUIElement otherElement) { 
     159        throw new UnsupportedOperationException("not implemented yet"); 
     160    } 
     161 
    153162    /** 
    154163     * <p> 
  • trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/test/DummyGUIElement.java

    r927 r1490  
    9292    } 
    9393 
     94 
     95    /* (non-Javadoc) 
     96     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement) 
     97     */ 
     98    @Override 
     99    public double getDistanceTo(IGUIElement otherElement) { 
     100        if (this == otherElement) { 
     101            return 0.0; 
     102        } 
     103        else { 
     104            return 1.0; 
     105        } 
     106    } 
    94107} 
Note: See TracChangeset for help on using the changeset viewer.