- Timestamp:
- 08/31/12 09:58:43 (12 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 deleted
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-core-events-test/src/test/java/de/ugoe/cs/quest/eventcore/gui/MouseClickCondenserTest.java
r692 r721 1 package de.ugoe.cs.quest.tasktrees.temporalrelation; 1 package de.ugoe.cs.quest.eventcore.gui; 2 3 import static org.junit.Assert.assertEquals; 4 import static org.junit.Assert.assertFalse; 5 import static org.junit.Assert.assertTrue; 6 7 import java.util.ArrayList; 8 import java.util.List; 2 9 3 10 import org.junit.Test; 4 11 12 import de.ugoe.cs.quest.eventcore.Event; 13 import de.ugoe.cs.quest.eventcore.IEventType; 5 14 import de.ugoe.cs.quest.eventcore.gui.MouseButtonDown; 6 15 import de.ugoe.cs.quest.eventcore.gui.MouseButtonInteraction; … … 8 17 import de.ugoe.cs.quest.eventcore.gui.MouseClick; 9 18 import de.ugoe.cs.quest.eventcore.guimodel.IGUIElement; 10 import de.ugoe.cs.quest.tasktrees.testutils.TaskTreeChecker;11 19 import de.ugoe.cs.quest.test.DummyGUIElement; 12 20 import de.ugoe.cs.quest.test.DummyInteraction; 13 21 14 22 /** 15 * TODO comment 16 * 17 * @version $Revision: $ $Date: $ 18 * @author 2011, last modified by $Author: $ 23 * @author Patrick Harms 19 24 */ 20 public class DefaultMouseClickReductionRuleTest extends AbstractTemporalRelationshipTC { 25 public class MouseClickCondenserTest { 26 27 /** */ 28 private List<Event> events = new ArrayList<Event>(); 21 29 22 30 /** … … 30 38 31 39 IGUIElement element1 = new DummyGUIElement("elem1"); 32 IGUIElement element2 = new DummyGUIElement("elem 1");40 IGUIElement element2 = new DummyGUIElement("elem2"); 33 41 34 42 simulateEvent(new MouseButtonDown(leftBtn), element1); 35 43 simulateEvent(new MouseButtonUp(leftBtn), element1); 36 44 simulateEvent(new MouseClick(leftBtn), element1); 37 38 new TaskTreeChecker().assertTaskTree 39 ("Sequence sequence {" + 40 " Event LeftMouseClick {}" + 41 "}", getTaskTree()); 45 assertCondensedMouseClicks("elem1"); 42 46 43 47 simulateEvent(new DummyInteraction("bla", 1), element1); … … 48 52 simulateEvent(new DummyInteraction("blo", 1), element1); 49 53 simulateEvent(new DummyInteraction("blu", 1), element1); 50 51 new TaskTreeChecker().assertTaskTree 52 ("Sequence sequence {" + 53 " Event LeftMouseClick {}" + 54 " Event bla {}" + 55 " Event bli {}" + 56 " Event MiddleMouseClick {}" + 57 " Event blo {}" + 58 " Event blu {}" + 59 "}", getTaskTree()); 54 assertCondensedMouseClicks("elem1", "", "", "elem1", "", ""); 60 55 61 56 simulateEvent(new DummyInteraction("bla", 1), element2); … … 66 61 simulateEvent(new DummyInteraction("blo", 1), element2); 67 62 simulateEvent(new DummyInteraction("blu", 1), element2); 68 69 new TaskTreeChecker().assertTaskTree 70 ("Sequence sequence0 {" + 71 " Sequence sequence1 {" + 72 " Event LeftMouseClick {}" + 73 " Event bla {}" + 74 " Event bli {}" + 75 " Event MiddleMouseClick {}" + 76 " Event blo {}" + 77 " Event blu {}" + 78 " }" + 79 " Sequence sequence2 {" + 80 " Event bla {}" + 81 " Event bli {}" + 82 " Event RightMouseClick {}" + 83 " Event blo {}" + 84 " Event blu {}" + 85 " }" + 86 "}", getTaskTree()); 63 assertCondensedMouseClicks("elem1", "", "", "elem1", "", "", "", "", "elem2", "", ""); 87 64 88 65 simulateEvent(new MouseButtonDown(leftBtn), element1); 89 66 simulateEvent(new MouseButtonUp(leftBtn), element1); 90 67 simulateEvent(new MouseClick(leftBtn), element2); 91 92 new TaskTreeChecker().assertTaskTree 93 ("Sequence sequence0 {" + 94 " Sequence sequence1 {" + 95 " Event LeftMouseClick {}" + 96 " Event bla {}" + 97 " Event bli {}" + 98 " Event MiddleMouseClick {}" + 99 " Event blo {}" + 100 " Event blu {}" + 101 " }" + 102 " Sequence sequence2 {" + 103 " Event bla {}" + 104 " Event bli {}" + 105 " Event RightMouseClick {}" + 106 " Event blo {}" + 107 " Event blu {}" + 108 " }" + 109 " Sequence sequence3 {" + 110 " Event LeftMouseButtonDown {}" + 111 " Event LeftMouseButtonUp {}" + 112 " }" + 113 " Sequence sequence4 {" + 114 " Event LeftMouseClick {}" + 115 " }" + 116 "}", getTaskTree()); 68 assertCondensedMouseClicks("elem1", "", "", "elem1", "", "", "", "", "elem2", "", "", 69 "", "", "elem2"); 117 70 118 71 simulateEvent(new MouseButtonDown(middleBtn), element1); … … 120 73 simulateEvent(new MouseClick(rightBtn), element1); 121 74 simulateEvent(new DummyInteraction("bla", 1), element2); 122 123 new TaskTreeChecker().assertTaskTree 124 ("Sequence sequence0 {" + 125 " Sequence sequence1 {" + 126 " Event LeftMouseClick {}" + 127 " Event bla {}" + 128 " Event bli {}" + 129 " Event MiddleMouseClick {}" + 130 " Event blo {}" + 131 " Event blu {}" + 132 " }" + 133 " Sequence sequence2 {" + 134 " Event bla {}" + 135 " Event bli {}" + 136 " Event RightMouseClick {}" + 137 " Event blo {}" + 138 " Event blu {}" + 139 " }" + 140 " Sequence sequence3 {" + 141 " Event LeftMouseButtonDown {}" + 142 " Event LeftMouseButtonUp {}" + 143 " }" + 144 " Sequence sequence4 {" + 145 " Event LeftMouseClick {}" + 146 " }" + 147 " Sequence sequence5 {" + 148 " Sequence sequence6 {" + 149 " Event MiddleMouseButtonDown {}" + 150 " Event MiddleMouseButtonUp {}" + 151 " }" + 152 " Event RightMouseClick {}" + 153 " }" + 154 " Sequence sequence7 {" + 155 " Event bla {}" + 156 " }" + 157 "}", getTaskTree()); 158 75 assertCondensedMouseClicks("elem1", "", "", "elem1", "", "", "", "", "elem2", "", "", 76 "", "", "elem2", "", "", "elem1", ""); 159 77 } 160 78 79 /** 80 * 81 */ 82 private void simulateEvent(IEventType eventType, IGUIElement guiElement) { 83 events.add(new Event(eventType, guiElement)); 84 } 85 86 /** 87 * 88 */ 89 private void assertCondensedMouseClicks(String... clickedTargets) { 90 MouseClickCondenser condenser = new MouseClickCondenser(); 91 List<Event> result = condenser.condenseMouseClicks(events); 92 93 assertEquals(clickedTargets.length, result.size()); 94 95 for (int i = 0; i < clickedTargets.length; i++) { 96 String clickedTarget = clickedTargets[i]; 97 98 if ((clickedTarget != null) && (!"".equals(clickedTarget))) { 99 assertTrue(result.get(i).getType() instanceof MouseClick); 100 assertTrue(result.get(i).getTarget() instanceof DummyGUIElement); 101 assertEquals 102 (clickedTarget, ((DummyGUIElement) result.get(i).getTarget()).getStringIdentifier()); 103 } 104 else { 105 assertFalse(result.get(i).getType() instanceof MouseClick); 106 } 107 } 108 } 161 109 } -
trunk/quest-core-tasktrees/src/main/java/de/ugoe/cs/quest/tasktrees/temporalrelation/TemporalRelationshipRuleManager.java
r690 r721 43 43 LOG.info("initializing"); 44 44 45 ruleIndex.add(new DefaultMouseClickReductionRule());46 45 ruleIndex.add(new DefaultEventTargetSequenceDetectionRule()); 47 46 ruleIndex.add(new TrackBarSelectionDetectionRule(nodeEqualityRuleManager));
Note: See TracChangeset
for help on using the changeset viewer.