Ignore:
Timestamp:
08/17/12 08:33:29 (12 years ago)
Author:
pharms
Message:
  • adapted task tree creation stuff to more general event handling
Location:
trunk/quest-core-tasktrees-test/src/test/java/de/ugoe/cs/quest/tasktrees/temporalrelation
Files:
5 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/quest-core-tasktrees-test/src/test/java/de/ugoe/cs/quest/tasktrees/temporalrelation/AbstractTemporalRelationshipTC.java

    r452 r557  
    1 //------------------------------------------------------------------------------------------------- 
    21// Module    : $RCSfile: AbstractTemporalRelationshipTC.java,v $ 
    32// Version   : $Revision: 0.0 $  $Author: patrick $  $Date: 28.04.2012 $ 
     
    54// Creation  : 2012 by patrick 
    65// Copyright : Patrick Harms, 2012 
    7 //------------------------------------------------------------------------------------------------- 
     6 
    87package de.ugoe.cs.quest.tasktrees.temporalrelation; 
    98 
     
    1413import org.junit.Before; 
    1514 
    16 import de.ugoe.cs.quest.eventcore.guimodel.GUIElement; 
    17 import de.ugoe.cs.quest.eventcore.userinteraction.Interaction; 
     15import de.ugoe.cs.quest.eventcore.IEventTarget; 
     16import de.ugoe.cs.quest.eventcore.IEventType; 
    1817import de.ugoe.cs.quest.tasktrees.nodeequality.NodeEqualityRuleManager; 
    1918import de.ugoe.cs.quest.tasktrees.testutils.SimpleLogFormatter; 
    2019import de.ugoe.cs.quest.tasktrees.testutils.Utilities; 
    21 import de.ugoe.cs.quest.tasktrees.treeifc.InteractionTask; 
    22 import de.ugoe.cs.quest.tasktrees.treeifc.Sequence; 
    23 import de.ugoe.cs.quest.tasktrees.treeifc.TaskTree; 
    24 import de.ugoe.cs.quest.tasktrees.treeifc.TaskTreeBuilder; 
    25 import de.ugoe.cs.quest.tasktrees.treeifc.TaskTreeNodeFactory; 
    26 import de.ugoe.cs.quest.tasktrees.treeimpl.TaskTreeBuilderImpl; 
    27 import de.ugoe.cs.quest.tasktrees.treeimpl.TaskTreeNodeFactoryImpl; 
     20import de.ugoe.cs.quest.tasktrees.treeifc.IEventTask; 
     21import de.ugoe.cs.quest.tasktrees.treeifc.ISequence; 
     22import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTree; 
     23import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTreeBuilder; 
     24import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTreeNodeFactory; 
     25import de.ugoe.cs.quest.tasktrees.treeimpl.TaskTreeBuilder; 
     26import de.ugoe.cs.quest.tasktrees.treeimpl.TaskTreeNodeFactory; 
    2827 
    29 //------------------------------------------------------------------------------------------------- 
    3028/** 
    3129 * TODO comment 
     
    3432 * @author 2012, last modified by $Author: patrick$ 
    3533 */ 
    36 //------------------------------------------------------------------------------------------------- 
    37 public class AbstractTemporalRelationshipTC 
    38 { 
     34public class AbstractTemporalRelationshipTC { 
    3935 
    40   /** */ 
    41   private List<InteractionTask> mInteractions; 
    42    
    43   /** */ 
    44   private TaskTreeBuilder mTaskTreeBuilder = new TaskTreeBuilderImpl(); 
     36    /** */ 
     37    private List<IEventTask> events; 
    4538 
    46   /** */ 
    47   private TaskTreeNodeFactory mTaskTreeNodeFactory = new TaskTreeNodeFactoryImpl(); 
    48    
    49   /** */ 
    50   private NodeEqualityRuleManager mNodeEqualityRuleManager = 
    51     Utilities.getNodeEqualityRuleManagerForTests(); 
     39    /** */ 
     40    private ITaskTreeBuilder taskTreeBuilder = new TaskTreeBuilder(); 
    5241 
    53   //----------------------------------------------------------------------------------------------- 
    54   /** 
     42    /** */ 
     43    private ITaskTreeNodeFactory taskTreeNodeFactory = new TaskTreeNodeFactory(); 
     44 
     45    /** */ 
     46    private NodeEqualityRuleManager nodeEqualityRuleManager = 
     47        Utilities.getNodeEqualityRuleManagerForTests(); 
     48 
     49    /** 
    5550   * 
    5651   */ 
    57   //----------------------------------------------------------------------------------------------- 
    58   @Before 
    59   public void setUp() 
    60   { 
    61     Logger.getLogger("").getHandlers()[0].setFormatter(new SimpleLogFormatter()); 
    62     mInteractions = new ArrayList<InteractionTask>(); 
    63   } 
     52    @Before 
     53    public void setUp() { 
     54        Logger.getLogger("").getHandlers()[0].setFormatter(new SimpleLogFormatter()); 
     55        events = new ArrayList<IEventTask>(); 
     56    } 
    6457 
    65   //----------------------------------------------------------------------------------------------- 
    66   /** 
    67    * @param interactionsDoNotOverwriteElement 
    68    */ 
    69   //----------------------------------------------------------------------------------------------- 
    70   protected void simulateInteraction(GUIElement GUIElement, Interaction interaction) 
    71   { 
    72     mInteractions.add 
    73       (mTaskTreeNodeFactory.createNewInteractionTask(GUIElement, interaction)); 
    74   } 
     58    /** 
     59     * 
     60     */ 
     61    protected void simulateEvent(IEventType eventType, IEventTarget eventTarget) { 
     62        events.add(taskTreeNodeFactory.createNewEventTask(eventType, eventTarget)); 
     63    } 
    7564 
    76   //----------------------------------------------------------------------------------------------- 
    77   /** 
    78    * @param interactionsDoNotOverwriteElement 
    79    * @return  
    80    */ 
    81   //----------------------------------------------------------------------------------------------- 
    82   protected TaskTree getTaskTree() 
    83   { 
    84     Sequence sequence = mTaskTreeNodeFactory.createNewSequence(); 
    85      
    86     for (InteractionTask task : mInteractions) 
    87     { 
    88       mTaskTreeBuilder.addChild(sequence, task); 
     65    /** 
     66     * 
     67     * @return 
     68     */ 
     69    protected ITaskTree getTaskTree() { 
     70        ISequence sequence = taskTreeNodeFactory.createNewSequence(); 
     71 
     72        for (IEventTask task : events) { 
     73            taskTreeBuilder.addChild(sequence, task); 
     74        } 
     75 
     76        TemporalRelationshipRuleManager ruleManager = 
     77            new TemporalRelationshipRuleManager(nodeEqualityRuleManager); 
     78 
     79        ruleManager.init(); 
     80        ruleManager.applyRules(sequence, taskTreeBuilder, taskTreeNodeFactory, true); 
     81 
     82        return taskTreeNodeFactory.createTaskTree(sequence); 
    8983    } 
    90      
    91     TemporalRelationshipRuleManager ruleManager = 
    92       new TemporalRelationshipRuleManager(mNodeEqualityRuleManager); 
    93      
    94     ruleManager.init(); 
    95     ruleManager.applyRules(sequence, mTaskTreeBuilder, mTaskTreeNodeFactory, true); 
    96      
    97     return mTaskTreeNodeFactory.createTaskTree(sequence); 
    98   } 
    9984 
    10085} 
  • trunk/quest-core-tasktrees-test/src/test/java/de/ugoe/cs/quest/tasktrees/temporalrelation/DefaultGuiEventSequenceDetectionRuleTest.java

    r468 r557  
    1 //------------------------------------------------------------------------------------------------- 
    21// Module    : $RCSfile: TaskTreeManagerTest.java,v $ 
    32// Version   : $Revision: 0.0 $  $Author: Patrick $  $Date: 08.11.2011 21:32:36 $ 
     
    54// Creation  : 2011 by Patrick 
    65// Copyright : Patrick Harms, 2011 
    7 //------------------------------------------------------------------------------------------------- 
    86 
    97package de.ugoe.cs.quest.tasktrees.temporalrelation; 
     
    119import org.junit.Test; 
    1210 
    13 import de.ugoe.cs.quest.eventcore.guimodel.GUIElement; 
    14 import de.ugoe.cs.quest.eventcore.userinteraction.Interaction; 
     11import de.ugoe.cs.quest.eventcore.IEventTarget; 
    1512import de.ugoe.cs.quest.tasktrees.testutils.DummyGUIElement; 
    1613import de.ugoe.cs.quest.tasktrees.testutils.DummyInteraction; 
    1714import de.ugoe.cs.quest.tasktrees.testutils.TaskTreeChecker; 
    1815 
    19 //------------------------------------------------------------------------------------------------- 
    2016/** 
    2117 * TODO comment 
    22  * 
     18 *  
    2319 * @version $Revision: $ $Date: $ 
    24  * @author  2011, last modified by $Author: $ 
     20 * @author 2011, last modified by $Author: $ 
    2521 */ 
    26 //------------------------------------------------------------------------------------------------- 
    27 public class DefaultGUIElementSequenceDetectionRuleTest extends AbstractTemporalRelationshipTC 
    28 { 
    29   //----------------------------------------------------------------------------------------------- 
    30   /** 
    31    * 
    32    */ 
    33   //----------------------------------------------------------------------------------------------- 
    34   @Test 
    35   public void testOneInteractionOnOneElement() 
    36   { 
    37     simulateInteraction(new DummyGUIElement("elem1"), new DummyInteraction("bla", 1)); 
     22public class DefaultGuiEventSequenceDetectionRuleTest extends AbstractTemporalRelationshipTC { 
    3823     
    39     new TaskTreeChecker().assertTaskTree 
    40       ("Sequence sequence {" + 
    41        "  Interaction bla {}" + 
    42        "}", getTaskTree()); 
    43   } 
    44    
    45   //----------------------------------------------------------------------------------------------- 
    46   /** 
    47    * 
    48    */ 
    49   //----------------------------------------------------------------------------------------------- 
    50   @Test 
    51   public void testManyInteractionsOnOneElement() 
    52   { 
    53     GUIElement element = new DummyGUIElement("elem1"); 
    54     simulateInteraction(element, new DummyInteraction("bla", 1)); 
    55     simulateInteraction(element, new DummyInteraction("bli", 1)); 
    56     simulateInteraction(element, new DummyInteraction("blo", 1)); 
    57     simulateInteraction(element, new DummyInteraction("blu", 1)); 
    58     simulateInteraction(element, new DummyInteraction("bla", 1)); 
    59      
    60     new TaskTreeChecker().assertTaskTree 
    61       ("Sequence sequence {" + 
    62        "  Interaction bla {}" + 
    63        "  Interaction bli {}" + 
    64        "  Interaction blo {}" + 
    65        "  Interaction blu {}" + 
    66        "  Interaction bla {}" + 
    67        "}", getTaskTree()); 
    68   } 
    69    
    70   //----------------------------------------------------------------------------------------------- 
    71   /** 
    72    * 
    73    */ 
    74   //----------------------------------------------------------------------------------------------- 
    75   @Test 
    76   public void testOneInteractionOnManyElements() 
    77   { 
    78     GUIElement element1 = new DummyGUIElement("elem1"); 
    79     GUIElement element2 = new DummyGUIElement("elem2"); 
    80     GUIElement element3 = new DummyGUIElement("elem3"); 
    81     GUIElement element4 = new DummyGUIElement("elem4"); 
    82     GUIElement element5 = new DummyGUIElement("elem5"); 
    83     GUIElement element6 = new DummyGUIElement("elem6"); 
    84     simulateInteraction(element1, new DummyInteraction("bla", 1)); 
    85     simulateInteraction(element2, new DummyInteraction("bli", 1)); 
    86     simulateInteraction(element3, new DummyInteraction("bla", 1)); 
    87     simulateInteraction(element4, new DummyInteraction("bli", 1)); 
    88     simulateInteraction(element5, new DummyInteraction("blo", 1)); 
    89     simulateInteraction(element6, new DummyInteraction("bla", 1)); 
     24    /** 
     25     * 
     26     */ 
     27    @Test 
     28    public void testOneInteractionOnOneElement() { 
     29        simulateEvent(new DummyInteraction("bla", 1), new DummyGUIElement("elem1")); 
    9030 
    91     new TaskTreeChecker().assertTaskTree 
    92       ("Sequence sequence0 {" + 
    93        "  Sequence sequence1 {" + 
    94        "    Interaction bla {}" + 
    95        "  }" + 
    96        "  Sequence sequence2 {" + 
    97        "    Interaction bli {}" + 
    98        "  }" + 
    99        "  Sequence sequence3 {" + 
    100        "    Interaction bla {}" + 
    101        "  }" + 
    102        "  Sequence sequence4 {" + 
    103        "    Interaction bli {}" + 
    104        "  }" + 
    105        "  Sequence sequence5 {" + 
    106        "    Interaction blo {}" + 
    107        "  }" + 
    108        "  Sequence sequence6 {" + 
    109        "    Interaction bla {}" + 
    110        "  }" + 
    111        "}", getTaskTree()); 
    112   } 
     31        new TaskTreeChecker().assertTaskTree 
     32            ("Sequence sequence {" + 
     33             "  Event bla {}" + 
     34             "}", getTaskTree()); 
     35    } 
    11336 
    114   //----------------------------------------------------------------------------------------------- 
    115   /** 
    116    * 
    117    */ 
    118   //----------------------------------------------------------------------------------------------- 
    119   @Test 
    120   public void testManyInteractionsOnManyElements() 
    121   { 
    122     GUIElement element1 = new DummyGUIElement("elem1"); 
    123     GUIElement element2 = new DummyGUIElement("elem2"); 
    124     GUIElement element3 = new DummyGUIElement("elem3"); 
    125     GUIElement element4 = new DummyGUIElement("elem4"); 
    126     GUIElement element5 = new DummyGUIElement("elem5"); 
    127     GUIElement element6 = new DummyGUIElement("elem6"); 
    128     simulateInteraction(element1, new DummyInteraction("bla", 1)); 
    129     simulateInteraction(element1, new DummyInteraction("bli", 1)); 
    130     simulateInteraction(element1, new DummyInteraction("bla", 1)); 
    131     simulateInteraction(element2, new DummyInteraction("bli", 1)); 
    132     simulateInteraction(element2, new DummyInteraction("blo", 1)); 
    133     simulateInteraction(element3, new DummyInteraction("bla", 1)); 
    134     simulateInteraction(element4, new DummyInteraction("bli", 1)); 
    135     simulateInteraction(element4, new DummyInteraction("bla", 1)); 
    136     simulateInteraction(element4, new DummyInteraction("bli", 1)); 
    137     simulateInteraction(element4, new DummyInteraction("blo", 1)); 
    138     simulateInteraction(element5, new DummyInteraction("bla", 1)); 
    139     simulateInteraction(element6, new DummyInteraction("bli", 1)); 
    140     simulateInteraction(element6, new DummyInteraction("bla", 1)); 
    141     simulateInteraction(element6, new DummyInteraction("bli", 1)); 
    142     simulateInteraction(element6, new DummyInteraction("blo", 1)); 
    143      
    144     new TaskTreeChecker().assertTaskTree 
    145       ("Sequence sequence0 {" + 
    146        "  Sequence sequence1 {" + 
    147        "    Interaction bla {}" + 
    148        "    Interaction bli {}" + 
    149        "    Interaction bla {}" + 
    150        "  }" + 
    151        "  Sequence sequence2 {" + 
    152        "    Interaction bli {}" + 
    153        "    Interaction blo {}" + 
    154        "  }" + 
    155        "  Sequence sequence3 {" + 
    156        "    Interaction bla {}" + 
    157        "  }" + 
    158        "  Sequence sequence4 {" + 
    159        "    Interaction bli {}" + 
    160        "    Interaction bla {}" + 
    161        "    Interaction bli {}" + 
    162        "    Interaction blo {}" + 
    163        "  }" + 
    164        "  Sequence sequence5 {" + 
    165        "    Interaction bla {}" + 
    166        "  }" + 
    167        "  Sequence sequence6 {" + 
    168        "    Interaction bli {}" + 
    169        "    Interaction bla {}" + 
    170        "    Interaction bli {}" + 
    171        "    Interaction blo {}" + 
    172        "  }" + 
    173        "}", getTaskTree()); 
    174   } 
     37    /** 
     38     * 
     39     */ 
     40    @Test 
     41    public void testManyInteractionsOnOneElement() { 
     42        IEventTarget eventTarget = new DummyGUIElement("elem1"); 
     43        simulateEvent(new DummyInteraction("bla", 1), eventTarget); 
     44        simulateEvent(new DummyInteraction("bli", 1), eventTarget); 
     45        simulateEvent(new DummyInteraction("blo", 1), eventTarget); 
     46        simulateEvent(new DummyInteraction("blu", 1), eventTarget); 
     47        simulateEvent(new DummyInteraction("bla", 1), eventTarget); 
    17548 
    176   //----------------------------------------------------------------------------------------------- 
    177   /** 
    178    * 
    179    */ 
    180   //----------------------------------------------------------------------------------------------- 
    181   @Test 
    182   public void testGUIElementHierarchyChanges() throws Exception 
    183   { 
    184     GUIElement element1 = new DummyGUIElement("elem1"); 
    185     GUIElement element2 = new DummyGUIElement("elem2"); 
    186     GUIElement element3 = new DummyGUIElement("elem3"); 
    187     GUIElement parent1 = new DummyGUIElement("parent1"); 
    188     GUIElement parent2 = new DummyGUIElement("parent2"); 
    189     GUIElement parent3 = new DummyGUIElement("parent3"); 
    190      
    191     element1.setParent(parent1); 
    192     element2.setParent(parent2); 
    193     element3.setParent(parent3); 
    194      
    195     parent1.setParent(parent2); 
    196     parent2.setParent(parent3); 
    197      
    198     Interaction interaction1 = new DummyInteraction("bla", 1); 
    199     simulateInteraction(element1, interaction1); 
    200     simulateInteraction(element2, interaction1); 
    201     simulateInteraction(element3, interaction1); 
    202     simulateInteraction(element2, interaction1); 
    203     simulateInteraction(element3, interaction1); 
    204     simulateInteraction(element2, interaction1); 
    205     simulateInteraction(element1, interaction1); 
    206     
    207     new TaskTreeChecker().assertTaskTree 
    208       ("Sequence sequence0 {" + 
    209        "  Sequence sequence1 {" + 
    210        "    Interaction bla {}" + 
    211        "  }" + 
    212        "  Sequence sequence2 {" + 
    213        "    Interaction bla {}" + 
    214        "  }" + 
    215        "  Iteration iteration0 {" + 
    216        "    Sequence sequence3 {" + 
    217        "      Sequence sequence4 {" + 
    218        "        Interaction bla {}" + 
    219        "      }" + 
    220        "      Sequence sequence5 {" + 
    221        "        Interaction bla {}" + 
    222        "      }" + 
    223        "    }" + 
    224        "  }" + 
    225        "  Sequence sequence6 {" + 
    226        "    Interaction bla {}" + 
    227        "  }" + 
    228        "}", getTaskTree());     
     49        new TaskTreeChecker().assertTaskTree 
     50            ("Sequence sequence {" + 
     51             "  Event bla {}" + 
     52             "  Event bli {}" + 
     53             "  Event blo {}" + 
     54             "  Event blu {}" + 
     55             "  Event bla {}" + 
     56             "}", getTaskTree()); 
     57    } 
    22958 
    230   } 
    231    
     59    /** 
     60     * 
     61     */ 
     62    @Test 
     63    public void testOneInteractionOnManyElements() { 
     64        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     65        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
     66        IEventTarget eventTarget3 = new DummyGUIElement("elem3"); 
     67        IEventTarget eventTarget4 = new DummyGUIElement("elem4"); 
     68        IEventTarget eventTarget5 = new DummyGUIElement("elem5"); 
     69        IEventTarget eventTarget6 = new DummyGUIElement("elem6"); 
     70        simulateEvent(new DummyInteraction("bla", 1), eventTarget1); 
     71        simulateEvent(new DummyInteraction("bli", 1), eventTarget2); 
     72        simulateEvent(new DummyInteraction("bla", 1), eventTarget3); 
     73        simulateEvent(new DummyInteraction("bli", 1), eventTarget4); 
     74        simulateEvent(new DummyInteraction("blo", 1), eventTarget5); 
     75        simulateEvent(new DummyInteraction("bla", 1), eventTarget6); 
     76 
     77        new TaskTreeChecker().assertTaskTree 
     78            ("Sequence sequence0 {" + 
     79             "  Sequence sequence1 {" + 
     80             "    Event bla {}" + 
     81             "  }" + 
     82             "  Sequence sequence2 {" + 
     83             "    Event bli {}" + 
     84             "  }" + 
     85             "  Sequence sequence3 {" + 
     86             "    Event bla {}" + 
     87             "  }" + 
     88             "  Sequence sequence4 {" + 
     89             "    Event bli {}" + 
     90             "  }" + 
     91             "  Sequence sequence5 {" + 
     92             "    Event blo {}" + 
     93             "  }" + 
     94             "  Sequence sequence6 {" + 
     95             "    Event bla {}" + 
     96             "  }" + 
     97             "}", getTaskTree()); 
     98    } 
     99 
     100    /** 
     101     * 
     102     */ 
     103    @Test 
     104    public void testManyInteractionsOnManyElements() { 
     105        IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 
     106        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
     107        IEventTarget eventTarget3 = new DummyGUIElement("elem3"); 
     108        IEventTarget eventTarget4 = new DummyGUIElement("elem4"); 
     109        IEventTarget eventTarget5 = new DummyGUIElement("elem5"); 
     110        IEventTarget eventTarget6 = new DummyGUIElement("elem6"); 
     111        simulateEvent(new DummyInteraction("bla", 1), eventTarget1); 
     112        simulateEvent(new DummyInteraction("bli", 1), eventTarget1); 
     113        simulateEvent(new DummyInteraction("bla", 1), eventTarget1); 
     114        simulateEvent(new DummyInteraction("bli", 1), eventTarget2); 
     115        simulateEvent(new DummyInteraction("blo", 1), eventTarget2); 
     116        simulateEvent(new DummyInteraction("bla", 1), eventTarget3); 
     117        simulateEvent(new DummyInteraction("bli", 1), eventTarget4); 
     118        simulateEvent(new DummyInteraction("bla", 1), eventTarget4); 
     119        simulateEvent(new DummyInteraction("bli", 1), eventTarget4); 
     120        simulateEvent(new DummyInteraction("blo", 1), eventTarget4); 
     121        simulateEvent(new DummyInteraction("bla", 1), eventTarget5); 
     122        simulateEvent(new DummyInteraction("bli", 1), eventTarget6); 
     123        simulateEvent(new DummyInteraction("bla", 1), eventTarget6); 
     124        simulateEvent(new DummyInteraction("bli", 1), eventTarget6); 
     125        simulateEvent(new DummyInteraction("blo", 1), eventTarget6); 
     126 
     127        new TaskTreeChecker().assertTaskTree 
     128            ("Sequence sequence0 {" + 
     129             "  Sequence sequence1 {" + 
     130             "    Event bla {}" + 
     131             "    Event bli {}" + 
     132             "    Event bla {}" + 
     133             "  }" + 
     134             "  Sequence sequence2 {" + 
     135             "    Event bli {}" + 
     136             "    Event blo {}" + 
     137             "  }" + 
     138             "  Sequence sequence3 {" + 
     139             "    Event bla {}" + 
     140             "  }" + 
     141             "  Sequence sequence4 {" + 
     142             "    Event bli {}" + 
     143             "    Event bla {}" + 
     144             "    Event bli {}" + 
     145             "    Event blo {}" + 
     146             "  }" + 
     147             "  Sequence sequence5 {" + 
     148             "    Event bla {}" + 
     149             "  }" + 
     150             "  Sequence sequence6 {" + 
     151             "    Event bli {}" + 
     152             "    Event bla {}" + 
     153             "    Event bli {}" + 
     154             "    Event blo {}" + 
     155             "  }" + 
     156             "}", getTaskTree()); 
     157    } 
     158 
    232159} 
  • trunk/quest-core-tasktrees-test/src/test/java/de/ugoe/cs/quest/tasktrees/temporalrelation/DefaultIterationDetectionRuleTest.java

    r468 r557  
    1 //------------------------------------------------------------------------------------------------- 
    21// Module    : $RCSfile: DefaultIterationDetectionRuleTest.java,v $ 
    32// Version   : $Revision: 0.0 $  $Author: patrick $  $Date: 28.04.2012 $ 
     
    54// Creation  : 2012 by patrick 
    65// Copyright : Patrick Harms, 2012 
    7 //------------------------------------------------------------------------------------------------- 
     6 
    87package de.ugoe.cs.quest.tasktrees.temporalrelation; 
    98 
    109import org.junit.Test; 
    1110 
    12 import de.ugoe.cs.quest.eventcore.guimodel.GUIElement; 
    13 import de.ugoe.cs.quest.eventcore.userinteraction.Interaction; 
     11import de.ugoe.cs.quest.eventcore.IEventTarget; 
     12import de.ugoe.cs.quest.eventcore.IEventType; 
    1413import de.ugoe.cs.quest.tasktrees.testutils.DummyGUIElement; 
    1514import de.ugoe.cs.quest.tasktrees.testutils.DummyInteraction; 
    1615import de.ugoe.cs.quest.tasktrees.testutils.TaskTreeChecker; 
    1716 
    18 //------------------------------------------------------------------------------------------------- 
    1917/** 
    2018 * TODO comment 
     
    2321 * @author 2012, last modified by $Author: patrick$ 
    2422 */ 
    25 //------------------------------------------------------------------------------------------------- 
    26 public class DefaultIterationDetectionRuleTest extends AbstractTemporalRelationshipTC 
    27 { 
    28  
    29   //----------------------------------------------------------------------------------------------- 
    30   /** 
    31    * 
    32    */ 
    33   //----------------------------------------------------------------------------------------------- 
    34   @Test 
    35   public void testInteractionIterationDetection() throws Exception 
    36   { 
    37     GUIElement element1 = new DummyGUIElement("elem1"); 
    38     Interaction interaction1 = new DummyInteraction("bla", 1); 
    39     simulateInteraction(element1, interaction1); 
    40     new TaskTreeChecker().assertTaskTree 
    41       ("Sequence sequence1 {" + 
    42        "  Interaction bla {}" + 
    43        "}", getTaskTree());     
    44  
    45     simulateInteraction(element1, interaction1); 
    46     new TaskTreeChecker().assertTaskTree 
    47       ("Sequence sequence1 {" + 
    48        "  Iteration iteration1 {" + 
    49        "    Interaction bla {}" + 
    50        "  }" + 
    51        "}", getTaskTree());     
    52  
    53     simulateInteraction(element1, interaction1); 
    54     new TaskTreeChecker().assertTaskTree 
    55       ("Sequence sequence1 {" + 
    56        "  Iteration iteration1 {" + 
    57        "    Interaction bla {}" + 
    58        "  }" + 
    59        "}", getTaskTree());     
    60  
    61     for (int i = 0; i < 10; i++) 
    62     { 
    63       simulateInteraction(element1, interaction1); 
     23public class DefaultIterationDetectionRuleTest extends AbstractTemporalRelationshipTC { 
     24 
     25    /** 
     26     * 
     27     */ 
     28    @Test 
     29    public void testInteractionIterationDetection() throws Exception { 
     30        IEventTarget element1 = new DummyGUIElement("elem1"); 
     31        IEventType event1 = new DummyInteraction("bla", 1); 
     32        simulateEvent(event1, element1); 
     33        new TaskTreeChecker().assertTaskTree 
     34            ("Sequence sequence1 {" + 
     35             "  Event bla {}" + 
     36             "}", getTaskTree()); 
     37 
     38        simulateEvent(event1, element1); 
     39        new TaskTreeChecker().assertTaskTree 
     40            ("Sequence sequence1 {" + 
     41             "  Iteration iteration1 {" + 
     42             "    Event bla {}" + 
     43             "  }" + 
     44             "}", getTaskTree()); 
     45 
     46        simulateEvent(event1, element1); 
     47        new TaskTreeChecker().assertTaskTree 
     48            ("Sequence sequence1 {" + 
     49             "  Iteration iteration1 {" + 
     50             "    Event bla {}" + 
     51             "  }" + 
     52             "}", getTaskTree()); 
     53 
     54        for (int i = 0; i < 10; i++) { 
     55            simulateEvent(event1, element1); 
     56        } 
     57 
     58        new TaskTreeChecker().assertTaskTree 
     59            ("Sequence sequence1 {" + 
     60             "  Iteration iteration1 {" + 
     61             "    Event bla {}" + 
     62             "  }" + 
     63             "}", getTaskTree()); 
     64 
     65        // now test with preceding and trailing other events 
     66        IEventType event2 = new DummyInteraction("bli", 1); 
     67        IEventType event3 = new DummyInteraction("blup", 1); 
     68 
     69        simulateEvent(event2, element1); 
     70        simulateEvent(event3, element1); 
     71        for (int i = 0; i < 10; i++) { 
     72            simulateEvent(event1, element1); 
     73        } 
     74        simulateEvent(event3, element1); 
     75        simulateEvent(event2, element1); 
     76 
     77        new TaskTreeChecker().assertTaskTree 
     78            ("Sequence sequence1 {" + 
     79             "  Iteration iteration1 {" + 
     80             "    Event bla {}" + 
     81             "  }" + 
     82             "  Event bli {}" + 
     83             "  Event blup {}" + 
     84             "  Iteration iteration2 {" + 
     85             "    Event bla {}" + 
     86             "  }" + 
     87             "  Event blup {}" + 
     88             "  Event bli {}" + 
     89             "}", getTaskTree()); 
     90 
     91        // now test with iterations of iterations 
     92 
     93        for (int i = 0; i < 10; i++) { 
     94            for (int j = 0; j < 5; j++) { 
     95                simulateEvent(event1, element1); 
     96            } 
     97            for (int j = 0; j < 5; j++) { 
     98                simulateEvent(event2, element1); 
     99            } 
     100            for (int j = 0; j < 5; j++) { 
     101                simulateEvent(event3, element1); 
     102            } 
     103        } 
     104 
     105        new TaskTreeChecker().assertTaskTree 
     106            ("Sequence sequence1 {" + 
     107             "  Iteration iteration1 {" + 
     108             "    Event bla {}" + 
     109             "  }" + 
     110             "  Event bli {}" + 
     111             "  Event blup {}" + 
     112             "  Iteration iteration2 {" + 
     113             "    Event bla {}" + 
     114             "  }" + 
     115             "  Event blup {}" + 
     116             "  Event bli {}" + 
     117             "  Iteration iteration3 {" + 
     118             "    Sequence sequence2 {" + 
     119             "      Iteration iteration4 {" + 
     120             "        Event bla {}" + 
     121             "      }" + 
     122             "      Iteration iteration5 {" + 
     123             "        Event bli {}" + 
     124             "      }" + 
     125             "      Iteration iteration6 {" + 
     126             "        Event blup {}" + 
     127             "      }" + 
     128             "    }" + 
     129             "  }" + 
     130             "}", getTaskTree()); 
     131 
    64132    } 
    65      
    66     new TaskTreeChecker().assertTaskTree 
    67       ("Sequence sequence1 {" + 
    68        "  Iteration iteration1 {" + 
    69        "    Interaction bla {}" + 
    70        "  }" + 
    71        "}", getTaskTree());     
    72      
    73     // now test with preceding and trailing other interactions 
    74     Interaction interaction2 = new DummyInteraction("bli", 1); 
    75     Interaction interaction3 = new DummyInteraction("blup", 1); 
    76  
    77     simulateInteraction(element1, interaction2); 
    78     simulateInteraction(element1, interaction3); 
    79     for (int i = 0; i < 10; i++) 
    80     { 
    81       simulateInteraction(element1, interaction1); 
     133 
     134    /** 
     135     * 
     136     */ 
     137    @Test 
     138    public void testSequenceIterationDetection() throws Exception { 
     139        IEventTarget element1 = new DummyGUIElement("elem1"); 
     140        IEventType event1 = new DummyInteraction("bla", 1); 
     141        IEventType event2 = new DummyInteraction("bli", 1); 
     142        IEventType event3 = new DummyInteraction("blup", 1); 
     143        simulateEvent(event1, element1); 
     144        simulateEvent(event2, element1); 
     145        simulateEvent(event3, element1); 
     146        new TaskTreeChecker().assertTaskTree 
     147            ("Sequence sequence1 {" + 
     148             "  Event bla {}" + 
     149             "  Event bli {}" + 
     150             "  Event blup {}" + 
     151             "}", getTaskTree()); 
     152 
     153        simulateEvent(event1, element1); 
     154        simulateEvent(event2, element1); 
     155        simulateEvent(event3, element1); 
     156        new TaskTreeChecker().assertTaskTree 
     157            ("Sequence sequence1 {" + 
     158             "  Iteration iteration1 {" + 
     159             "    Sequence sequence2 {" + 
     160             "      Event bla {}" + 
     161             "      Event bli {}" + 
     162             "      Event blup {}" + 
     163             "    }" + 
     164             "  }" + 
     165             "}", getTaskTree()); 
     166 
     167        simulateEvent(event1, element1); 
     168        simulateEvent(event2, element1); 
     169        simulateEvent(event3, element1); 
     170        new TaskTreeChecker().assertTaskTree 
     171            ("Sequence sequence1 {" + 
     172             "  Iteration iteration1 {" + 
     173             "    Sequence sequence2 {" + 
     174             "      Event bla {}" + 
     175             "      Event bli {}" + 
     176             "      Event blup {}" + 
     177             "    }" + 
     178             "  }" + 
     179             "}", getTaskTree()); 
     180 
     181        for (int i = 0; i < 10; i++) { 
     182            simulateEvent(event1, element1); 
     183            simulateEvent(event2, element1); 
     184            simulateEvent(event3, element1); 
     185        } 
     186 
     187        new TaskTreeChecker().assertTaskTree 
     188            ("Sequence sequence1 {" + 
     189             "  Iteration iteration1 {" + 
     190             "    Sequence sequence2 {" + 
     191             "      Event bla {}" + 
     192             "      Event bli {}" + 
     193             "      Event blup {}" + 
     194             "    }" + 
     195             "  }" + 
     196             "}", getTaskTree()); 
     197 
     198        // now test with preceding and trailing other events 
     199        IEventType event4 = new DummyInteraction("ble", 1); 
     200        IEventType event5 = new DummyInteraction("blo", 1); 
     201        IEventType event6 = new DummyInteraction("blu", 1); 
     202        simulateEvent(event4, element1); 
     203        simulateEvent(event5, element1); 
     204        simulateEvent(event6, element1); 
     205        for (int i = 0; i < 10; i++) { 
     206            simulateEvent(event1, element1); 
     207            simulateEvent(event2, element1); 
     208            simulateEvent(event3, element1); 
     209        } 
     210        simulateEvent(event6, element1); 
     211        simulateEvent(event5, element1); 
     212        simulateEvent(event4, element1); 
     213 
     214        new TaskTreeChecker().assertTaskTree 
     215            ("Sequence sequence1 {" + 
     216             "  Iteration iteration1 {" + 
     217             "    Sequence sequence2 {" + 
     218             "      Event bla {}" + 
     219             "      Event bli {}" + 
     220             "      Event blup {}" + 
     221             "    }" + 
     222             "  }" + 
     223             "  Event ble {}" + 
     224             "  Event blo {}" + 
     225             "  Event blu {}" + 
     226             "  Iteration iteration2 {" + 
     227             "    Sequence sequence3 {" + 
     228             "      Event bla {}" + 
     229             "      Event bli {}" + 
     230             "      Event blup {}" + 
     231             "    }" + 
     232             "  }" + 
     233             "  Event blu {}" + 
     234             "  Event blo {}" + 
     235             "  Event ble {}" + 
     236             "}", getTaskTree()); 
     237 
     238        // now test with iterations of iterations 
     239        for (int i = 0; i < 10; i++) { 
     240            for (int j = 0; j < 5; j++) { 
     241                simulateEvent(event1, element1); 
     242                simulateEvent(event2, element1); 
     243                simulateEvent(event3, element1); 
     244            } 
     245            for (int j = 0; j < 5; j++) { 
     246                simulateEvent(event2, element1); 
     247                simulateEvent(event1, element1); 
     248                simulateEvent(event3, element1); 
     249            } 
     250            for (int j = 0; j < 5; j++) { 
     251                simulateEvent(event1, element1); 
     252                simulateEvent(event2, element1); 
     253                simulateEvent(event3, element1); 
     254            } 
     255        } 
     256 
     257        new TaskTreeChecker().assertTaskTree 
     258            ("Sequence sequence1 {" + 
     259             "  Iteration iteration1 {" + 
     260             "    Sequence sequence2 {" + 
     261             "      Event bla {}" + 
     262             "      Event bli {}" + 
     263             "      Event blup {}" + 
     264             "    }" + 
     265             "  }" + 
     266             "  Event ble {}" + 
     267             "  Event blo {}" + 
     268             "  Event blu {}" + 
     269             "  Iteration iteration2 {" + 
     270             "    Sequence sequence3 {" + 
     271             "      Event bla {}" + 
     272             "      Event bli {}" + 
     273             "      Event blup {}" + 
     274             "    }" + 
     275             "  }" + 
     276             "  Event blu {}" + 
     277             "  Event blo {}" + 
     278             "  Event ble {}" + 
     279             "  Iteration iteration3 {" + 
     280             "    Sequence sequence4 {" + 
     281             "      Iteration iteration4 {" + 
     282             "        Sequence sequence4 {" + 
     283             "          Event bla {}" + 
     284             "          Event bli {}" + 
     285             "          Event blup {}" + 
     286             "        }" + 
     287             "      }" + 
     288             "      Iteration iteration5 {" + 
     289             "        Sequence sequence5 {" + 
     290             "          Event bli {}" + 
     291             "          Event bla {}" + 
     292             "          Event blup {}" + 
     293             "        }" + 
     294             "      }" + 
     295             "      Iteration iteration6 {" + 
     296             "        Sequence sequence6 {" + 
     297             "          Event bla {}" + 
     298             "          Event bli {}" + 
     299             "          Event blup {}" + 
     300             "        }" + 
     301             "      }" + 
     302             "    }" + 
     303             "  }" + 
     304             "}", getTaskTree()); 
    82305    } 
    83     simulateInteraction(element1, interaction3); 
    84     simulateInteraction(element1, interaction2); 
    85      
    86     new TaskTreeChecker().assertTaskTree 
    87       ("Sequence sequence1 {" + 
    88        "  Iteration iteration1 {" + 
    89        "    Interaction bla {}" + 
    90        "  }" + 
    91        "  Interaction bli {}" + 
    92        "  Interaction blup {}" + 
    93        "  Iteration iteration2 {" + 
    94        "    Interaction bla {}" + 
    95        "  }" + 
    96        "  Interaction blup {}" + 
    97        "  Interaction bli {}" + 
    98        "}", getTaskTree());     
    99    
    100     // now test with iterations of iterations 
    101  
    102     for (int i = 0; i < 10; i++) 
    103     { 
    104       for (int j = 0; j < 5; j++) 
    105       { 
    106         simulateInteraction(element1, interaction1); 
    107       } 
    108       for (int j = 0; j < 5; j++) 
    109       { 
    110         simulateInteraction(element1, interaction2); 
    111       } 
    112       for (int j = 0; j < 5; j++) 
    113       { 
    114         simulateInteraction(element1, interaction3); 
    115       } 
    116     } 
    117      
    118     new TaskTreeChecker().assertTaskTree 
    119       ("Sequence sequence1 {" + 
    120        "  Iteration iteration1 {" + 
    121        "    Interaction bla {}" + 
    122        "  }" + 
    123        "  Interaction bli {}" + 
    124        "  Interaction blup {}" + 
    125        "  Iteration iteration2 {" + 
    126        "    Interaction bla {}" + 
    127        "  }" + 
    128        "  Interaction blup {}" + 
    129        "  Interaction bli {}" + 
    130        "  Iteration iteration3 {" + 
    131        "    Sequence sequence2 {" + 
    132        "      Iteration iteration4 {" + 
    133        "        Interaction bla {}" + 
    134        "      }" + 
    135        "      Iteration iteration5 {" + 
    136        "        Interaction bli {}" + 
    137        "      }" + 
    138        "      Iteration iteration6 {" + 
    139        "        Interaction blup {}" + 
    140        "      }" + 
    141        "    }" + 
    142        "  }" + 
    143        "}", getTaskTree());     
    144    
    145   } 
    146    
    147   //----------------------------------------------------------------------------------------------- 
    148   /** 
    149    * 
    150    */ 
    151   //----------------------------------------------------------------------------------------------- 
    152   @Test 
    153   public void testSequenceIterationDetection() throws Exception 
    154   { 
    155     GUIElement element1 = new DummyGUIElement("elem1"); 
    156     Interaction interaction1 = new DummyInteraction("bla", 1); 
    157     Interaction interaction2 = new DummyInteraction("bli", 1); 
    158     Interaction interaction3 = new DummyInteraction("blup", 1); 
    159     simulateInteraction(element1, interaction1); 
    160     simulateInteraction(element1, interaction2); 
    161     simulateInteraction(element1, interaction3); 
    162     new TaskTreeChecker().assertTaskTree 
    163       ("Sequence sequence1 {" + 
    164        "  Interaction bla {}" + 
    165        "  Interaction bli {}" + 
    166        "  Interaction blup {}" + 
    167        "}", getTaskTree());     
    168  
    169     simulateInteraction(element1, interaction1); 
    170     simulateInteraction(element1, interaction2); 
    171     simulateInteraction(element1, interaction3); 
    172     new TaskTreeChecker().assertTaskTree 
    173       ("Sequence sequence1 {" + 
    174        "  Iteration iteration1 {" + 
    175        "    Sequence sequence2 {" + 
    176        "      Interaction bla {}" + 
    177        "      Interaction bli {}" + 
    178        "      Interaction blup {}" + 
    179        "    }" + 
    180        "  }" + 
    181        "}", getTaskTree());     
    182  
    183     simulateInteraction(element1, interaction1); 
    184     simulateInteraction(element1, interaction2); 
    185     simulateInteraction(element1, interaction3); 
    186     new TaskTreeChecker().assertTaskTree 
    187       ("Sequence sequence1 {" + 
    188        "  Iteration iteration1 {" + 
    189        "    Sequence sequence2 {" + 
    190        "      Interaction bla {}" + 
    191        "      Interaction bli {}" + 
    192        "      Interaction blup {}" + 
    193        "    }" + 
    194        "  }" + 
    195        "}", getTaskTree());     
    196  
    197     for (int i = 0; i < 10; i++) 
    198     { 
    199       simulateInteraction(element1, interaction1); 
    200       simulateInteraction(element1, interaction2); 
    201       simulateInteraction(element1, interaction3); 
    202     } 
    203      
    204     new TaskTreeChecker().assertTaskTree 
    205       ("Sequence sequence1 {" + 
    206        "  Iteration iteration1 {" + 
    207        "    Sequence sequence2 {" + 
    208        "      Interaction bla {}" + 
    209        "      Interaction bli {}" + 
    210        "      Interaction blup {}" + 
    211        "    }" + 
    212        "  }" + 
    213        "}", getTaskTree());     
    214      
    215     // now test with preceding and trailing other interactions 
    216     Interaction interaction4 = new DummyInteraction("ble", 1); 
    217     Interaction interaction5 = new DummyInteraction("blo", 1); 
    218     Interaction interaction6 = new DummyInteraction("blu", 1); 
    219     simulateInteraction(element1, interaction4); 
    220     simulateInteraction(element1, interaction5); 
    221     simulateInteraction(element1, interaction6); 
    222     for (int i = 0; i < 10; i++) 
    223     { 
    224       simulateInteraction(element1, interaction1); 
    225       simulateInteraction(element1, interaction2); 
    226       simulateInteraction(element1, interaction3); 
    227     } 
    228     simulateInteraction(element1, interaction6); 
    229     simulateInteraction(element1, interaction5); 
    230     simulateInteraction(element1, interaction4); 
    231      
    232     new TaskTreeChecker().assertTaskTree 
    233       ("Sequence sequence1 {" + 
    234        "  Iteration iteration1 {" + 
    235        "    Sequence sequence2 {" + 
    236        "      Interaction bla {}" + 
    237        "      Interaction bli {}" + 
    238        "      Interaction blup {}" + 
    239        "    }" + 
    240        "  }" + 
    241        "  Interaction ble {}" + 
    242        "  Interaction blo {}" + 
    243        "  Interaction blu {}" + 
    244        "  Iteration iteration2 {" + 
    245        "    Sequence sequence3 {" + 
    246        "      Interaction bla {}" + 
    247        "      Interaction bli {}" + 
    248        "      Interaction blup {}" + 
    249        "    }" + 
    250        "  }" + 
    251        "  Interaction blu {}" + 
    252        "  Interaction blo {}" + 
    253        "  Interaction ble {}" + 
    254        "}", getTaskTree());     
    255    
    256     // now test with iterations of iterations 
    257     for (int i = 0; i < 10; i++) 
    258     { 
    259       for (int j = 0; j < 5; j++) 
    260       { 
    261         simulateInteraction(element1, interaction1); 
    262         simulateInteraction(element1, interaction2); 
    263         simulateInteraction(element1, interaction3); 
    264       } 
    265       for (int j = 0; j < 5; j++) 
    266       { 
    267         simulateInteraction(element1, interaction2); 
    268         simulateInteraction(element1, interaction1); 
    269         simulateInteraction(element1, interaction3); 
    270       } 
    271       for (int j = 0; j < 5; j++) 
    272       { 
    273         simulateInteraction(element1, interaction1); 
    274         simulateInteraction(element1, interaction2); 
    275         simulateInteraction(element1, interaction3); 
    276       } 
    277     } 
    278      
    279     new TaskTreeChecker().assertTaskTree 
    280       ("Sequence sequence1 {" + 
    281        "  Iteration iteration1 {" + 
    282        "    Sequence sequence2 {" + 
    283        "      Interaction bla {}" + 
    284        "      Interaction bli {}" + 
    285        "      Interaction blup {}" + 
    286        "    }" + 
    287        "  }" + 
    288        "  Interaction ble {}" + 
    289        "  Interaction blo {}" + 
    290        "  Interaction blu {}" + 
    291        "  Iteration iteration2 {" + 
    292        "    Sequence sequence3 {" + 
    293        "      Interaction bla {}" + 
    294        "      Interaction bli {}" + 
    295        "      Interaction blup {}" + 
    296        "    }" + 
    297        "  }" + 
    298        "  Interaction blu {}" + 
    299        "  Interaction blo {}" + 
    300        "  Interaction ble {}" + 
    301        "  Iteration iteration3 {" + 
    302        "    Sequence sequence4 {" + 
    303        "      Iteration iteration4 {" + 
    304        "        Sequence sequence4 {" + 
    305        "          Interaction bla {}" + 
    306        "          Interaction bli {}" + 
    307        "          Interaction blup {}" + 
    308        "        }" + 
    309        "      }" + 
    310        "      Iteration iteration5 {" + 
    311        "        Sequence sequence5 {" + 
    312        "          Interaction bli {}" + 
    313        "          Interaction bla {}" + 
    314        "          Interaction blup {}" + 
    315        "        }" + 
    316        "      }" + 
    317        "      Iteration iteration6 {" + 
    318        "        Sequence sequence6 {" + 
    319        "          Interaction bla {}" + 
    320        "          Interaction bli {}" + 
    321        "          Interaction blup {}" + 
    322        "        }" + 
    323        "      }" + 
    324        "    }" + 
    325        "  }" + 
    326        "}", getTaskTree());     
    327   } 
    328    
     306 
    329307} 
  • trunk/quest-core-tasktrees-test/src/test/java/de/ugoe/cs/quest/tasktrees/temporalrelation/DefaultMouseClickReductionRuleTest.java

    r468 r557  
    1 //------------------------------------------------------------------------------------------------- 
    21// Module    : $RCSfile: TaskTreeManagerTest.java,v $ 
    32// Version   : $Revision: 0.0 $  $Author: Patrick $  $Date: 08.11.2011 21:32:36 $ 
     
    54// Creation  : 2011 by Patrick 
    65// Copyright : Patrick Harms, 2011 
    7 //------------------------------------------------------------------------------------------------- 
    86 
    97package de.ugoe.cs.quest.tasktrees.temporalrelation; 
     
    119import org.junit.Test; 
    1210 
    13 import de.ugoe.cs.quest.eventcore.guimodel.GUIElement; 
    14 import de.ugoe.cs.quest.eventcore.userinteraction.MouseButtonDown; 
    15 import de.ugoe.cs.quest.eventcore.userinteraction.MouseButtonInteraction; 
    16 import de.ugoe.cs.quest.eventcore.userinteraction.MouseButtonUp; 
    17 import de.ugoe.cs.quest.eventcore.userinteraction.MouseClick; 
     11import de.ugoe.cs.quest.eventcore.gui.MouseButtonDown; 
     12import de.ugoe.cs.quest.eventcore.gui.MouseButtonInteraction; 
     13import de.ugoe.cs.quest.eventcore.gui.MouseButtonUp; 
     14import de.ugoe.cs.quest.eventcore.gui.MouseClick; 
     15import de.ugoe.cs.quest.eventcore.guimodel.IGUIElement; 
    1816import de.ugoe.cs.quest.tasktrees.testutils.DummyGUIElement; 
    1917import de.ugoe.cs.quest.tasktrees.testutils.DummyInteraction; 
    2018import de.ugoe.cs.quest.tasktrees.testutils.TaskTreeChecker; 
    2119 
    22 //------------------------------------------------------------------------------------------------- 
    2320/** 
    2421 * TODO comment 
    25  * 
     22 *  
    2623 * @version $Revision: $ $Date: $ 
    27  * @author  2011, last modified by $Author: $ 
     24 * @author 2011, last modified by $Author: $ 
    2825 */ 
    29 //------------------------------------------------------------------------------------------------- 
    30 public class DefaultMouseClickReductionRuleTest extends AbstractTemporalRelationshipTC 
    31 { 
    32   //----------------------------------------------------------------------------------------------- 
    33   /** 
    34    * 
    35    */ 
    36   //----------------------------------------------------------------------------------------------- 
    37   @Test 
    38   public void testMouseClickInOneSequenceElement() 
    39   { 
    40     MouseButtonInteraction.Button leftBtn = MouseButtonInteraction.Button.LEFT; 
    41     MouseButtonInteraction.Button middleBtn = MouseButtonInteraction.Button.MIDDLE; 
    42     MouseButtonInteraction.Button rightBtn = MouseButtonInteraction.Button.RIGHT; 
    43      
    44     GUIElement element1 = new DummyGUIElement("elem1"); 
    45     GUIElement element2 = new DummyGUIElement("elem1"); 
    46      
    47     simulateInteraction(element1, new MouseButtonDown(leftBtn)); 
    48     simulateInteraction(element1, new MouseButtonUp(leftBtn)); 
    49     simulateInteraction(element1, new MouseClick(leftBtn)); 
     26public class DefaultMouseClickReductionRuleTest extends AbstractTemporalRelationshipTC { 
    5027 
    51     new TaskTreeChecker().assertTaskTree 
    52       ("Sequence sequence {" + 
    53        "  Interaction LeftMouseClick {}" + 
    54        "}", getTaskTree()); 
    55      
    56     simulateInteraction(element1, new DummyInteraction("bla", 1)); 
    57     simulateInteraction(element1, new DummyInteraction("bli", 1)); 
    58     simulateInteraction(element1, new MouseButtonDown(middleBtn)); 
    59     simulateInteraction(element1, new MouseButtonUp(middleBtn)); 
    60     simulateInteraction(element1, new MouseClick(middleBtn)); 
    61     simulateInteraction(element1, new DummyInteraction("blo", 1)); 
    62     simulateInteraction(element1, new DummyInteraction("blu", 1)); 
     28    /** 
     29     * 
     30     */ 
     31    @Test 
     32    public void testMouseClickInOneSequenceElement() { 
     33        MouseButtonInteraction.Button leftBtn = MouseButtonInteraction.Button.LEFT; 
     34        MouseButtonInteraction.Button middleBtn = MouseButtonInteraction.Button.MIDDLE; 
     35        MouseButtonInteraction.Button rightBtn = MouseButtonInteraction.Button.RIGHT; 
    6336 
    64     new TaskTreeChecker().assertTaskTree 
    65       ("Sequence sequence {" + 
    66        "  Interaction LeftMouseClick {}" + 
    67        "  Interaction bla {}" + 
    68        "  Interaction bli {}" + 
    69        "  Interaction MiddleMouseClick {}" + 
    70        "  Interaction blo {}" + 
    71        "  Interaction blu {}" + 
    72        "}", getTaskTree()); 
     37        IGUIElement element1 = new DummyGUIElement("elem1"); 
     38        IGUIElement element2 = new DummyGUIElement("elem1"); 
    7339 
    74     simulateInteraction(element2, new DummyInteraction("bla", 1)); 
    75     simulateInteraction(element2, new DummyInteraction("bli", 1)); 
    76     simulateInteraction(element2, new MouseButtonDown(rightBtn)); 
    77     simulateInteraction(element2, new MouseButtonUp(rightBtn)); 
    78     simulateInteraction(element2, new MouseClick(rightBtn)); 
    79     simulateInteraction(element2, new DummyInteraction("blo", 1)); 
    80     simulateInteraction(element2, new DummyInteraction("blu", 1)); 
     40        simulateEvent(new MouseButtonDown(leftBtn), element1); 
     41        simulateEvent(new MouseButtonUp(leftBtn), element1); 
     42        simulateEvent(new MouseClick(leftBtn), element1); 
    8143 
    82     new TaskTreeChecker().assertTaskTree 
    83       ("Sequence sequence0 {" + 
    84        "  Sequence sequence1 {" + 
    85        "    Interaction LeftMouseClick {}" + 
    86        "    Interaction bla {}" + 
    87        "    Interaction bli {}" + 
    88        "    Interaction MiddleMouseClick {}" + 
    89        "    Interaction blo {}" + 
    90        "    Interaction blu {}" + 
    91        "  }" + 
    92        "  Sequence sequence2 {" + 
    93        "    Interaction bla {}" + 
    94        "    Interaction bli {}" + 
    95        "    Interaction RightMouseClick {}" + 
    96        "    Interaction blo {}" + 
    97        "    Interaction blu {}" + 
    98        "  }" + 
    99        "}", getTaskTree()); 
     44        new TaskTreeChecker().assertTaskTree 
     45            ("Sequence sequence {" + 
     46             "  Event LeftMouseClick {}" + 
     47             "}", getTaskTree()); 
    10048 
    101     simulateInteraction(element1, new MouseButtonDown(leftBtn)); 
    102     simulateInteraction(element1, new MouseButtonUp(leftBtn)); 
    103     simulateInteraction(element2, new MouseClick(leftBtn)); 
     49        simulateEvent(new DummyInteraction("bla", 1), element1); 
     50        simulateEvent(new DummyInteraction("bli", 1), element1); 
     51        simulateEvent(new MouseButtonDown(middleBtn), element1); 
     52        simulateEvent(new MouseButtonUp(middleBtn), element1); 
     53        simulateEvent(new MouseClick(middleBtn), element1); 
     54        simulateEvent(new DummyInteraction("blo", 1), element1); 
     55        simulateEvent(new DummyInteraction("blu", 1), element1); 
    10456 
    105     new TaskTreeChecker().assertTaskTree 
    106       ("Sequence sequence0 {" + 
    107        "  Sequence sequence1 {" + 
    108        "    Interaction LeftMouseClick {}" + 
    109        "    Interaction bla {}" + 
    110        "    Interaction bli {}" + 
    111        "    Interaction MiddleMouseClick {}" + 
    112        "    Interaction blo {}" + 
    113        "    Interaction blu {}" + 
    114        "  }" + 
    115        "  Sequence sequence2 {" + 
    116        "    Interaction bla {}" + 
    117        "    Interaction bli {}" + 
    118        "    Interaction RightMouseClick {}" + 
    119        "    Interaction blo {}" + 
    120        "    Interaction blu {}" + 
    121        "  }" + 
    122        "  Sequence sequence3 {" + 
    123        "    Interaction LeftMouseButtonDown {}" + 
    124        "    Interaction LeftMouseButtonUp {}" + 
    125        "  }" + 
    126        "  Sequence sequence4 {" + 
    127        "    Interaction LeftMouseClick {}" + 
    128        "  }" + 
    129        "}", getTaskTree()); 
     57        new TaskTreeChecker().assertTaskTree 
     58            ("Sequence sequence {" + 
     59             "  Event LeftMouseClick {}" + 
     60             "  Event bla {}" + 
     61             "  Event bli {}" + 
     62             "  Event MiddleMouseClick {}" + 
     63             "  Event blo {}" + 
     64             "  Event blu {}" + 
     65             "}", getTaskTree()); 
    13066 
    131     simulateInteraction(element1, new MouseButtonDown(middleBtn)); 
    132     simulateInteraction(element1, new MouseButtonUp(middleBtn)); 
    133     simulateInteraction(element1, new MouseClick(rightBtn)); 
    134     simulateInteraction(element2, new DummyInteraction("bla", 1)); 
     67        simulateEvent(new DummyInteraction("bla", 1), element2); 
     68        simulateEvent(new DummyInteraction("bli", 1), element2); 
     69        simulateEvent(new MouseButtonDown(rightBtn), element2); 
     70        simulateEvent(new MouseButtonUp(rightBtn), element2); 
     71        simulateEvent(new MouseClick(rightBtn), element2); 
     72        simulateEvent(new DummyInteraction("blo", 1), element2); 
     73        simulateEvent(new DummyInteraction("blu", 1), element2); 
    13574 
    136     new TaskTreeChecker().assertTaskTree 
    137       ("Sequence sequence0 {" + 
    138        "  Sequence sequence1 {" + 
    139        "    Interaction LeftMouseClick {}" + 
    140        "    Interaction bla {}" + 
    141        "    Interaction bli {}" + 
    142        "    Interaction MiddleMouseClick {}" + 
    143        "    Interaction blo {}" + 
    144        "    Interaction blu {}" + 
    145        "  }" + 
    146        "  Sequence sequence2 {" + 
    147        "    Interaction bla {}" + 
    148        "    Interaction bli {}" + 
    149        "    Interaction RightMouseClick {}" + 
    150        "    Interaction blo {}" + 
    151        "    Interaction blu {}" + 
    152        "  }" + 
    153        "  Sequence sequence3 {" + 
    154        "    Interaction LeftMouseButtonDown {}" + 
    155        "    Interaction LeftMouseButtonUp {}" + 
    156        "  }" + 
    157        "  Sequence sequence4 {" + 
    158        "    Interaction LeftMouseClick {}" + 
    159        "  }" + 
    160        "  Sequence sequence5 {" + 
    161        "    Sequence sequence6 {" + 
    162        "      Interaction MiddleMouseButtonDown {}" + 
    163        "      Interaction MiddleMouseButtonUp {}" + 
    164        "    }" + 
    165        "    Interaction RightMouseClick {}" + 
    166        "  }" + 
    167        "  Sequence sequence7 {" + 
    168        "    Interaction bla {}" + 
    169        "  }" + 
    170        "}", getTaskTree()); 
     75        new TaskTreeChecker().assertTaskTree 
     76            ("Sequence sequence0 {" + 
     77             "  Sequence sequence1 {" + 
     78             "    Event LeftMouseClick {}" + 
     79             "    Event bla {}" + 
     80             "    Event bli {}" + 
     81             "    Event MiddleMouseClick {}" + 
     82             "    Event blo {}" + 
     83             "    Event blu {}" + 
     84             "  }" + 
     85             "  Sequence sequence2 {" + 
     86             "    Event bla {}" + 
     87             "    Event bli {}" + 
     88             "    Event RightMouseClick {}" + 
     89             "    Event blo {}" + 
     90             "    Event blu {}" + 
     91             "  }" + 
     92             "}", getTaskTree()); 
    17193 
    172   } 
    173    
     94        simulateEvent(new MouseButtonDown(leftBtn), element1); 
     95        simulateEvent(new MouseButtonUp(leftBtn), element1); 
     96        simulateEvent(new MouseClick(leftBtn), element2); 
     97 
     98        new TaskTreeChecker().assertTaskTree 
     99            ("Sequence sequence0 {" + 
     100             "  Sequence sequence1 {" + 
     101             "    Event LeftMouseClick {}" + 
     102             "    Event bla {}" + 
     103             "    Event bli {}" + 
     104             "    Event MiddleMouseClick {}" + 
     105             "    Event blo {}" + 
     106             "    Event blu {}" + 
     107             "  }" + 
     108             "  Sequence sequence2 {" + 
     109             "    Event bla {}" + 
     110             "    Event bli {}" + 
     111             "    Event RightMouseClick {}" + 
     112             "    Event blo {}" + 
     113             "    Event blu {}" + 
     114             "  }" + 
     115             "  Sequence sequence3 {" + 
     116             "    Event LeftMouseButtonDown {}" + 
     117             "    Event LeftMouseButtonUp {}" + 
     118             "  }" + 
     119             "  Sequence sequence4 {" + 
     120             "    Event LeftMouseClick {}" + 
     121             "  }" + 
     122             "}", getTaskTree()); 
     123 
     124        simulateEvent(new MouseButtonDown(middleBtn), element1); 
     125        simulateEvent(new MouseButtonUp(middleBtn), element1); 
     126        simulateEvent(new MouseClick(rightBtn), element1); 
     127        simulateEvent(new DummyInteraction("bla", 1), element2); 
     128 
     129        new TaskTreeChecker().assertTaskTree 
     130            ("Sequence sequence0 {" + 
     131             "  Sequence sequence1 {" + 
     132             "    Event LeftMouseClick {}" + 
     133             "    Event bla {}" + 
     134             "    Event bli {}" + 
     135             "    Event MiddleMouseClick {}" + 
     136             "    Event blo {}" + 
     137             "    Event blu {}" + 
     138             "  }" + 
     139             "  Sequence sequence2 {" + 
     140             "    Event bla {}" + 
     141             "    Event bli {}" + 
     142             "    Event RightMouseClick {}" + 
     143             "    Event blo {}" + 
     144             "    Event blu {}" + 
     145             "  }" + 
     146             "  Sequence sequence3 {" + 
     147             "    Event LeftMouseButtonDown {}" + 
     148             "    Event LeftMouseButtonUp {}" + 
     149             "  }" + 
     150             "  Sequence sequence4 {" + 
     151             "    Event LeftMouseClick {}" + 
     152             "  }" + 
     153             "  Sequence sequence5 {" + 
     154             "    Sequence sequence6 {" + 
     155             "      Event MiddleMouseButtonDown {}" + 
     156             "      Event MiddleMouseButtonUp {}" + 
     157             "    }" + 
     158             "    Event RightMouseClick {}" + 
     159             "  }" + 
     160             "  Sequence sequence7 {" + 
     161             "    Event bla {}" + 
     162             "  }" + 
     163             "}", getTaskTree()); 
     164 
     165    } 
     166 
    174167} 
  • trunk/quest-core-tasktrees-test/src/test/java/de/ugoe/cs/quest/tasktrees/temporalrelation/DefaultTextInputReductionRuleTest.java

    r468 r557  
    1 //------------------------------------------------------------------------------------------------- 
    21// Module    : $RCSfile: DefaultIterationDetectionRuleTest.java,v $ 
    32// Version   : $Revision: 0.0 $  $Author: patrick $  $Date: 28.04.2012 $ 
     
    54// Creation  : 2012 by patrick 
    65// Copyright : Patrick Harms, 2012 
    7 //------------------------------------------------------------------------------------------------- 
     6 
    87package de.ugoe.cs.quest.tasktrees.temporalrelation; 
    98 
    109import org.junit.Test; 
    1110 
    12 import de.ugoe.cs.quest.eventcore.guimodel.GUIElement; 
    13 import de.ugoe.cs.quest.eventcore.guimodel.TextField; 
    14 import de.ugoe.cs.quest.eventcore.userinteraction.KeyPressed; 
    15 import de.ugoe.cs.quest.eventcore.userinteraction.KeyReleased; 
     11import de.ugoe.cs.quest.eventcore.gui.KeyPressed; 
     12import de.ugoe.cs.quest.eventcore.gui.KeyReleased; 
     13import de.ugoe.cs.quest.eventcore.guimodel.IGUIElement; 
     14import de.ugoe.cs.quest.eventcore.guimodel.ITextField; 
    1615import de.ugoe.cs.quest.tasktrees.testutils.DummyGUIElement; 
    1716import de.ugoe.cs.quest.tasktrees.testutils.TaskTreeChecker; 
    1817import de.ugoe.cs.tasktree.keyboardmaps.VirtualKey; 
    1918 
    20 //------------------------------------------------------------------------------------------------- 
    2119/** 
    2220 * TODO comment 
     
    2523 * @author 2012, last modified by $Author: patrick$ 
    2624 */ 
    27 //------------------------------------------------------------------------------------------------- 
    28 public class DefaultTextInputReductionRuleTest extends AbstractTemporalRelationshipTC 
    29 { 
    30  
    31   //----------------------------------------------------------------------------------------------- 
    32   /** 
    33    * 
    34    */ 
    35   //----------------------------------------------------------------------------------------------- 
    36   @Test 
    37   public void testSimpleTextEntry() 
    38   { 
    39     GUIElement element1 = new DummyTextField("elem1"); 
    40     simulateInteraction(element1, new KeyPressed(VirtualKey.LETTER_A)); 
    41     simulateInteraction(element1, new KeyReleased(VirtualKey.LETTER_A)); 
    42     new TaskTreeChecker(true).assertTaskTree 
    43       ("Sequence sequence0 {" + 
    44        "  TextInputInteraction TextInput a {" + 
    45        "    Interaction KeyPressed LETTER_A {}" + 
    46        "    Interaction KeyReleased LETTER_A {}" + 
    47        "  }" + 
    48        "}", getTaskTree());     
    49  
    50     simulateInteraction(element1, new KeyPressed(VirtualKey.LETTER_B)); 
    51     simulateInteraction(element1, new KeyReleased(VirtualKey.LETTER_B)); 
    52     new TaskTreeChecker().assertTaskTree 
    53       ("Sequence sequence0 {" + 
    54        "  TextInputInteraction TextInput ab {" + 
    55        "    Interaction KeyPressed LETTER_A {}" + 
    56        "    Interaction KeyReleased LETTER_A {}" + 
    57        "    Interaction KeyPressed LETTER_B {}" + 
    58        "    Interaction KeyReleased LETTER_B {}" + 
    59        "  }" + 
    60        "}", getTaskTree());     
    61  
    62     simulateInteraction(element1, new KeyPressed(VirtualKey.SHIFT)); 
    63     simulateInteraction(element1, new KeyPressed(VirtualKey.LETTER_C)); 
    64     simulateInteraction(element1, new KeyReleased(VirtualKey.LETTER_C)); 
    65     simulateInteraction(element1, new KeyReleased(VirtualKey.SHIFT)); 
    66     new TaskTreeChecker().assertTaskTree 
    67       ("Sequence sequence0 {" + 
    68        "  TextInputInteraction TextInput abC {" + 
    69        "    Interaction KeyPressed LETTER_A {}" + 
    70        "    Interaction KeyReleased LETTER_A {}" + 
    71        "    Interaction KeyPressed LETTER_B {}" + 
    72        "    Interaction KeyReleased LETTER_B {}" + 
    73        "    Interaction KeyPressed SHIFT {}" + 
    74        "    Interaction KeyPressed LETTER_C {}" + 
    75        "    Interaction KeyReleased LETTER_C {}" + 
    76        "    Interaction KeyReleased SHIFT {}" + 
    77        "  }" + 
    78        "}", getTaskTree());     
    79  
    80     simulateInteraction(element1, new KeyPressed(VirtualKey.SHIFT)); 
    81     simulateInteraction(element1, new KeyPressed(VirtualKey.LETTER_D)); 
    82     simulateInteraction(element1, new KeyReleased(VirtualKey.LETTER_D)); 
    83     simulateInteraction(element1, new KeyPressed(VirtualKey.LETTER_E)); 
    84     simulateInteraction(element1, new KeyReleased(VirtualKey.LETTER_E)); 
    85     simulateInteraction(element1, new KeyPressed(VirtualKey.LETTER_F)); 
    86     simulateInteraction(element1, new KeyReleased(VirtualKey.LETTER_F)); 
    87     simulateInteraction(element1, new KeyReleased(VirtualKey.SHIFT)); 
    88     new TaskTreeChecker().assertTaskTree 
    89       ("Sequence sequence0 {" + 
    90        "  TextInputInteraction TextInput abCDEF {" + 
    91        "    Interaction KeyPressed LETTER_A {}" + 
    92        "    Interaction KeyReleased LETTER_A {}" + 
    93        "    Interaction KeyPressed LETTER_B {}" + 
    94        "    Interaction KeyReleased LETTER_B {}" + 
    95        "    Interaction KeyPressed SHIFT {}" + 
    96        "    Interaction KeyPressed LETTER_C {}" + 
    97        "    Interaction KeyReleased LETTER_C {}" + 
    98        "    Interaction KeyReleased SHIFT {}" + 
    99        "    Interaction KeyPressed SHIFT {}" + 
    100        "    Interaction KeyPressed LETTER_D {}" + 
    101        "    Interaction KeyReleased LETTER_D {}" + 
    102        "    Interaction KeyPressed LETTER_E {}" + 
    103        "    Interaction KeyReleased LETTER_E {}" + 
    104        "    Interaction KeyPressed LETTER_F {}" + 
    105        "    Interaction KeyReleased LETTER_F {}" + 
    106        "    Interaction KeyReleased SHIFT {}" + 
    107        "  }" + 
    108        "}", getTaskTree());     
    109  
    110  
    111     simulateInteraction(element1, new KeyPressed(VirtualKey.SHIFT)); 
    112     simulateInteraction(element1, new KeyPressed(VirtualKey.SHIFT)); 
    113     simulateInteraction(element1, new KeyPressed(VirtualKey.LETTER_G)); 
    114     simulateInteraction(element1, new KeyReleased(VirtualKey.LETTER_G)); 
    115     simulateInteraction(element1, new KeyReleased(VirtualKey.SHIFT)); 
    116     simulateInteraction(element1, new KeyReleased(VirtualKey.SHIFT)); 
    117     new TaskTreeChecker().assertTaskTree 
    118       ("Sequence sequence0 {" + 
    119        "  TextInputInteraction TextInput abCDEFg {" + 
    120        "    Interaction KeyPressed LETTER_A {}" + 
    121        "    Interaction KeyReleased LETTER_A {}" + 
    122        "    Interaction KeyPressed LETTER_B {}" + 
    123        "    Interaction KeyReleased LETTER_B {}" + 
    124        "    Interaction KeyPressed SHIFT {}" + 
    125        "    Interaction KeyPressed LETTER_C {}" + 
    126        "    Interaction KeyReleased LETTER_C {}" + 
    127        "    Interaction KeyReleased SHIFT {}" + 
    128        "    Interaction KeyPressed SHIFT {}" + 
    129        "    Interaction KeyPressed LETTER_D {}" + 
    130        "    Interaction KeyReleased LETTER_D {}" + 
    131        "    Interaction KeyPressed LETTER_E {}" + 
    132        "    Interaction KeyReleased LETTER_E {}" + 
    133        "    Interaction KeyPressed LETTER_F {}" + 
    134        "    Interaction KeyReleased LETTER_F {}" + 
    135        "    Interaction KeyReleased SHIFT {}" + 
    136        "    Interaction KeyPressed SHIFT {}" + 
    137        "    Interaction KeyPressed SHIFT {}" + 
    138        "    Interaction KeyPressed LETTER_G {}" + 
    139        "    Interaction KeyReleased LETTER_G {}" + 
    140        "    Interaction KeyReleased SHIFT {}" + 
    141        "    Interaction KeyReleased SHIFT {}" + 
    142        "  }" + 
    143        "}", getTaskTree());     
    144  
    145   } 
    146    
    147   //----------------------------------------------------------------------------------------------- 
    148   /** 
    149    * 
    150    */ 
    151   //----------------------------------------------------------------------------------------------- 
    152   @Test 
    153   public void testTextEntryOnDifferentGuiElements() 
    154   { 
    155     GUIElement element1 = new DummyTextField("elem1"); 
    156     GUIElement element2 = new DummyTextField("elem2"); 
    157     simulateInteraction(element1, new KeyPressed(VirtualKey.LETTER_A)); 
    158     simulateInteraction(element1, new KeyReleased(VirtualKey.LETTER_A)); 
    159     new TaskTreeChecker().assertTaskTree 
    160       ("Sequence sequence0 {" + 
    161        "  TextInputInteraction TextInput a {" + 
    162        "    Interaction KeyPressed LETTER_A {}" + 
    163        "    Interaction KeyReleased LETTER_A {}" + 
    164        "  }" + 
    165        "}", getTaskTree());     
    166  
    167     simulateInteraction(element2, new KeyPressed(VirtualKey.LETTER_B)); 
    168     simulateInteraction(element2, new KeyReleased(VirtualKey.LETTER_B)); 
    169     new TaskTreeChecker().assertTaskTree 
    170       ("Sequence sequence0 {" + 
    171        "  Sequence sequence1 {" + 
    172        "    TextInputInteraction TextInput a {" + 
    173        "      Interaction KeyPressed LETTER_A {}" + 
    174        "      Interaction KeyReleased LETTER_A {}" + 
    175        "    }" + 
    176        "  }" + 
    177        "  Sequence sequence2 {" + 
    178        "    TextInputInteraction TextInput b {" + 
    179        "      Interaction KeyPressed LETTER_B {}" + 
    180        "      Interaction KeyReleased LETTER_B {}" + 
    181        "    }" + 
    182        "  }" + 
    183        "}", getTaskTree());     
    184  
    185     simulateInteraction(element1, new KeyPressed(VirtualKey.SHIFT)); 
    186     simulateInteraction(element1, new KeyPressed(VirtualKey.LETTER_C)); 
    187     simulateInteraction(element1, new KeyReleased(VirtualKey.LETTER_C)); 
    188     simulateInteraction(element1, new KeyReleased(VirtualKey.SHIFT)); 
    189     new TaskTreeChecker().assertTaskTree 
    190       ("Sequence sequence0 {" + 
    191        "  Sequence sequence1 {" + 
    192        "    TextInputInteraction TextInput a {" + 
    193        "      Interaction KeyPressed LETTER_A {}" + 
    194        "      Interaction KeyReleased LETTER_A {}" + 
    195        "    }" + 
    196        "  }" + 
    197        "  Sequence sequence2 {" + 
    198        "    TextInputInteraction TextInput b {" + 
    199        "      Interaction KeyPressed LETTER_B {}" + 
    200        "      Interaction KeyReleased LETTER_B {}" + 
    201        "    }" + 
    202        "  }" + 
    203        "  Sequence sequence3 {" + 
    204        "    TextInputInteraction TextInput C {" + 
    205        "      Interaction KeyPressed SHIFT {}" + 
    206        "      Interaction KeyPressed LETTER_C {}" + 
    207        "      Interaction KeyReleased LETTER_C {}" + 
    208        "      Interaction KeyReleased SHIFT {}" + 
    209        "    }" + 
    210        "  }" + 
    211        "}", getTaskTree());     
    212  
    213     simulateInteraction(element2, new KeyPressed(VirtualKey.SHIFT)); 
    214     simulateInteraction(element2, new KeyPressed(VirtualKey.LETTER_D)); 
    215     simulateInteraction(element2, new KeyReleased(VirtualKey.LETTER_D)); 
    216     simulateInteraction(element2, new KeyPressed(VirtualKey.LETTER_E)); 
    217     simulateInteraction(element2, new KeyReleased(VirtualKey.LETTER_E)); 
    218     simulateInteraction(element2, new KeyPressed(VirtualKey.LETTER_F)); 
    219     simulateInteraction(element2, new KeyReleased(VirtualKey.LETTER_F)); 
    220     simulateInteraction(element2, new KeyReleased(VirtualKey.SHIFT)); 
    221     new TaskTreeChecker().assertTaskTree 
    222       ("Sequence sequence0 {" + 
    223        "  Sequence sequence1 {" + 
    224        "    TextInputInteraction TextInput a {" + 
    225        "      Interaction KeyPressed LETTER_A {}" + 
    226        "      Interaction KeyReleased LETTER_A {}" + 
    227        "    }" + 
    228        "  }" + 
    229        "  Sequence sequence2 {" + 
    230        "    TextInputInteraction TextInput b {" + 
    231        "      Interaction KeyPressed LETTER_B {}" + 
    232        "      Interaction KeyReleased LETTER_B {}" + 
    233        "    }" + 
    234        "  }" + 
    235        "  Sequence sequence3 {" + 
    236        "    TextInputInteraction TextInput C {" + 
    237        "      Interaction KeyPressed SHIFT {}" + 
    238        "      Interaction KeyPressed LETTER_C {}" + 
    239        "      Interaction KeyReleased LETTER_C {}" + 
    240        "      Interaction KeyReleased SHIFT {}" + 
    241        "    }" + 
    242        "  }" + 
    243        "  Sequence sequence4 {" + 
    244        "    TextInputInteraction TextInput DEF {" + 
    245        "      Interaction KeyPressed SHIFT {}" + 
    246        "      Interaction KeyPressed LETTER_D {}" + 
    247        "      Interaction KeyReleased LETTER_D {}" + 
    248        "      Interaction KeyPressed LETTER_E {}" + 
    249        "      Interaction KeyReleased LETTER_E {}" + 
    250        "      Interaction KeyPressed LETTER_F {}" + 
    251        "      Interaction KeyReleased LETTER_F {}" + 
    252        "      Interaction KeyReleased SHIFT {}" + 
    253        "    }" + 
    254        "  }" + 
    255        "}", getTaskTree());     
    256  
    257  
    258     simulateInteraction(element1, new KeyPressed(VirtualKey.SHIFT)); 
    259     simulateInteraction(element1, new KeyPressed(VirtualKey.SHIFT)); 
    260     simulateInteraction(element1, new KeyPressed(VirtualKey.LETTER_G)); 
    261     simulateInteraction(element1, new KeyReleased(VirtualKey.LETTER_G)); 
    262     simulateInteraction(element1, new KeyReleased(VirtualKey.SHIFT)); 
    263     simulateInteraction(element1, new KeyReleased(VirtualKey.SHIFT)); 
    264     new TaskTreeChecker().assertTaskTree 
    265       ("Sequence sequence0 {" + 
    266        "  Sequence sequence1 {" + 
    267        "    TextInputInteraction TextInput a {" + 
    268        "      Interaction KeyPressed LETTER_A {}" + 
    269        "      Interaction KeyReleased LETTER_A {}" + 
    270        "    }" + 
    271        "  }" + 
    272        "  Sequence sequence2 {" + 
    273        "    TextInputInteraction TextInput b {" + 
    274        "      Interaction KeyPressed LETTER_B {}" + 
    275        "      Interaction KeyReleased LETTER_B {}" + 
    276        "    }" + 
    277        "  }" + 
    278        "  Sequence sequence3 {" + 
    279        "    TextInputInteraction TextInput C {" + 
    280        "      Interaction KeyPressed SHIFT {}" + 
    281        "      Interaction KeyPressed LETTER_C {}" + 
    282        "      Interaction KeyReleased LETTER_C {}" + 
    283        "      Interaction KeyReleased SHIFT {}" + 
    284        "    }" + 
    285        "  }" + 
    286        "  Sequence sequence4 {" + 
    287        "    TextInputInteraction TextInput DEF {" + 
    288        "      Interaction KeyPressed SHIFT {}" + 
    289        "      Interaction KeyPressed LETTER_D {}" + 
    290        "      Interaction KeyReleased LETTER_D {}" + 
    291        "      Interaction KeyPressed LETTER_E {}" + 
    292        "      Interaction KeyReleased LETTER_E {}" + 
    293        "      Interaction KeyPressed LETTER_F {}" + 
    294        "      Interaction KeyReleased LETTER_F {}" + 
    295        "      Interaction KeyReleased SHIFT {}" + 
    296        "    }" + 
    297        "  }" + 
    298        "  Sequence sequence5 {" + 
    299        "    TextInputInteraction TextInput g {" + 
    300        "      Interaction KeyPressed SHIFT {}" + 
    301        "      Interaction KeyPressed SHIFT {}" + 
    302        "      Interaction KeyPressed LETTER_G {}" + 
    303        "      Interaction KeyReleased LETTER_G {}" + 
    304        "      Interaction KeyReleased SHIFT {}" + 
    305        "      Interaction KeyReleased SHIFT {}" + 
    306        "    }" + 
    307        "  }" + 
    308        "}", getTaskTree());     
    309  
    310   } 
    311    
    312   //----------------------------------------------------------------------------------------------- 
    313   /** 
    314    * 
    315    */ 
    316   //----------------------------------------------------------------------------------------------- 
    317   @Test 
    318   public void testUsageOfBackspace() 
    319   { 
    320     GUIElement element1 = new DummyTextField("elem1"); 
    321     simulateInteraction(element1, new KeyPressed(VirtualKey.LETTER_A)); 
    322     simulateInteraction(element1, new KeyReleased(VirtualKey.LETTER_A)); 
    323     simulateInteraction(element1, new KeyPressed(VirtualKey.LETTER_B)); 
    324     simulateInteraction(element1, new KeyReleased(VirtualKey.LETTER_B)); 
    325     simulateInteraction(element1, new KeyPressed(VirtualKey.LETTER_C)); 
    326     simulateInteraction(element1, new KeyReleased(VirtualKey.LETTER_C)); 
    327     simulateInteraction(element1, new KeyPressed(VirtualKey.LETTER_D)); 
    328     simulateInteraction(element1, new KeyReleased(VirtualKey.LETTER_D)); 
    329     simulateInteraction(element1, new KeyPressed(VirtualKey.BACK_SPACE)); 
    330     simulateInteraction(element1, new KeyReleased(VirtualKey.BACK_SPACE)); 
    331     simulateInteraction(element1, new KeyPressed(VirtualKey.LETTER_E)); 
    332     simulateInteraction(element1, new KeyReleased(VirtualKey.LETTER_E)); 
    333     simulateInteraction(element1, new KeyPressed(VirtualKey.LETTER_F)); 
    334     simulateInteraction(element1, new KeyReleased(VirtualKey.LETTER_F)); 
    335     new TaskTreeChecker().assertTaskTree 
    336       ("Sequence sequence0 {" + 
    337        "  TextInputInteraction TextInput abcef {" + 
    338        "    Interaction KeyPressed LETTER_A {}" + 
    339        "    Interaction KeyReleased LETTER_A {}" + 
    340        "    Interaction KeyPressed LETTER_B {}" + 
    341        "    Interaction KeyReleased LETTER_B {}" + 
    342        "    Interaction KeyPressed LETTER_C {}" + 
    343        "    Interaction KeyReleased LETTER_C {}" + 
    344        "    Interaction KeyPressed LETTER_D {}" + 
    345        "    Interaction KeyReleased LETTER_D {}" + 
    346        "    Interaction KeyPressed BACK_SPACE {}" + 
    347        "    Interaction KeyReleased BACK_SPACE {}" + 
    348        "    Interaction KeyPressed LETTER_E {}" + 
    349        "    Interaction KeyReleased LETTER_E {}" + 
    350        "    Interaction KeyPressed LETTER_F {}" + 
    351        "    Interaction KeyReleased LETTER_F {}" + 
    352        "  }" + 
    353        "}", getTaskTree());     
    354  
    355     simulateInteraction(element1, new KeyPressed(VirtualKey.BACK_SPACE)); 
    356     simulateInteraction(element1, new KeyReleased(VirtualKey.BACK_SPACE)); 
    357     simulateInteraction(element1, new KeyPressed(VirtualKey.BACK_SPACE)); 
    358     simulateInteraction(element1, new KeyReleased(VirtualKey.BACK_SPACE)); 
    359     simulateInteraction(element1, new KeyPressed(VirtualKey.BACK_SPACE)); 
    360     simulateInteraction(element1, new KeyReleased(VirtualKey.BACK_SPACE)); 
    361     new TaskTreeChecker().assertTaskTree 
    362       ("Sequence sequence0 {" + 
    363        "  TextInputInteraction TextInput ab {" + 
    364        "    Interaction KeyPressed LETTER_A {}" + 
    365        "    Interaction KeyReleased LETTER_A {}" + 
    366        "    Interaction KeyPressed LETTER_B {}" + 
    367        "    Interaction KeyReleased LETTER_B {}" + 
    368        "    Interaction KeyPressed LETTER_C {}" + 
    369        "    Interaction KeyReleased LETTER_C {}" + 
    370        "    Interaction KeyPressed LETTER_D {}" + 
    371        "    Interaction KeyReleased LETTER_D {}" + 
    372        "    Interaction KeyPressed BACK_SPACE {}" + 
    373        "    Interaction KeyReleased BACK_SPACE {}" + 
    374        "    Interaction KeyPressed LETTER_E {}" + 
    375        "    Interaction KeyReleased LETTER_E {}" + 
    376        "    Interaction KeyPressed LETTER_F {}" + 
    377        "    Interaction KeyReleased LETTER_F {}" + 
    378        "    Interaction KeyPressed BACK_SPACE {}" + 
    379        "    Interaction KeyReleased BACK_SPACE {}" + 
    380        "    Interaction KeyPressed BACK_SPACE {}" + 
    381        "    Interaction KeyReleased BACK_SPACE {}" + 
    382        "    Interaction KeyPressed BACK_SPACE {}" + 
    383        "    Interaction KeyReleased BACK_SPACE {}" + 
    384        "  }" + 
    385        "}", getTaskTree());     
    386  
    387   } 
    388    
    389   //----------------------------------------------------------------------------------------------- 
    390   /** 
    391    * 
    392    */ 
    393   //----------------------------------------------------------------------------------------------- 
    394   private static class DummyTextField extends DummyGUIElement implements TextField 
    395   { 
    396  
    397     //--------------------------------------------------------------------------------------------- 
     25public class DefaultTextInputReductionRuleTest extends AbstractTemporalRelationshipTC { 
     26 
    39827    /** 
    399      * TODO: comment 
    40028     * 
    401      * @param name 
    40229     */ 
    403     //--------------------------------------------------------------------------------------------- 
    404     public DummyTextField(String name) 
    405     { 
    406       super(name); 
     30    @Test 
     31    public void testSimpleTextEntry() { 
     32        IGUIElement element1 = new DummyTextField("elem1"); 
     33        simulateEvent(new KeyPressed(VirtualKey.LETTER_A), element1); 
     34        simulateEvent(new KeyReleased(VirtualKey.LETTER_A), element1); 
     35        new TaskTreeChecker(true).assertTaskTree 
     36            ("Sequence sequence0 {" + 
     37             "  TextInputEvent TextInput a {" + 
     38             "    Event KeyPressed LETTER_A {}" + 
     39             "    Event KeyReleased LETTER_A {}" + 
     40             "  }" + 
     41             "}", getTaskTree()); 
     42 
     43        simulateEvent(new KeyPressed(VirtualKey.LETTER_B), element1); 
     44        simulateEvent(new KeyReleased(VirtualKey.LETTER_B), element1); 
     45        new TaskTreeChecker().assertTaskTree 
     46            ("Sequence sequence0 {" + 
     47             "  TextInputEvent TextInput ab {" + 
     48             "    Event KeyPressed LETTER_A {}" + 
     49             "    Event KeyReleased LETTER_A {}" + 
     50             "    Event KeyPressed LETTER_B {}" + 
     51             "    Event KeyReleased LETTER_B {}" + 
     52             "  }" + 
     53             "}", getTaskTree()); 
     54 
     55        simulateEvent(new KeyPressed(VirtualKey.SHIFT), element1); 
     56        simulateEvent(new KeyPressed(VirtualKey.LETTER_C), element1); 
     57        simulateEvent(new KeyReleased(VirtualKey.LETTER_C), element1); 
     58        simulateEvent(new KeyReleased(VirtualKey.SHIFT), element1); 
     59        new TaskTreeChecker().assertTaskTree 
     60            ("Sequence sequence0 {" + 
     61             "  TextInputEvent TextInput abC {" + 
     62             "    Event KeyPressed LETTER_A {}" + 
     63             "    Event KeyReleased LETTER_A {}" + 
     64             "    Event KeyPressed LETTER_B {}" + 
     65             "    Event KeyReleased LETTER_B {}" + 
     66             "    Event KeyPressed SHIFT {}" + 
     67             "    Event KeyPressed LETTER_C {}" + 
     68             "    Event KeyReleased LETTER_C {}" + 
     69             "    Event KeyReleased SHIFT {}" + 
     70             "  }" + 
     71             "}", getTaskTree()); 
     72 
     73        simulateEvent(new KeyPressed(VirtualKey.SHIFT), element1); 
     74        simulateEvent(new KeyPressed(VirtualKey.LETTER_D), element1); 
     75        simulateEvent(new KeyReleased(VirtualKey.LETTER_D), element1); 
     76        simulateEvent(new KeyPressed(VirtualKey.LETTER_E), element1); 
     77        simulateEvent(new KeyReleased(VirtualKey.LETTER_E), element1); 
     78        simulateEvent(new KeyPressed(VirtualKey.LETTER_F), element1); 
     79        simulateEvent(new KeyReleased(VirtualKey.LETTER_F), element1); 
     80        simulateEvent(new KeyReleased(VirtualKey.SHIFT), element1); 
     81        new TaskTreeChecker().assertTaskTree 
     82            ("Sequence sequence0 {" + 
     83             "  TextInputEvent TextInput abCDEF {" + 
     84             "    Event KeyPressed LETTER_A {}" + 
     85             "    Event KeyReleased LETTER_A {}" + 
     86             "    Event KeyPressed LETTER_B {}" + 
     87             "    Event KeyReleased LETTER_B {}" + 
     88             "    Event KeyPressed SHIFT {}" + 
     89             "    Event KeyPressed LETTER_C {}" + 
     90             "    Event KeyReleased LETTER_C {}" + 
     91             "    Event KeyReleased SHIFT {}" + 
     92             "    Event KeyPressed SHIFT {}" + 
     93             "    Event KeyPressed LETTER_D {}" + 
     94             "    Event KeyReleased LETTER_D {}" + 
     95             "    Event KeyPressed LETTER_E {}" + 
     96             "    Event KeyReleased LETTER_E {}" + 
     97             "    Event KeyPressed LETTER_F {}" + 
     98             "    Event KeyReleased LETTER_F {}" + 
     99             "    Event KeyReleased SHIFT {}" + 
     100             "  }" + 
     101             "}", getTaskTree()); 
     102 
     103        simulateEvent(new KeyPressed(VirtualKey.SHIFT), element1); 
     104        simulateEvent(new KeyPressed(VirtualKey.SHIFT), element1); 
     105        simulateEvent(new KeyPressed(VirtualKey.LETTER_G), element1); 
     106        simulateEvent(new KeyReleased(VirtualKey.LETTER_G), element1); 
     107        simulateEvent(new KeyReleased(VirtualKey.SHIFT), element1); 
     108        simulateEvent(new KeyReleased(VirtualKey.SHIFT), element1); 
     109        new TaskTreeChecker().assertTaskTree 
     110            ("Sequence sequence0 {" + 
     111             "  TextInputEvent TextInput abCDEFg {" + 
     112             "    Event KeyPressed LETTER_A {}" + 
     113             "    Event KeyReleased LETTER_A {}" + 
     114             "    Event KeyPressed LETTER_B {}" + 
     115             "    Event KeyReleased LETTER_B {}" + 
     116             "    Event KeyPressed SHIFT {}" + 
     117             "    Event KeyPressed LETTER_C {}" + 
     118             "    Event KeyReleased LETTER_C {}" + 
     119             "    Event KeyReleased SHIFT {}" + 
     120             "    Event KeyPressed SHIFT {}" + 
     121             "    Event KeyPressed LETTER_D {}" + 
     122             "    Event KeyReleased LETTER_D {}" + 
     123             "    Event KeyPressed LETTER_E {}" + 
     124             "    Event KeyReleased LETTER_E {}" + 
     125             "    Event KeyPressed LETTER_F {}" + 
     126             "    Event KeyReleased LETTER_F {}" + 
     127             "    Event KeyReleased SHIFT {}" + 
     128             "    Event KeyPressed SHIFT {}" + 
     129             "    Event KeyPressed SHIFT {}" + 
     130             "    Event KeyPressed LETTER_G {}" + 
     131             "    Event KeyReleased LETTER_G {}" + 
     132             "    Event KeyReleased SHIFT {}" + 
     133             "    Event KeyReleased SHIFT {}" + 
     134             "  }" + 
     135             "}", getTaskTree()); 
     136 
    407137    } 
    408138 
    409   } 
     139    /** 
     140     * 
     141     */ 
     142    @Test 
     143    public void testTextEntryOnDifferentGuiElements() { 
     144        IGUIElement element1 = new DummyTextField("elem1"); 
     145        IGUIElement element2 = new DummyTextField("elem2"); 
     146        simulateEvent(new KeyPressed(VirtualKey.LETTER_A), element1); 
     147        simulateEvent(new KeyReleased(VirtualKey.LETTER_A), element1); 
     148        new TaskTreeChecker().assertTaskTree 
     149            ("Sequence sequence0 {" + 
     150             "  TextInputEvent TextInput a {" + 
     151             "    Event KeyPressed LETTER_A {}" + 
     152             "    Event KeyReleased LETTER_A {}" + 
     153             "  }" + 
     154             "}", getTaskTree()); 
     155 
     156        simulateEvent(new KeyPressed(VirtualKey.LETTER_B), element2); 
     157        simulateEvent(new KeyReleased(VirtualKey.LETTER_B), element2); 
     158        new TaskTreeChecker().assertTaskTree 
     159            ("Sequence sequence0 {" + 
     160             "  Sequence sequence1 {" + 
     161             "    TextInputEvent TextInput a {" + 
     162             "      Event KeyPressed LETTER_A {}" + 
     163             "      Event KeyReleased LETTER_A {}" + 
     164             "    }" + 
     165             "  }" + 
     166             "  Sequence sequence2 {" + 
     167             "    TextInputEvent TextInput b {" + 
     168             "      Event KeyPressed LETTER_B {}" + 
     169             "      Event KeyReleased LETTER_B {}" + 
     170             "    }" + 
     171             "  }" + 
     172             "}", getTaskTree()); 
     173 
     174        simulateEvent(new KeyPressed(VirtualKey.SHIFT), element1); 
     175        simulateEvent(new KeyPressed(VirtualKey.LETTER_C), element1); 
     176        simulateEvent(new KeyReleased(VirtualKey.LETTER_C), element1); 
     177        simulateEvent(new KeyReleased(VirtualKey.SHIFT), element1); 
     178        new TaskTreeChecker().assertTaskTree 
     179            ("Sequence sequence0 {" + 
     180             "  Sequence sequence1 {" + 
     181             "    TextInputEvent TextInput a {" + 
     182             "      Event KeyPressed LETTER_A {}" + 
     183             "      Event KeyReleased LETTER_A {}" + 
     184             "    }" + 
     185             "  }" + 
     186             "  Sequence sequence2 {" + 
     187             "    TextInputEvent TextInput b {" + 
     188             "      Event KeyPressed LETTER_B {}" + 
     189             "      Event KeyReleased LETTER_B {}" + 
     190             "    }" + 
     191             "  }" + 
     192             "  Sequence sequence3 {" + 
     193             "    TextInputEvent TextInput C {" + 
     194             "      Event KeyPressed SHIFT {}" + 
     195             "      Event KeyPressed LETTER_C {}" + 
     196             "      Event KeyReleased LETTER_C {}" + 
     197             "      Event KeyReleased SHIFT {}" + 
     198             "    }" + 
     199             "  }" + 
     200             "}", getTaskTree()); 
     201 
     202        simulateEvent(new KeyPressed(VirtualKey.SHIFT), element2); 
     203        simulateEvent(new KeyPressed(VirtualKey.LETTER_D), element2); 
     204        simulateEvent(new KeyReleased(VirtualKey.LETTER_D), element2); 
     205        simulateEvent(new KeyPressed(VirtualKey.LETTER_E), element2); 
     206        simulateEvent(new KeyReleased(VirtualKey.LETTER_E), element2); 
     207        simulateEvent(new KeyPressed(VirtualKey.LETTER_F), element2); 
     208        simulateEvent(new KeyReleased(VirtualKey.LETTER_F), element2); 
     209        simulateEvent(new KeyReleased(VirtualKey.SHIFT), element2); 
     210        new TaskTreeChecker().assertTaskTree 
     211            ("Sequence sequence0 {" + 
     212             "  Sequence sequence1 {" + 
     213             "    TextInputEvent TextInput a {" + 
     214             "      Event KeyPressed LETTER_A {}" + 
     215             "      Event KeyReleased LETTER_A {}" + 
     216             "    }" + 
     217             "  }" + 
     218             "  Sequence sequence2 {" + 
     219             "    TextInputEvent TextInput b {" + 
     220             "      Event KeyPressed LETTER_B {}" + 
     221             "      Event KeyReleased LETTER_B {}" + 
     222             "    }" + 
     223             "  }" + 
     224             "  Sequence sequence3 {" + 
     225             "    TextInputEvent TextInput C {" + 
     226             "      Event KeyPressed SHIFT {}" + 
     227             "      Event KeyPressed LETTER_C {}" + 
     228             "      Event KeyReleased LETTER_C {}" + 
     229             "      Event KeyReleased SHIFT {}" + 
     230             "    }" + 
     231             "  }" + 
     232             "  Sequence sequence4 {" + 
     233             "    TextInputEvent TextInput DEF {" + 
     234             "      Event KeyPressed SHIFT {}" + 
     235             "      Event KeyPressed LETTER_D {}" + 
     236             "      Event KeyReleased LETTER_D {}" + 
     237             "      Event KeyPressed LETTER_E {}" + 
     238             "      Event KeyReleased LETTER_E {}" + 
     239             "      Event KeyPressed LETTER_F {}" + 
     240             "      Event KeyReleased LETTER_F {}" + 
     241             "      Event KeyReleased SHIFT {}" + 
     242             "    }" + 
     243             "  }" + 
     244             "}", getTaskTree()); 
     245 
     246        simulateEvent(new KeyPressed(VirtualKey.SHIFT), element1); 
     247        simulateEvent(new KeyPressed(VirtualKey.SHIFT), element1); 
     248        simulateEvent(new KeyPressed(VirtualKey.LETTER_G), element1); 
     249        simulateEvent(new KeyReleased(VirtualKey.LETTER_G), element1); 
     250        simulateEvent(new KeyReleased(VirtualKey.SHIFT), element1); 
     251        simulateEvent(new KeyReleased(VirtualKey.SHIFT), element1); 
     252        new TaskTreeChecker().assertTaskTree 
     253            ("Sequence sequence0 {" + 
     254             "  Sequence sequence1 {" + 
     255             "    TextInputEvent TextInput a {" + 
     256             "      Event KeyPressed LETTER_A {}" + 
     257             "      Event KeyReleased LETTER_A {}" + 
     258             "    }" + 
     259             "  }" + 
     260             "  Sequence sequence2 {" + 
     261             "    TextInputEvent TextInput b {" + 
     262             "      Event KeyPressed LETTER_B {}" + 
     263             "      Event KeyReleased LETTER_B {}" + 
     264             "    }" + 
     265             "  }" + 
     266             "  Sequence sequence3 {" + 
     267             "    TextInputEvent TextInput C {" + 
     268             "      Event KeyPressed SHIFT {}" + 
     269             "      Event KeyPressed LETTER_C {}" + 
     270             "      Event KeyReleased LETTER_C {}" + 
     271             "      Event KeyReleased SHIFT {}" + 
     272             "    }" + 
     273             "  }" + 
     274             "  Sequence sequence4 {" + 
     275             "    TextInputEvent TextInput DEF {" + 
     276             "      Event KeyPressed SHIFT {}" + 
     277             "      Event KeyPressed LETTER_D {}" + 
     278             "      Event KeyReleased LETTER_D {}" + 
     279             "      Event KeyPressed LETTER_E {}" + 
     280             "      Event KeyReleased LETTER_E {}" + 
     281             "      Event KeyPressed LETTER_F {}" + 
     282             "      Event KeyReleased LETTER_F {}" + 
     283             "      Event KeyReleased SHIFT {}" + 
     284             "    }" + 
     285             "  }" + 
     286             "  Sequence sequence5 {" + 
     287             "    TextInputEvent TextInput g {" + 
     288             "      Event KeyPressed SHIFT {}" + 
     289             "      Event KeyPressed SHIFT {}" + 
     290             "      Event KeyPressed LETTER_G {}" + 
     291             "      Event KeyReleased LETTER_G {}" + 
     292             "      Event KeyReleased SHIFT {}" + 
     293             "      Event KeyReleased SHIFT {}" + 
     294             "    }" + 
     295             "  }" + 
     296             "}", getTaskTree()); 
     297 
     298    } 
     299 
     300    /** 
     301     * 
     302     */ 
     303    @Test 
     304    public void testUsageOfBackspace() { 
     305        IGUIElement element1 = new DummyTextField("elem1"); 
     306        simulateEvent(new KeyPressed(VirtualKey.LETTER_A), element1); 
     307        simulateEvent(new KeyReleased(VirtualKey.LETTER_A), element1); 
     308        simulateEvent(new KeyPressed(VirtualKey.LETTER_B), element1); 
     309        simulateEvent(new KeyReleased(VirtualKey.LETTER_B), element1); 
     310        simulateEvent(new KeyPressed(VirtualKey.LETTER_C), element1); 
     311        simulateEvent(new KeyReleased(VirtualKey.LETTER_C), element1); 
     312        simulateEvent(new KeyPressed(VirtualKey.LETTER_D), element1); 
     313        simulateEvent(new KeyReleased(VirtualKey.LETTER_D), element1); 
     314        simulateEvent(new KeyPressed(VirtualKey.BACK_SPACE), element1); 
     315        simulateEvent(new KeyReleased(VirtualKey.BACK_SPACE), element1); 
     316        simulateEvent(new KeyPressed(VirtualKey.LETTER_E), element1); 
     317        simulateEvent(new KeyReleased(VirtualKey.LETTER_E), element1); 
     318        simulateEvent(new KeyPressed(VirtualKey.LETTER_F), element1); 
     319        simulateEvent(new KeyReleased(VirtualKey.LETTER_F), element1); 
     320        new TaskTreeChecker().assertTaskTree 
     321            ("Sequence sequence0 {" + 
     322             "  TextInputEvent TextInput abcef {" + 
     323             "    Event KeyPressed LETTER_A {}" + 
     324             "    Event KeyReleased LETTER_A {}" + 
     325             "    Event KeyPressed LETTER_B {}" + 
     326             "    Event KeyReleased LETTER_B {}" + 
     327             "    Event KeyPressed LETTER_C {}" + 
     328             "    Event KeyReleased LETTER_C {}" + 
     329             "    Event KeyPressed LETTER_D {}" + 
     330             "    Event KeyReleased LETTER_D {}" + 
     331             "    Event KeyPressed BACK_SPACE {}" + 
     332             "    Event KeyReleased BACK_SPACE {}" + 
     333             "    Event KeyPressed LETTER_E {}" + 
     334             "    Event KeyReleased LETTER_E {}" + 
     335             "    Event KeyPressed LETTER_F {}" + 
     336             "    Event KeyReleased LETTER_F {}" + 
     337             "  }" + 
     338             "}", getTaskTree()); 
     339 
     340        simulateEvent(new KeyPressed(VirtualKey.BACK_SPACE), element1); 
     341        simulateEvent(new KeyReleased(VirtualKey.BACK_SPACE), element1); 
     342        simulateEvent(new KeyPressed(VirtualKey.BACK_SPACE), element1); 
     343        simulateEvent(new KeyReleased(VirtualKey.BACK_SPACE), element1); 
     344        simulateEvent(new KeyPressed(VirtualKey.BACK_SPACE), element1); 
     345        simulateEvent(new KeyReleased(VirtualKey.BACK_SPACE), element1); 
     346        new TaskTreeChecker().assertTaskTree 
     347            ("Sequence sequence0 {" + 
     348             "  TextInputEvent TextInput ab {" + 
     349             "    Event KeyPressed LETTER_A {}" + 
     350             "    Event KeyReleased LETTER_A {}" + 
     351             "    Event KeyPressed LETTER_B {}" + 
     352             "    Event KeyReleased LETTER_B {}" + 
     353             "    Event KeyPressed LETTER_C {}" + 
     354             "    Event KeyReleased LETTER_C {}" + 
     355             "    Event KeyPressed LETTER_D {}" + 
     356             "    Event KeyReleased LETTER_D {}" + 
     357             "    Event KeyPressed BACK_SPACE {}" + 
     358             "    Event KeyReleased BACK_SPACE {}" + 
     359             "    Event KeyPressed LETTER_E {}" + 
     360             "    Event KeyReleased LETTER_E {}" + 
     361             "    Event KeyPressed LETTER_F {}" + 
     362             "    Event KeyReleased LETTER_F {}" + 
     363             "    Event KeyPressed BACK_SPACE {}" + 
     364             "    Event KeyReleased BACK_SPACE {}" + 
     365             "    Event KeyPressed BACK_SPACE {}" + 
     366             "    Event KeyReleased BACK_SPACE {}" + 
     367             "    Event KeyPressed BACK_SPACE {}" + 
     368             "    Event KeyReleased BACK_SPACE {}" + 
     369             "  }" + 
     370             "}", getTaskTree()); 
     371 
     372    } 
     373 
     374    /** 
     375     * 
     376     */ 
     377    private static class DummyTextField extends DummyGUIElement implements ITextField { 
     378 
     379        /**  */ 
     380        private static final long serialVersionUID = 1L; 
     381 
     382        /** 
     383         * TODO: comment 
     384         *  
     385         * @param name 
     386         */ 
     387        public DummyTextField(String name) { 
     388            super(name); 
     389        } 
     390 
     391    } 
    410392 
    411393} 
  • trunk/quest-core-tasktrees-test/src/test/java/de/ugoe/cs/quest/tasktrees/temporalrelation/TrackBarSelectionDetectionRuleTest.java

    r468 r557  
    1 //------------------------------------------------------------------------------------------------- 
    21// Module    : $RCSfile: DefaultIterationDetectionRuleTest.java,v $ 
    32// Version   : $Revision: 0.0 $  $Author: patrick $  $Date: 28.04.2012 $ 
     
    54// Creation  : 2012 by patrick 
    65// Copyright : Patrick Harms, 2012 
    7 //------------------------------------------------------------------------------------------------- 
     6 
    87package de.ugoe.cs.quest.tasktrees.temporalrelation; 
    98 
    109import org.junit.Test; 
    1110 
    12 import de.ugoe.cs.quest.eventcore.guimodel.GUIElement; 
    13 import de.ugoe.cs.quest.eventcore.guimodel.TrackBar; 
    14 import de.ugoe.cs.quest.eventcore.userinteraction.ValueSelection; 
     11import de.ugoe.cs.quest.eventcore.gui.ValueSelection; 
     12import de.ugoe.cs.quest.eventcore.guimodel.IGUIElement; 
     13import de.ugoe.cs.quest.eventcore.guimodel.ITrackBar; 
    1514import de.ugoe.cs.quest.tasktrees.testutils.DummyGUIElement; 
    1615import de.ugoe.cs.quest.tasktrees.testutils.DummyInteraction; 
    1716import de.ugoe.cs.quest.tasktrees.testutils.TaskTreeChecker; 
    1817 
    19 //------------------------------------------------------------------------------------------------- 
    2018/** 
    2119 * TODO comment 
     
    2422 * @author 2012, last modified by $Author: patrick$ 
    2523 */ 
    26 //------------------------------------------------------------------------------------------------- 
    27 public class TrackBarSelectionDetectionRuleTest extends AbstractTemporalRelationshipTC 
    28 { 
     24public class TrackBarSelectionDetectionRuleTest extends AbstractTemporalRelationshipTC { 
    2925 
    30   //----------------------------------------------------------------------------------------------- 
    31   /** 
    32    * 
    33    */ 
    34   //----------------------------------------------------------------------------------------------- 
    35   @Test 
    36   public void testSimpleDetection() throws Exception 
    37   { 
    38     GUIElement element1 = new DummyTrackBar(); 
    39     simulateInteraction(element1, new ValueSelection<Integer>(1)); 
    40     new TaskTreeChecker().assertTaskTree 
    41       ("Sequence sequence1 {" + 
    42        "  Iteration interation1 {" + 
    43        "    Selection selection1 {" + 
    44        "      Interaction ValueSelection {}" + 
    45        "    }" + 
    46        "  }" + 
    47        "}", getTaskTree());     
    48  
    49     simulateInteraction(element1, new ValueSelection<Integer>(2)); 
    50     new TaskTreeChecker().assertTaskTree 
    51       ("Sequence sequence1 {" + 
    52        "  Iteration interation1 {" + 
    53        "    Selection selection1 {" + 
    54        "      Interaction ValueSelection {}" + 
    55        "      Interaction ValueSelection {}" + 
    56        "    }" + 
    57        "  }" + 
    58        "}", getTaskTree());     
    59  
    60     simulateInteraction(element1, new ValueSelection<Integer>(3)); 
    61     new TaskTreeChecker().assertTaskTree 
    62       ("Sequence sequence1 {" + 
    63        "  Iteration interation1 {" + 
    64        "    Selection selection1 {" + 
    65        "      Interaction ValueSelection {}" + 
    66        "      Interaction ValueSelection {}" + 
    67        "      Interaction ValueSelection {}" + 
    68        "    }" + 
    69        "  }" + 
    70        "}", getTaskTree());     
    71  
    72     simulateInteraction(element1, new ValueSelection<Integer>(2)); 
    73     new TaskTreeChecker().assertTaskTree 
    74       ("Sequence sequence1 {" + 
    75        "  Iteration interation1 {" + 
    76        "    Selection selection1 {" + 
    77        "      Interaction ValueSelection {}" + 
    78        "      Interaction ValueSelection {}" + 
    79        "      Interaction ValueSelection {}" + 
    80        "    }" + 
    81        "  }" + 
    82        "}", getTaskTree());     
    83  
    84     simulateInteraction(element1, new ValueSelection<Integer>(3)); 
    85     new TaskTreeChecker().assertTaskTree 
    86       ("Sequence sequence1 {" + 
    87        "  Iteration interation1 {" + 
    88        "    Selection selection1 {" + 
    89        "      Interaction ValueSelection {}" + 
    90        "      Interaction ValueSelection {}" + 
    91        "      Interaction ValueSelection {}" + 
    92        "    }" + 
    93        "  }" + 
    94        "}", getTaskTree()); 
    95  
    96   } 
    97    
    98   //----------------------------------------------------------------------------------------------- 
    99   /** 
    100    * 
    101    */ 
    102   //----------------------------------------------------------------------------------------------- 
    103   @Test 
    104   public void testComplexDetection() throws Exception 
    105   { 
    106     GUIElement element1 = new DummyTrackBar(); 
    107     simulateInteraction(element1, new ValueSelection<Integer>(1)); 
    108     simulateInteraction(element1, new ValueSelection<Integer>(2)); 
    109     simulateInteraction(element1, new ValueSelection<Integer>(3)); 
    110     simulateInteraction(element1, new ValueSelection<Integer>(1)); 
    111     simulateInteraction(element1, new DummyInteraction("bla", 1)); 
    112     simulateInteraction(element1, new DummyInteraction("bla", 2)); 
    113     simulateInteraction(element1, new ValueSelection<Integer>(2)); 
    114     simulateInteraction(element1, new ValueSelection<Integer>(1)); 
    115     simulateInteraction(element1, new DummyInteraction("bla", 3)); 
    116     simulateInteraction(element1, new ValueSelection<Integer>(3)); 
    117     simulateInteraction(element1, new ValueSelection<Integer>(2)); 
    118     simulateInteraction(element1, new ValueSelection<Integer>(3)); 
    119     simulateInteraction(element1, new DummyInteraction("bla", 1)); 
    120     simulateInteraction(element1, new DummyInteraction("bla", 2)); 
    121     simulateInteraction(element1, new ValueSelection<Integer>(1)); 
    122     simulateInteraction(element1, new ValueSelection<Integer>(1)); 
    123      
    124     new TaskTreeChecker().assertTaskTree 
    125       ("Sequence sequence1 {" + 
    126        "  Iteration interation1 {" + 
    127        "    Selection selection1 {" + 
    128        "      Interaction ValueSelection {}" + 
    129        "      Interaction ValueSelection {}" + 
    130        "      Interaction ValueSelection {}" + 
    131        "    }" + 
    132        "  }" + 
    133        "  Interaction bla {}" + 
    134        "  Interaction bla {}" + 
    135        "  Iteration interation2 {" + 
    136        "    Selection selection2 {" + 
    137        "      Interaction ValueSelection {}" + 
    138        "      Interaction ValueSelection {}" + 
    139        "    }" + 
    140        "  }" + 
    141        "  Interaction bla {}" + 
    142        "  Iteration interation3 {" + 
    143        "    Selection selection3 {" + 
    144        "      Interaction ValueSelection {}" + 
    145        "      Interaction ValueSelection {}" + 
    146        "    }" + 
    147        "  }" + 
    148        "  Interaction bla {}" + 
    149        "  Interaction bla {}" + 
    150        "  Iteration interation4 {" + 
    151        "    Selection selection4 {" + 
    152        "      Interaction ValueSelection {}" + 
    153        "    }" + 
    154        "  }" + 
    155        "}", getTaskTree());     
    156   } 
    157    
    158   //----------------------------------------------------------------------------------------------- 
    159   /** 
    160    * TODO comment 
    161    *  
    162    * @version $Revision: $ $Date: 28.04.2012$ 
    163    * @author 2012, last modified by $Author: patrick$ 
    164    */ 
    165   //----------------------------------------------------------------------------------------------- 
    166   public class DummyTrackBar extends DummyGUIElement implements TrackBar 
    167   { 
    168  
    169     //--------------------------------------------------------------------------------------------- 
    17026    /** 
    17127     * 
    17228     */ 
    173     //--------------------------------------------------------------------------------------------- 
    174     public DummyTrackBar() 
    175     { 
    176       super("DummyTrackBar"); 
     29    @Test 
     30    public void testSimpleDetection() throws Exception { 
     31        IGUIElement element1 = new DummyTrackBar(); 
     32        simulateEvent(new ValueSelection<Integer>(1), element1); 
     33        new TaskTreeChecker().assertTaskTree 
     34            ("Sequence sequence1 {" + 
     35             "  Iteration interation1 {" + 
     36             "    Selection selection1 {" + 
     37             "      Event ValueSelection {}" + 
     38             "    }" + 
     39             "  }" + 
     40             "}", getTaskTree()); 
     41 
     42        simulateEvent(new ValueSelection<Integer>(2), element1); 
     43        new TaskTreeChecker().assertTaskTree 
     44            ("Sequence sequence1 {" + 
     45             "  Iteration interation1 {" + 
     46             "    Selection selection1 {" + 
     47             "      Event ValueSelection {}" + 
     48             "      Event ValueSelection {}" + 
     49             "    }" + 
     50             "  }" + 
     51             "}", getTaskTree()); 
     52 
     53        simulateEvent(new ValueSelection<Integer>(3), element1); 
     54        new TaskTreeChecker().assertTaskTree 
     55            ("Sequence sequence1 {" + 
     56             "  Iteration interation1 {" + 
     57             "    Selection selection1 {" + 
     58             "      Event ValueSelection {}" + 
     59             "      Event ValueSelection {}" + 
     60             "      Event ValueSelection {}" + 
     61             "    }" + 
     62             "  }" + 
     63             "}", getTaskTree()); 
     64 
     65        simulateEvent(new ValueSelection<Integer>(2), element1); 
     66        new TaskTreeChecker().assertTaskTree 
     67            ("Sequence sequence1 {" + 
     68             "  Iteration interation1 {" + 
     69             "    Selection selection1 {" + 
     70             "      Event ValueSelection {}" + 
     71             "      Event ValueSelection {}" + 
     72             "      Event ValueSelection {}" + 
     73             "    }" + 
     74             "  }" + 
     75             "}", getTaskTree()); 
     76 
     77        simulateEvent(new ValueSelection<Integer>(3), element1); 
     78        new TaskTreeChecker().assertTaskTree 
     79            ("Sequence sequence1 {" + 
     80             "  Iteration interation1 {" + 
     81             "    Selection selection1 {" + 
     82             "      Event ValueSelection {}" + 
     83             "      Event ValueSelection {}" + 
     84             "      Event ValueSelection {}" + 
     85             "    }" + 
     86             "  }" + 
     87             "}", getTaskTree()); 
     88 
    17789    } 
    178   } 
     90 
     91    /** 
     92     * 
     93     */ 
     94    @Test 
     95    public void testComplexDetection() throws Exception { 
     96        IGUIElement element1 = new DummyTrackBar(); 
     97        simulateEvent(new ValueSelection<Integer>(1), element1); 
     98        simulateEvent(new ValueSelection<Integer>(2), element1); 
     99        simulateEvent(new ValueSelection<Integer>(3), element1); 
     100        simulateEvent(new ValueSelection<Integer>(1), element1); 
     101        simulateEvent(new DummyInteraction("bla", 1), element1); 
     102        simulateEvent(new DummyInteraction("bla", 2), element1); 
     103        simulateEvent(new ValueSelection<Integer>(2), element1); 
     104        simulateEvent(new ValueSelection<Integer>(1), element1); 
     105        simulateEvent(new DummyInteraction("bla", 3), element1); 
     106        simulateEvent(new ValueSelection<Integer>(3), element1); 
     107        simulateEvent(new ValueSelection<Integer>(2), element1); 
     108        simulateEvent(new ValueSelection<Integer>(3), element1); 
     109        simulateEvent(new DummyInteraction("bla", 1), element1); 
     110        simulateEvent(new DummyInteraction("bla", 2), element1); 
     111        simulateEvent(new ValueSelection<Integer>(1), element1); 
     112        simulateEvent(new ValueSelection<Integer>(1), element1); 
     113 
     114        new TaskTreeChecker().assertTaskTree 
     115            ("Sequence sequence1 {" + 
     116             "  Iteration interation1 {" + 
     117             "    Selection selection1 {" + 
     118             "      Event ValueSelection {}" + 
     119             "      Event ValueSelection {}" + 
     120             "      Event ValueSelection {}" + 
     121             "    }" + 
     122             "  }" + 
     123             "  Event bla {}" + 
     124             "  Event bla {}" + 
     125             "  Iteration interation2 {" + 
     126             "    Selection selection2 {" + 
     127             "      Event ValueSelection {}" + 
     128             "      Event ValueSelection {}" + 
     129             "    }" + 
     130             "  }" + 
     131             "  Event bla {}" + 
     132             "  Iteration interation3 {" + 
     133             "    Selection selection3 {" + 
     134             "      Event ValueSelection {}" + 
     135             "      Event ValueSelection {}" + 
     136             "    }" + 
     137             "  }" + 
     138             "  Event bla {}" + 
     139             "  Event bla {}" + 
     140             "  Iteration interation4 {" + 
     141             "    Selection selection4 {" + 
     142             "      Event ValueSelection {}" + 
     143             "    }" + 
     144             "  }" + 
     145             "}", getTaskTree()); 
     146    } 
     147 
     148    /** 
     149     * TODO comment 
     150     *  
     151     * @version $Revision: $ $Date: 28.04.2012$ 
     152     * @author 2012, last modified by $Author: patrick$ 
     153     */ 
     154    public class DummyTrackBar extends DummyGUIElement implements ITrackBar { 
     155 
     156        /**  */ 
     157        private static final long serialVersionUID = 1L; 
     158 
     159         /** 
     160          * 
     161          */ 
     162         public DummyTrackBar() { 
     163            super("DummyTrackBar"); 
     164        } 
     165    } 
    179166 
    180167} 
Note: See TracChangeset for help on using the changeset viewer.