Changeset 1061


Ignore:
Timestamp:
02/12/13 16:05:41 (12 years ago)
Author:
pharms
Message:
  • improved event task comparison to ignore coordinates for clicks on GUI elements like buttons, were the coordinates are unimportant
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/GUIEventTaskComparisonRule.java

    r1057 r1061  
    11package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
    22 
     3import de.ugoe.cs.autoquest.eventcore.IEventTarget; 
    34import de.ugoe.cs.autoquest.eventcore.gui.IInteraction; 
    45import de.ugoe.cs.autoquest.eventcore.gui.MouseClick; 
     
    78import de.ugoe.cs.autoquest.eventcore.gui.TextInput; 
    89import de.ugoe.cs.autoquest.eventcore.gui.ValueSelection; 
     10import de.ugoe.cs.autoquest.eventcore.guimodel.IButton; 
     11import de.ugoe.cs.autoquest.eventcore.guimodel.ICheckBox; 
     12import de.ugoe.cs.autoquest.eventcore.guimodel.IComboBox; 
     13import de.ugoe.cs.autoquest.eventcore.guimodel.IImage; 
     14import de.ugoe.cs.autoquest.eventcore.guimodel.IListBox; 
     15import de.ugoe.cs.autoquest.eventcore.guimodel.IMenuButton; 
     16import de.ugoe.cs.autoquest.eventcore.guimodel.IRadioButton; 
     17import de.ugoe.cs.autoquest.eventcore.guimodel.IShape; 
     18import de.ugoe.cs.autoquest.eventcore.guimodel.IText; 
     19import de.ugoe.cs.autoquest.eventcore.guimodel.IToolTip; 
    920import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 
    1021import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     
    5768        IInteraction interaction2 = (IInteraction) task2.getEventType(); 
    5869         
    59         return compareInteractions(interaction1, interaction2); 
    60     } 
    61  
    62     /** 
    63      * <p> 
    64      * compares two interactions. The method delegates two 
     70        return compareInteractions(interaction1, interaction2, task1.getEventTarget()); 
     71    } 
     72 
     73    /** 
     74     * <p> 
     75     * compares two interactions. The method delegates to other, more specific compare method, e.g., 
    6576     * {@link #compareTextInputs(TextInput, TextInput)} and 
    66      * {@link #compareValueSelections(ValueSelection, ValueSelection)} for text inputs and value 
    67      * selections. Otherwise it uses the equal method of the interactions for comparison. In this 
    68      * case, if the interactions equal method returns true, this method returns lexical equality. 
     77     * {@link #compareValueSelections(ValueSelection, ValueSelection)}, if any exist for the 
     78     * concrete interaction types. Otherwise it uses the equals method of the interactions for 
     79     * comparison. In this case, if the interactions equals method returns true, this method 
     80     * returns lexical equality. 
    6981     * </p> 
    7082     * 
    7183     * @param interaction1 the first interaction to compare 
    7284     * @param interaction2 the second interaction to compare 
    73      *  
    74      * @return as described 
    75      */ 
    76     private NodeEquality compareInteractions(IInteraction interaction1, IInteraction interaction2) { 
     85     * @param eventTarget  the event target on which the interactions happened (used within 
     86     *                     special comparisons like mouse clicks on buttons, where the coordinates 
     87     *                     can be ignored) 
     88     *  
     89     * @return as described 
     90     */ 
     91    private NodeEquality compareInteractions(IInteraction interaction1, 
     92                                             IInteraction interaction2, 
     93                                             IEventTarget eventTarget) 
     94    { 
    7795        if (interaction1 == interaction2) { 
    7896            return NodeEquality.LEXICALLY_EQUAL; 
     
    90108                 (interaction2 instanceof MouseClick)) 
    91109        { 
    92             return compareMouseClicks((MouseClick) interaction1, (MouseClick) interaction2); 
     110            return compareMouseClicks 
     111                ((MouseClick) interaction1, (MouseClick) interaction2, eventTarget); 
    93112        } 
    94113        else if ((interaction1 instanceof MouseDoubleClick) && 
     
    96115        { 
    97116            return compareMouseDoubleClicks 
    98                 ((MouseDoubleClick) interaction1, (MouseDoubleClick) interaction2); 
     117                ((MouseDoubleClick) interaction1, (MouseDoubleClick) interaction2, eventTarget); 
    99118        } 
    100119        else if ((interaction1 instanceof MouseDragAndDrop) && 
     
    168187     * <p> 
    169188     * compares two mouse clicks. If both clicks have the same coordinates, they are lexically 
    170      * equal. Otherwise, they are semantically equal. 
     189     * equal. Otherwise, they are semantically equal. Mouse clicks for which the coordinates make 
     190     * no lexical difference (see {@link #clickCoordinatesMakeLexicalDifference(IEventTarget)}) 
     191     * are treated as lexically equal. 
    171192     * </p> 
    172193     * 
    173194     * @param interaction1 the first mouse click to compare 
    174195     * @param interaction2 the second mouse click to compare 
    175      *  
    176      * @return as described 
    177      */ 
    178     private NodeEquality compareMouseClicks(MouseClick interaction1, 
    179                                             MouseClick interaction2) 
     196     * @param eventTarget  the event target on which the interactions happened (used within 
     197     *                     special comparisons like mouse clicks on buttons, where the coordinates 
     198     *                     can be ignored) 
     199     *  
     200     * @return as described 
     201     */ 
     202    private NodeEquality compareMouseClicks(MouseClick   interaction1, 
     203                                            MouseClick   interaction2, 
     204                                            IEventTarget eventTarget) 
    180205    { 
    181206        if (interaction1.getButton() != interaction2.getButton()) { 
    182207            return NodeEquality.UNEQUAL; 
     208        } 
     209         
     210        if (!clickCoordinatesMakeLexicalDifference(eventTarget)) { 
     211            return NodeEquality.LEXICALLY_EQUAL; 
    183212        } 
    184213         
     
    199228     * <p> 
    200229     * compares two mouse double clicks. If both double clicks have the same coordinates, they are 
    201      * lexically equal. Otherwise, they are semantically equal. 
     230     * lexically equal. Otherwise, they are semantically equal. Double clicks for which the 
     231     * coordinates make no lexical difference 
     232     * (see {@link #clickCoordinatesMakeLexicalDifference(IEventTarget)}) are treated as lexically 
     233     * equal. 
    202234     * </p> 
    203235     * 
    204236     * @param interaction1 the first mouse double click to compare 
    205237     * @param interaction2 the second mouse double click to compare 
     238     * @param eventTarget  the event target on which the interactions happened (used within 
     239     *                     special comparisons like mouse clicks on buttons, where the coordinates 
     240     *                     can be ignored) 
    206241     *  
    207242     * @return as described 
    208243     */ 
    209244    private NodeEquality compareMouseDoubleClicks(MouseDoubleClick interaction1, 
    210                                                   MouseDoubleClick interaction2) 
     245                                                  MouseDoubleClick interaction2, 
     246                                                  IEventTarget     eventTarget) 
    211247    { 
    212248        if (interaction1.getButton() != interaction2.getButton()) { 
    213249            return NodeEquality.UNEQUAL; 
     250        } 
     251         
     252        if (!clickCoordinatesMakeLexicalDifference(eventTarget)) { 
     253            return NodeEquality.LEXICALLY_EQUAL; 
    214254        } 
    215255         
     
    262302    } 
    263303 
     304    /** 
     305     * <p> 
     306     * Checks, if the coordinates of a click or double click on the provided event target makes 
     307     * a lexical difference. Mouse clicks and double clicks on buttons, check boxes, 
     308     * combo boxes, images, list boxes, menu buttons, radio buttons, shapes, uneditable text, 
     309     * and tool tips have no lexical difference as long as they happen on the same event target. 
     310     * The concrete coordinates are not relevant. 
     311     * </p> 
     312     * 
     313     * @param eventTarget the event target on which the interaction occurred 
     314     *  
     315     * @return if the coordinates are important to be considered for clicks and double clicks, 
     316     *         false else 
     317     */ 
     318    private boolean clickCoordinatesMakeLexicalDifference(IEventTarget eventTarget) { 
     319        if ((eventTarget instanceof IButton) || 
     320            (eventTarget instanceof ICheckBox) || 
     321            (eventTarget instanceof IComboBox) || 
     322            (eventTarget instanceof IImage) || 
     323            (eventTarget instanceof IListBox) || 
     324            (eventTarget instanceof IMenuButton) || 
     325            (eventTarget instanceof IRadioButton) || 
     326            (eventTarget instanceof IShape) || 
     327            (eventTarget instanceof IText) || 
     328            (eventTarget instanceof IToolTip)) 
     329        { 
     330            return false; 
     331        } 
     332        else { 
     333            return true; 
     334        } 
     335    } 
     336 
    264337} 
Note: See TracChangeset for help on using the changeset viewer.