Ignore:
Timestamp:
01/24/13 18:20:26 (12 years ago)
Author:
pharms
Message:
  • added detection of double clicks
File:
1 edited

Legend:

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

    r995 r1042  
    161161 
    162162        simulateEvent(new MouseButtonDown(leftBtn, 0, 0), element1); 
    163         simulateEvent(new MouseButtonUp(leftBtn, 1, 0), element1); 
     163        simulateEvent(new MouseButtonUp(leftBtn, 5, 0), element1); 
    164164        assertCondensedMouseClicks("drag left elem1"); 
    165165 
    166166        simulateEvent(new MouseButtonDown(leftBtn, 0, 0), element1); 
    167         simulateEvent(new MouseButtonUp(leftBtn, 1, 1), element1); 
     167        simulateEvent(new MouseButtonUp(leftBtn, 5, 5), element1); 
    168168        assertCondensedMouseClicks("drag left elem1", "drag left elem1"); 
    169169 
    170170        simulateEvent(new MouseButtonDown(leftBtn, 0, 0), element1); 
    171         simulateEvent(new MouseButtonUp(leftBtn, 0, 1), element1); 
     171        simulateEvent(new MouseButtonUp(leftBtn, 0, 5), element1); 
    172172        simulateEvent(new MouseClick(leftBtn, 0, 0), element1); 
    173173        assertCondensedMouseClicks("drag left elem1", "drag left elem1", "drag left elem1", 
    174174                                   "click left elem1"); 
    175175 
    176         simulateEvent(new MouseButtonDown(middleBtn, 1, 0), element1); 
     176        simulateEvent(new MouseButtonDown(middleBtn, 5, 0), element1); 
    177177        simulateEvent(new MouseButtonUp(middleBtn, 0, 0), element1); 
    178178        simulateEvent(new MouseClick(middleBtn, 0, 0), element1); 
     
    180180                                   "click left elem1", "", "", "click middle elem1"); 
    181181 
    182         simulateEvent(new MouseButtonDown(rightBtn, 0, 1), element1); 
     182        simulateEvent(new MouseButtonDown(rightBtn, 0, 5), element1); 
    183183        simulateEvent(new MouseButtonUp(rightBtn, 0, 0), element1); 
    184184        simulateEvent(new MouseClick(rightBtn, 0, 0), element1); 
     
    191191     * 
    192192     */ 
     193    @Test 
     194    public void testDoubleClick() { 
     195        MouseButtonInteraction.Button leftBtn = MouseButtonInteraction.Button.LEFT; 
     196        MouseButtonInteraction.Button rightBtn = MouseButtonInteraction.Button.RIGHT; 
     197 
     198        IGUIElement element1 = new DummyGUIElement("elem1"); 
     199 
     200        simulateEventWithTimestamp(new MouseClick(leftBtn, 0, 0), element1); 
     201        simulateEventWithTimestamp(new MouseClick(leftBtn, 0, 0), element1); 
     202        assertCondensedMouseClicks("dblclick left elem1"); 
     203 
     204        simulateEventWithTimestamp(new MouseButtonDown(leftBtn, 5, 5), element1); 
     205        simulateEventWithTimestamp(new MouseButtonUp(leftBtn, 5, 5), element1); 
     206        simulateEventWithTimestamp(new MouseButtonDown(leftBtn, 5, 5), element1); 
     207        simulateEventWithTimestamp(new MouseButtonUp(leftBtn, 5, 5), element1); 
     208        assertCondensedMouseClicks("dblclick left elem1", "dblclick left elem1"); 
     209 
     210        simulateEventWithTimestamp(new MouseClick(leftBtn, 0, 0), element1); 
     211        simulateEventWithTimestamp(new MouseClick(leftBtn, 5, 5), element1); 
     212        assertCondensedMouseClicks("dblclick left elem1", "dblclick left elem1", 
     213                                   "click left elem1", "click left elem1"); 
     214 
     215        simulateEventWithTimestamp(new MouseButtonDown(leftBtn, 0, 0), element1); 
     216        simulateEventWithTimestamp(new MouseButtonUp(leftBtn, 0, 0), element1); 
     217        simulateEventWithTimestamp(new MouseButtonDown(leftBtn, 5, 5), element1); 
     218        simulateEventWithTimestamp(new MouseButtonUp(leftBtn, 5, 5), element1); 
     219        assertCondensedMouseClicks("dblclick left elem1", "dblclick left elem1", 
     220                                   "click left elem1", "click left elem1", 
     221                                   "click left elem1", "click left elem1"); 
     222 
     223        simulateEventWithTimestamp(new MouseClick(rightBtn, 0, 0), element1); 
     224        simulateEventWithTimestamp(new MouseClick(rightBtn, 5, 5), element1); 
     225        assertCondensedMouseClicks("dblclick left elem1", "dblclick left elem1", 
     226                                   "click left elem1", "click left elem1", 
     227                                   "click left elem1", "click left elem1", 
     228                                   "click right elem1", "click right elem1"); 
     229 
     230        simulateEventWithTimestamp(new MouseButtonDown(rightBtn, 0, 0), element1); 
     231        simulateEventWithTimestamp(new MouseButtonUp(rightBtn, 0, 0), element1); 
     232        simulateEventWithTimestamp(new MouseButtonDown(rightBtn, 5, 5), element1); 
     233        simulateEventWithTimestamp(new MouseButtonUp(rightBtn, 5, 5), element1); 
     234        assertCondensedMouseClicks("dblclick left elem1", "dblclick left elem1", 
     235                                   "click left elem1", "click left elem1", 
     236                                   "click left elem1", "click left elem1", 
     237                                   "click right elem1", "click right elem1", 
     238                                   "click right elem1", "click right elem1"); 
     239 
     240    } 
     241 
     242    /** 
     243     * 
     244     */ 
    193245    private void simulateEvent(IEventType eventType, IGUIElement guiElement) { 
    194246        events.add(new Event(eventType, guiElement)); 
     247    } 
     248 
     249    /** 
     250     * 
     251     */ 
     252    private void simulateEventWithTimestamp(IEventType eventType, IGUIElement guiElement) { 
     253        Event event = new Event(eventType, guiElement); 
     254        event.setTimestamp(System.currentTimeMillis()); 
     255        events.add(event); 
    195256    } 
    196257 
     
    214275                    assertTrue(result.get(i).getType() instanceof MouseClick); 
    215276                } 
     277                else if ("dblclick".equals(parts[0])) { 
     278                    assertTrue(result.get(i).getType() instanceof MouseDoubleClick); 
     279                } 
    216280                else if ("drag".equals(parts[0])) { 
    217281                    assertTrue(result.get(i).getType() instanceof MouseDragAndDrop); 
Note: See TracChangeset for help on using the changeset viewer.