Changeset 957 for trunk/autoquest-core-events-test/src/test
- Timestamp:
- 10/30/12 10:40:25 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-events-test/src/test/java/de/ugoe/cs/autoquest/eventcore/gui/MouseClickCondenserTest.java
r946 r957 18 18 import static org.junit.Assert.assertFalse; 19 19 import static org.junit.Assert.assertTrue; 20 import static org.junit.Assert.fail; 20 21 21 22 import java.util.ArrayList; … … 47 48 */ 48 49 @Test 49 public void test MouseClickInOneSequenceElement() {50 public void testNormalSequence() { 50 51 MouseButtonInteraction.Button leftBtn = MouseButtonInteraction.Button.LEFT; 51 52 MouseButtonInteraction.Button middleBtn = MouseButtonInteraction.Button.MIDDLE; … … 53 54 54 55 IGUIElement element1 = new DummyGUIElement("elem1"); 55 IGUIElement element2 = new DummyGUIElement("elem2");56 56 57 57 simulateEvent(new MouseButtonDown(leftBtn, 0, 0), element1); 58 58 simulateEvent(new MouseButtonUp(leftBtn, 0, 0), element1); 59 59 simulateEvent(new MouseClick(leftBtn, 0, 0), element1); 60 assertCondensedMouseClicks("elem1"); 60 assertCondensedMouseClicks("click left elem1"); 61 62 simulateEvent(new MouseButtonDown(middleBtn, 0, 0), element1); 63 simulateEvent(new MouseButtonUp(middleBtn, 0, 0), element1); 64 simulateEvent(new MouseClick(middleBtn, 0, 0), element1); 65 assertCondensedMouseClicks("click left elem1", "click middle elem1"); 66 67 simulateEvent(new MouseButtonDown(rightBtn, 0, 0), element1); 68 simulateEvent(new MouseButtonUp(rightBtn, 0, 0), element1); 69 simulateEvent(new MouseClick(rightBtn, 0, 0), element1); 70 assertCondensedMouseClicks("click left elem1", "click middle elem1", "click right elem1"); 71 72 simulateEvent(new MouseButtonDown(leftBtn, 0, 0), element1); 73 simulateEvent(new MouseButtonUp(leftBtn, 0, 0), element1); 74 assertCondensedMouseClicks("click left elem1", "click middle elem1", "click right elem1", 75 "click left elem1"); 76 77 simulateEvent(new MouseButtonDown(middleBtn, 0, 0), element1); 78 simulateEvent(new MouseButtonUp(middleBtn, 0, 0), element1); 79 assertCondensedMouseClicks("click left elem1", "click middle elem1", "click right elem1", 80 "click left elem1", "click middle elem1"); 81 82 simulateEvent(new MouseButtonDown(rightBtn, 0, 0), element1); 83 simulateEvent(new MouseButtonUp(rightBtn, 0, 0), element1); 84 assertCondensedMouseClicks("click left elem1", "click middle elem1", "click right elem1", 85 "click left elem1", "click middle elem1", "click right elem1"); 86 87 } 88 89 /** 90 * 91 */ 92 @Test 93 public void testMouseClickInSequence() { 94 MouseButtonInteraction.Button middleBtn = MouseButtonInteraction.Button.MIDDLE; 95 MouseButtonInteraction.Button rightBtn = MouseButtonInteraction.Button.RIGHT; 96 97 IGUIElement element1 = new DummyGUIElement("elem1"); 98 IGUIElement element2 = new DummyGUIElement("elem2"); 61 99 62 100 simulateEvent(new DummyInteraction("bla", 1), element1); … … 67 105 simulateEvent(new DummyInteraction("blo", 1), element1); 68 106 simulateEvent(new DummyInteraction("blu", 1), element1); 69 assertCondensedMouseClicks(" elem1", "", "", "elem1", "", "");107 assertCondensedMouseClicks("", "", "click middle elem1", "", ""); 70 108 71 109 simulateEvent(new DummyInteraction("bla", 1), element2); … … 76 114 simulateEvent(new DummyInteraction("blo", 1), element2); 77 115 simulateEvent(new DummyInteraction("blu", 1), element2); 78 assertCondensedMouseClicks("elem1", "", "", "elem1", "", "", "", "", "elem2", "", ""); 116 assertCondensedMouseClicks("", "", "click middle elem1", "", "", 117 "", "", "click right elem2", "", ""); 118 119 } 120 121 122 /** 123 * 124 */ 125 @Test 126 public void testNoMouseClick() { 127 MouseButtonInteraction.Button leftBtn = MouseButtonInteraction.Button.LEFT; 128 MouseButtonInteraction.Button middleBtn = MouseButtonInteraction.Button.MIDDLE; 129 MouseButtonInteraction.Button rightBtn = MouseButtonInteraction.Button.RIGHT; 130 131 IGUIElement element1 = new DummyGUIElement("elem1"); 132 IGUIElement element2 = new DummyGUIElement("elem2"); 79 133 80 134 simulateEvent(new MouseButtonDown(leftBtn, 0, 0), element1); 81 simulateEvent(new MouseButtonUp(leftBtn, 0, 0), element1); 82 simulateEvent(new MouseClick(leftBtn, 0, 0), element2); 83 assertCondensedMouseClicks("elem1", "", "", "elem1", "", "", "", "", "elem2", "", "", 84 "", "", "elem2"); 85 86 simulateEvent(new MouseButtonDown(middleBtn, 0, 0), element1); 87 simulateEvent(new MouseButtonUp(middleBtn, 0, 0), element1); 88 simulateEvent(new MouseClick(rightBtn, 0, 0), element1); 89 simulateEvent(new DummyInteraction("bla", 1), element2); 90 assertCondensedMouseClicks("elem1", "", "", "elem1", "", "", "", "", "elem2", "", "", 91 "", "", "elem2", "", "", "elem1", ""); 135 simulateEvent(new MouseButtonUp(leftBtn, 0, 0), element2); 136 simulateEvent(new MouseClick(leftBtn, 0, 0), element1); 137 assertCondensedMouseClicks("", "", "click left elem1"); 138 139 simulateEvent(new MouseButtonDown(middleBtn, 0, 0), element1); 140 simulateEvent(new MouseButtonUp(rightBtn, 0, 0), element1); 141 simulateEvent(new MouseClick(middleBtn, 0, 0), element1); 142 assertCondensedMouseClicks("", "", "click left elem1", "", "", "click middle elem1"); 143 144 simulateEvent(new MouseButtonDown(leftBtn, 1, 0), element1); 145 simulateEvent(new MouseButtonUp(leftBtn, 0, 1), element1); 146 simulateEvent(new MouseClick(leftBtn, 1, 1), element1); 147 assertCondensedMouseClicks("", "", "click left elem1", "", "", "click middle elem1", 148 "", "", "click left elem1"); 92 149 } 93 150 … … 100 157 101 158 /** 102 *103 */104 private void assertCondensedMouseClicks(String... clickedTargets) {105 MouseClickCondenser condenser = new MouseClickCondenser();106 List<Event> result = condenser.condenseMouseClicks(events);159 * 160 */ 161 private void assertCondensedMouseClicks(String... clickedTargets) { 162 MouseClickCondenser condenser = new MouseClickCondenser(); 163 List<Event> result = condenser.condenseMouseClicks(events); 107 164 108 assertEquals(clickedTargets.length, result.size());165 assertEquals(clickedTargets.length, result.size()); 109 166 110 for (int i = 0; i < clickedTargets.length; i++) {111 String clickedTarget = clickedTargets[i];167 for (int i = 0; i < clickedTargets.length; i++) { 168 String clickedTarget = clickedTargets[i]; 112 169 113 if ((clickedTarget != null) && (!"".equals(clickedTarget))) { 114 assertTrue(result.get(i).getType() instanceof MouseClick); 115 assertTrue(result.get(i).getTarget() instanceof DummyGUIElement); 116 assertEquals 117 (clickedTarget, ((DummyGUIElement) result.get(i).getTarget()).getStringIdentifier()); 118 } 119 else { 120 assertFalse(result.get(i).getType() instanceof MouseClick); 121 } 122 } 123 } 170 if ((clickedTarget != null) && (!"".equals(clickedTarget))) { 171 String[] parts = clickedTarget.split(" "); 172 assertEquals("invalid test case", 3, parts.length); 173 174 if ("click".equals(parts[0])) { 175 assertTrue(result.get(i).getType() instanceof MouseClick); 176 } 177 else { 178 fail("invalid assertion in test case"); 179 } 180 181 if ("left".equals(parts[1])) { 182 assertEquals(MouseButtonInteraction.Button.LEFT, 183 ((MouseButtonInteraction) result.get(i).getType()).getButton()); 184 } 185 else if ("middle".equals(parts[1])) { 186 assertEquals(MouseButtonInteraction.Button.MIDDLE, 187 ((MouseButtonInteraction) result.get(i).getType()).getButton()); 188 } 189 else if ("right".equals(parts[1])) { 190 assertEquals(MouseButtonInteraction.Button.RIGHT, 191 ((MouseButtonInteraction) result.get(i).getType()).getButton()); 192 } 193 else { 194 fail("invalid assertion in test case"); 195 } 196 197 assertTrue(result.get(i).getTarget() instanceof DummyGUIElement); 198 199 assertEquals 200 (parts[2], ((DummyGUIElement) result.get(i).getTarget()).getStringIdentifier()); 201 } 202 else { 203 assertFalse(result.get(i).getType() instanceof MouseClick); 204 } 205 } 206 } 124 207 }
Note: See TracChangeset
for help on using the changeset viewer.