Changeset 1125
- Timestamp:
- 03/18/13 11:46:47 (12 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/EventTaskComparisonRuleTest.java
r927 r1125 24 24 import de.ugoe.cs.autoquest.tasktrees.nodeequality.EventTaskComparisonRule; 25 25 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality; 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection;27 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 28 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; … … 39 38 */ 40 39 @Test 41 public void test() { 42 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 43 44 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 45 46 // test the identity check 47 IEventType eventType1 = new StringEventType("eventType1"); 48 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 49 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 50 51 assertEquals(NodeEquality.IDENTICAL, rule.compare(task1, task1)); 52 40 public void test_isApplicable_01() { 41 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 42 43 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 44 45 IEventType eventType1 = new StringEventType("eventType1"); 46 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 47 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 48 49 assertTrue(rule.isApplicable(task1, task1)); 50 } 51 52 /** 53 * 54 */ 55 @Test 56 public void test_isApplicable_02() { 57 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 58 59 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 60 61 IEventType eventType1 = new StringEventType("eventType1"); 62 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 63 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 64 65 IEventType eventType2 = new StringEventType("eventType2"); 66 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 67 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 68 69 assertTrue(rule.isApplicable(task1, task2)); 70 assertTrue(rule.isApplicable(task2, task1)); 71 } 72 73 /** 74 * 75 */ 76 @Test 77 public void test_isApplicable_03() { 78 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 79 80 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 81 82 IEventType eventType1 = new StringEventType("eventType1"); 83 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 84 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 85 86 ITaskTreeNode selection = treeNodeFactory.createNewSelection(); 87 88 assertFalse(rule.isApplicable(task1, selection)); 89 assertFalse(rule.isApplicable(selection, task1)); 90 } 91 92 /** 93 * 94 */ 95 @Test 96 public void test_isApplicable_04() { 97 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 98 99 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 100 101 IEventType eventType1 = new StringEventType("eventType1"); 102 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 103 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 104 105 ITaskTreeNode sequence = treeNodeFactory.createNewSequence(); 106 107 assertFalse(rule.isApplicable(task1, sequence)); 108 assertFalse(rule.isApplicable(sequence, task1)); 109 } 110 111 /** 112 * 113 */ 114 @Test 115 public void test_isApplicable_05() { 116 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 117 118 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 119 120 IEventType eventType1 = new StringEventType("eventType1"); 121 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 122 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 123 124 ITaskTreeNode iteration = treeNodeFactory.createNewIteration(); 125 126 assertFalse(rule.isApplicable(task1, iteration)); 127 assertFalse(rule.isApplicable(iteration, task1)); 128 } 129 130 /** 131 * 132 */ 133 @Test 134 public void test_isApplicable_06() { 135 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 136 137 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 138 139 IEventType eventType1 = new StringEventType("eventType1"); 140 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 141 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 142 143 ITaskTreeNode optional = treeNodeFactory.createNewOptional(); 144 145 assertFalse(rule.isApplicable(task1, optional)); 146 assertFalse(rule.isApplicable(optional, task1)); 147 } 148 149 /** 150 * 151 */ 152 @Test 153 public void test_compare_01() { 154 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 155 156 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 157 158 IEventType eventType1 = new StringEventType("eventType1"); 159 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 160 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 161 162 assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, task1)); 163 assertTrue(rule.areLexicallyEqual(task1, task1)); 164 assertTrue(rule.areSyntacticallyEqual(task1, task1)); 165 assertTrue(rule.areSemanticallyEqual(task1, task1)); 166 } 167 168 /** 169 * 170 */ 171 @Test 172 public void test_compare_02() { 173 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 174 175 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 176 177 IEventType eventType1 = new StringEventType("eventType1"); 178 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 179 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 180 53 181 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 54 182 55 183 assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, task2)); 184 assertTrue(rule.areLexicallyEqual(task1, task2)); 185 assertTrue(rule.areSyntacticallyEqual(task1, task2)); 186 assertTrue(rule.areSemanticallyEqual(task1, task2)); 187 56 188 assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task2, task1)); 189 assertTrue(rule.areLexicallyEqual(task2, task1)); 190 assertTrue(rule.areSyntacticallyEqual(task2, task1)); 191 assertTrue(rule.areSemanticallyEqual(task2, task1)); 192 } 193 194 /** 195 * 196 */ 197 @Test 198 public void test_compare_03() { 199 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 200 201 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 202 203 IEventType eventType1 = new StringEventType("eventType1"); 204 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 205 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 57 206 58 207 IEventType eventType2 = new StringEventType("eventType2"); 59 task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1);208 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 60 209 61 210 assertEquals(NodeEquality.UNEQUAL, rule.compare(task1, task2)); 211 assertFalse(rule.areLexicallyEqual(task1, task2)); 212 assertFalse(rule.areSyntacticallyEqual(task1, task2)); 213 assertFalse(rule.areSemanticallyEqual(task1, task2)); 214 62 215 assertEquals(NodeEquality.UNEQUAL, rule.compare(task2, task1)); 216 assertFalse(rule.areLexicallyEqual(task2, task1)); 217 assertFalse(rule.areSyntacticallyEqual(task2, task1)); 218 assertFalse(rule.areSemanticallyEqual(task2, task1)); 219 } 220 221 /** 222 * 223 */ 224 @Test 225 public void test_compare_04() { 226 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 227 228 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 229 230 IEventType eventType1 = new StringEventType("eventType1"); 231 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 232 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 63 233 64 234 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 65 task2 = treeNodeFactory.createNewEventTask(eventType1, eventTarget2);235 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType1, eventTarget2); 66 236 67 237 assertEquals(NodeEquality.UNEQUAL, rule.compare(task1, task2)); 238 assertFalse(rule.areLexicallyEqual(task1, task2)); 239 assertFalse(rule.areSyntacticallyEqual(task1, task2)); 240 assertFalse(rule.areSemanticallyEqual(task1, task2)); 241 68 242 assertEquals(NodeEquality.UNEQUAL, rule.compare(task2, task1)); 69 70 task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 243 assertFalse(rule.areLexicallyEqual(task2, task1)); 244 assertFalse(rule.areSyntacticallyEqual(task2, task1)); 245 assertFalse(rule.areSemanticallyEqual(task2, task1)); 246 } 247 248 249 /** 250 * 251 */ 252 @Test 253 public void test_compare_05() { 254 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 255 256 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 257 258 IEventType eventType1 = new StringEventType("eventType1"); 259 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 260 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 261 262 IEventType eventType2 = new StringEventType("eventType2"); 263 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 264 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 71 265 72 266 assertEquals(NodeEquality.UNEQUAL, rule.compare(task1, task2)); 267 assertFalse(rule.areLexicallyEqual(task1, task2)); 268 assertFalse(rule.areSyntacticallyEqual(task1, task2)); 269 assertFalse(rule.areSemanticallyEqual(task1, task2)); 270 73 271 assertEquals(NodeEquality.UNEQUAL, rule.compare(task2, task1)); 74 75 ISelection selection = treeNodeFactory.createNewSelection(); 76 assertNull(rule.compare(task1, selection)); 77 assertNull(rule.compare(selection, task1)); 78 assertNull(rule.compare(task2, selection)); 79 assertNull(rule.compare(selection, task2)); 272 assertFalse(rule.areLexicallyEqual(task2, task1)); 273 assertFalse(rule.areSyntacticallyEqual(task2, task1)); 274 assertFalse(rule.areSemanticallyEqual(task2, task1)); 80 275 } 81 276 -
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/GUIEventTaskComparisonRuleTest.java
r973 r1125 26 26 import de.ugoe.cs.autoquest.eventcore.IEventType; 27 27 import de.ugoe.cs.autoquest.eventcore.StringEventType; 28 import de.ugoe.cs.autoquest.eventcore.gui.KeyPressed; 29 import de.ugoe.cs.autoquest.eventcore.gui.KeyReleased; 30 import de.ugoe.cs.autoquest.eventcore.gui.KeyTyped; 28 31 import de.ugoe.cs.autoquest.eventcore.gui.KeyboardFocusChange; 32 import de.ugoe.cs.autoquest.eventcore.gui.MouseButtonDown; 33 import de.ugoe.cs.autoquest.eventcore.gui.MouseButtonInteraction; 34 import de.ugoe.cs.autoquest.eventcore.gui.MouseButtonUp; 35 import de.ugoe.cs.autoquest.eventcore.gui.MouseClick; 36 import de.ugoe.cs.autoquest.eventcore.gui.MouseDoubleClick; 37 import de.ugoe.cs.autoquest.eventcore.gui.MouseDragAndDrop; 38 import de.ugoe.cs.autoquest.eventcore.gui.Scroll; 29 39 import de.ugoe.cs.autoquest.eventcore.gui.TextInput; 40 import de.ugoe.cs.autoquest.eventcore.gui.TextSelection; 30 41 import de.ugoe.cs.autoquest.eventcore.gui.ValueSelection; 42 import de.ugoe.cs.autoquest.keyboardmaps.VirtualKey; 31 43 import de.ugoe.cs.autoquest.tasktrees.nodeequality.GUIEventTaskComparisonRule; 32 44 import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality; 33 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection;34 45 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 35 46 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; … … 46 57 */ 47 58 @Test 48 public void test() { 49 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 50 51 GUIEventTaskComparisonRule rule = new GUIEventTaskComparisonRule(); 52 53 // test the identity check 54 IEventType eventType1 = new StringEventType("blub"); 55 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 56 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 57 58 assertNull(rule.compare(task1, task1)); 59 60 eventType1 = new KeyboardFocusChange(); 61 task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 62 63 assertEquals(NodeEquality.IDENTICAL, rule.compare(task1, task1)); 64 65 // test lexical equality for interaction events which are no value selections or text inputs 59 public void test_isApplicable_01() { 60 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 61 62 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 63 64 IEventType eventType1 = new StringEventType("eventType1"); 65 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 66 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 67 68 assertTrue(rule.isApplicable(task1, task1)); 69 } 70 71 /** 72 * 73 */ 74 @Test 75 public void test_isApplicable_02() { 76 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 77 78 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 79 80 IEventType eventType1 = new StringEventType("eventType1"); 81 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 82 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 83 84 IEventType eventType2 = new StringEventType("eventType2"); 85 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 86 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 87 88 assertTrue(rule.isApplicable(task1, task2)); 89 assertTrue(rule.isApplicable(task2, task1)); 90 } 91 92 /** 93 * 94 */ 95 @Test 96 public void test_isApplicable_03() { 97 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 98 99 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 100 101 IEventType eventType1 = new KeyboardFocusChange(); 102 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 103 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 104 66 105 IEventType eventType2 = new KeyboardFocusChange(); 67 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 68 69 assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, task2)); 70 assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task2, task1)); 71 72 // test equality of value selections 73 eventType1 = new ValueSelection<String>("value1"); 74 task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 75 76 assertEquals(NodeEquality.UNEQUAL, rule.compare(task1, task2)); 77 assertEquals(NodeEquality.UNEQUAL, rule.compare(task2, task1)); 78 79 eventType2 = new ValueSelection<String>("value1"); 80 task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 81 82 assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, task2)); 83 assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task2, task1)); 84 85 eventType2 = new ValueSelection<String>("value2"); 86 task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 87 88 assertEquals(NodeEquality.SEMANTICALLY_EQUAL, rule.compare(task1, task2)); 89 assertEquals(NodeEquality.SEMANTICALLY_EQUAL, rule.compare(task2, task1)); 90 91 // test equality of text inputs 106 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 107 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 108 109 assertTrue(rule.isApplicable(task1, task2)); 110 assertTrue(rule.isApplicable(task2, task1)); 111 } 112 113 /** 114 * 115 */ 116 @Test 117 public void test_isApplicable_04() { 118 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 119 120 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 121 122 IEventType eventType1 = new KeyPressed(VirtualKey.LETTER_A); 123 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 124 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 125 126 IEventType eventType2 = new KeyReleased(VirtualKey.LETTER_B); 127 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 128 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 129 130 assertTrue(rule.isApplicable(task1, task2)); 131 assertTrue(rule.isApplicable(task2, task1)); 132 } 133 134 /** 135 * 136 */ 137 @Test 138 public void test_isApplicable_05() { 139 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 140 141 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 142 143 IEventType eventType1 = new KeyTyped(VirtualKey.LETTER_C); 144 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 145 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 146 147 IEventType eventType2 = new KeyTyped(VirtualKey.LETTER_D); 148 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 149 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 150 151 assertTrue(rule.isApplicable(task1, task2)); 152 assertTrue(rule.isApplicable(task2, task1)); 153 } 154 155 /** 156 * 157 */ 158 @Test 159 public void test_isApplicable_06() { 160 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 161 162 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 163 164 IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 5, 6); 165 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 166 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 167 168 IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.MIDDLE, 3, 1); 169 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 170 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 171 172 assertTrue(rule.isApplicable(task1, task2)); 173 assertTrue(rule.isApplicable(task2, task1)); 174 } 175 176 /** 177 * 178 */ 179 @Test 180 public void test_isApplicable_07() { 181 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 182 183 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 184 185 IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.RIGHT, 4, 7); 186 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 187 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 188 189 IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.X, 9, 12); 190 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 191 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 192 193 assertTrue(rule.isApplicable(task1, task2)); 194 assertTrue(rule.isApplicable(task2, task1)); 195 } 196 197 /** 198 * 199 */ 200 @Test 201 public void test_isApplicable_08() { 202 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 203 204 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 205 206 IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 207 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 208 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 209 210 IEventType eventType2 = new MouseDragAndDrop(5, 6, 7, 8); 211 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 212 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 213 214 assertTrue(rule.isApplicable(task1, task2)); 215 assertTrue(rule.isApplicable(task2, task1)); 216 } 217 218 /** 219 * 220 */ 221 @Test 222 public void test_isApplicable_09() { 223 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 224 225 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 226 227 IEventType eventType1 = new Scroll(1, 2); 228 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 229 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 230 231 IEventType eventType2 = new Scroll(3, 4); 232 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 233 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 234 235 assertTrue(rule.isApplicable(task1, task2)); 236 assertTrue(rule.isApplicable(task2, task1)); 237 } 238 239 /** 240 * 241 */ 242 @Test 243 public void test_isApplicable_10() { 244 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 245 246 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 247 248 List<Event> inputEvents = new ArrayList<Event>(); 249 IEventType eventType1 = new TextInput("text1", inputEvents); 250 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 251 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 252 253 IEventType eventType2 = new TextInput("text2", inputEvents); 254 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 255 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 256 257 assertTrue(rule.isApplicable(task1, task2)); 258 assertTrue(rule.isApplicable(task2, task1)); 259 } 260 261 /** 262 * 263 */ 264 @Test 265 public void test_isApplicable_11() { 266 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 267 268 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 269 270 IEventType eventType1 = new TextSelection(); 271 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 272 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 273 274 IEventType eventType2 = new ValueSelection<String>("value"); 275 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 276 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 277 278 assertTrue(rule.isApplicable(task1, task2)); 279 assertTrue(rule.isApplicable(task2, task1)); 280 } 281 282 /** 283 * 284 */ 285 @Test 286 public void test_isApplicable_12() { 287 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 288 289 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 290 291 IEventType eventType1 = new StringEventType("eventType1"); 292 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 293 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 294 295 ITaskTreeNode selection = treeNodeFactory.createNewSelection(); 296 297 assertFalse(rule.isApplicable(task1, selection)); 298 assertFalse(rule.isApplicable(selection, task1)); 299 } 300 301 /** 302 * 303 */ 304 @Test 305 public void test_isApplicable_13() { 306 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 307 308 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 309 310 IEventType eventType1 = new StringEventType("eventType1"); 311 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 312 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 313 314 ITaskTreeNode sequence = treeNodeFactory.createNewSequence(); 315 316 assertFalse(rule.isApplicable(task1, sequence)); 317 assertFalse(rule.isApplicable(sequence, task1)); 318 } 319 320 /** 321 * 322 */ 323 @Test 324 public void test_isApplicable_14() { 325 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 326 327 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 328 329 IEventType eventType1 = new StringEventType("eventType1"); 330 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 331 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 332 333 ITaskTreeNode iteration = treeNodeFactory.createNewIteration(); 334 335 assertFalse(rule.isApplicable(task1, iteration)); 336 assertFalse(rule.isApplicable(iteration, task1)); 337 } 338 339 /** 340 * 341 */ 342 @Test 343 public void test_isApplicable_15() { 344 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 345 346 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 347 348 IEventType eventType1 = new StringEventType("eventType1"); 349 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 350 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 351 352 ITaskTreeNode optional = treeNodeFactory.createNewOptional(); 353 354 assertFalse(rule.isApplicable(task1, optional)); 355 assertFalse(rule.isApplicable(optional, task1)); 356 } 357 358 /** 359 * 360 */ 361 @Test 362 public void test_compare_KeyboardFocusChange_01() { 363 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 364 365 IEventType eventType1 = new KeyboardFocusChange(); 366 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 367 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 368 369 assertLexicallyEqual(task1, task1); 370 } 371 372 /** 373 * 374 */ 375 @Test 376 public void test_compare_KeyboardFocusChange_02() { 377 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 378 379 IEventType eventType1 = new KeyboardFocusChange(); 380 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 381 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 382 383 IEventType eventType2 = new KeyboardFocusChange(); 384 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 385 386 assertLexicallyEqual(task1, task2); 387 } 388 389 /** 390 * 391 */ 392 @Test 393 public void test_compare_KeyboardFocusChange_03() { 394 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 395 396 IEventType eventType1 = new KeyboardFocusChange(); 397 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 398 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 399 400 IEventType eventType2 = new KeyboardFocusChange(); 401 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 402 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 403 404 assertUnequal(task1, task2); 405 } 406 407 /** 408 * 409 */ 410 @Test 411 public void test_compare_KeyPressed_01() { 412 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 413 414 IEventType eventType1 = new KeyPressed(VirtualKey.LETTER_A); 415 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 416 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 417 418 assertLexicallyEqual(task1, task1); 419 } 420 421 /** 422 * 423 */ 424 @Test 425 public void test_compare_KeyPressed_02() { 426 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 427 428 IEventType eventType1 = new KeyPressed(VirtualKey.LETTER_A); 429 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 430 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 431 432 IEventType eventType2 = new KeyPressed(VirtualKey.LETTER_A); 433 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 434 435 assertLexicallyEqual(task1, task2); 436 } 437 438 /** 439 * 440 */ 441 @Test 442 public void test_compare_KeyPressed_03() { 443 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 444 445 IEventType eventType1 = new KeyPressed(VirtualKey.LETTER_A); 446 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 447 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 448 449 IEventType eventType2 = new KeyPressed(VirtualKey.LETTER_B); 450 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 451 452 assertSemanticallyEqual(task1, task2); 453 } 454 455 /** 456 * 457 */ 458 @Test 459 public void test_compare_KeyPressed_04() { 460 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 461 462 IEventType eventType1 = new KeyPressed(VirtualKey.LETTER_A); 463 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 464 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 465 466 IEventType eventType2 = new KeyPressed(VirtualKey.LETTER_A); 467 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 468 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 469 470 assertUnequal(task1, task2); 471 } 472 473 /** 474 * 475 */ 476 @Test 477 public void test_compare_KeyReleased_01() { 478 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 479 480 IEventType eventType1 = new KeyReleased(VirtualKey.LETTER_A); 481 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 482 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 483 484 assertLexicallyEqual(task1, task1); 485 } 486 487 /** 488 * 489 */ 490 @Test 491 public void test_compare_KeyReleased_02() { 492 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 493 494 IEventType eventType1 = new KeyReleased(VirtualKey.LETTER_A); 495 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 496 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 497 498 IEventType eventType2 = new KeyReleased(VirtualKey.LETTER_A); 499 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 500 501 assertLexicallyEqual(task1, task2); 502 } 503 504 /** 505 * 506 */ 507 @Test 508 public void test_compare_KeyReleased_03() { 509 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 510 511 IEventType eventType1 = new KeyReleased(VirtualKey.LETTER_A); 512 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 513 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 514 515 IEventType eventType2 = new KeyReleased(VirtualKey.LETTER_B); 516 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 517 518 assertSemanticallyEqual(task1, task2); 519 } 520 521 /** 522 * 523 */ 524 @Test 525 public void test_compare_KeyReleased_04() { 526 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 527 528 IEventType eventType1 = new KeyReleased(VirtualKey.LETTER_A); 529 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 530 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 531 532 IEventType eventType2 = new KeyReleased(VirtualKey.LETTER_A); 533 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 534 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 535 536 assertUnequal(task1, task2); 537 } 538 539 /** 540 * 541 */ 542 @Test 543 public void test_compare_KeyTyped_01() { 544 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 545 546 IEventType eventType1 = new KeyTyped(VirtualKey.LETTER_A); 547 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 548 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 549 550 assertLexicallyEqual(task1, task1); 551 } 552 553 /** 554 * 555 */ 556 @Test 557 public void test_compare_KeyTyped_02() { 558 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 559 560 IEventType eventType1 = new KeyTyped(VirtualKey.LETTER_A); 561 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 562 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 563 564 IEventType eventType2 = new KeyTyped(VirtualKey.LETTER_A); 565 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 566 567 assertLexicallyEqual(task1, task2); 568 } 569 570 /** 571 * 572 */ 573 @Test 574 public void test_compare_KeyTyped_03() { 575 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 576 577 IEventType eventType1 = new KeyTyped(VirtualKey.LETTER_A); 578 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 579 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 580 581 IEventType eventType2 = new KeyTyped(VirtualKey.LETTER_B); 582 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 583 584 assertSemanticallyEqual(task1, task2); 585 } 586 587 /** 588 * 589 */ 590 @Test 591 public void test_compare_KeyTyped_04() { 592 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 593 594 IEventType eventType1 = new KeyTyped(VirtualKey.LETTER_A); 595 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 596 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 597 598 IEventType eventType2 = new KeyTyped(VirtualKey.LETTER_A); 599 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 600 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 601 602 assertUnequal(task1, task2); 603 } 604 605 /** 606 * 607 */ 608 @Test 609 public void test_compare_MouseButtonDown_01() { 610 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 611 612 IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 613 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 614 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 615 616 assertLexicallyEqual(task1, task1); 617 } 618 619 /** 620 * 621 */ 622 @Test 623 public void test_compare_MouseButtonDown_02() { 624 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 625 626 IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 627 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 628 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 629 630 IEventType eventType2 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 631 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 632 633 assertLexicallyEqual(task1, task2); 634 } 635 636 /** 637 * 638 */ 639 @Test 640 public void test_compare_MouseButtonDown_03() { 641 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 642 643 IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 644 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 645 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 646 647 IEventType eventType2 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 3); 648 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 649 650 assertSemanticallyEqual(task1, task2); 651 } 652 653 /** 654 * 655 */ 656 @Test 657 public void test_compare_MouseButtonDown_04() { 658 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 659 660 IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 661 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 662 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 663 664 IEventType eventType2 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 3, 2); 665 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 666 667 assertSemanticallyEqual(task1, task2); 668 } 669 670 /** 671 * 672 */ 673 @Test 674 public void test_compare_MouseButtonDown_05() { 675 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 676 677 IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 678 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 679 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 680 681 IEventType eventType2 = new MouseButtonDown(MouseButtonInteraction.Button.RIGHT, 1, 2); 682 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 683 684 assertUnequal(task1, task2); 685 } 686 687 /** 688 * 689 */ 690 @Test 691 public void test_compare_MouseButtonDown_06() { 692 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 693 694 IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 695 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 696 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 697 698 IEventType eventType2 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 699 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 700 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 701 702 assertUnequal(task1, task2); 703 } 704 705 /** 706 * 707 */ 708 @Test 709 public void test_compare_MouseButtonUp_01() { 710 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 711 712 IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 713 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 714 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 715 716 assertLexicallyEqual(task1, task1); 717 } 718 719 /** 720 * 721 */ 722 @Test 723 public void test_compare_MouseButtonUp_02() { 724 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 725 726 IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 727 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 728 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 729 730 IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 731 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 732 733 assertLexicallyEqual(task1, task2); 734 } 735 736 /** 737 * 738 */ 739 @Test 740 public void test_compare_MouseButtonUp_03() { 741 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 742 743 IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 744 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 745 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 746 747 IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 3); 748 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 749 750 assertSemanticallyEqual(task1, task2); 751 } 752 753 /** 754 * 755 */ 756 @Test 757 public void test_compare_MouseButtonUp_04() { 758 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 759 760 IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 761 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 762 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 763 764 IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 3, 2); 765 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 766 767 assertSemanticallyEqual(task1, task2); 768 } 769 770 /** 771 * 772 */ 773 @Test 774 public void test_compare_MouseButtonUp_05() { 775 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 776 777 IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 778 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 779 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 780 781 IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.RIGHT, 1, 2); 782 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 783 784 assertUnequal(task1, task2); 785 } 786 787 /** 788 * 789 */ 790 @Test 791 public void test_compare_MouseButtonUp_06() { 792 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 793 794 IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 795 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 796 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 797 798 IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 799 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 800 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 801 802 assertUnequal(task1, task2); 803 } 804 805 /** 806 * 807 */ 808 @Test 809 public void test_compare_MouseClick_01() { 810 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 811 812 IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 813 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 814 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 815 816 assertLexicallyEqual(task1, task1); 817 } 818 819 /** 820 * 821 */ 822 @Test 823 public void test_compare_MouseClick_02() { 824 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 825 826 IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 827 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 828 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 829 830 IEventType eventType2 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 831 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 832 833 assertLexicallyEqual(task1, task2); 834 } 835 836 /** 837 * 838 */ 839 @Test 840 public void test_compare_MouseClick_03() { 841 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 842 843 IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 844 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 845 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 846 847 IEventType eventType2 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 3); 848 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 849 850 assertSemanticallyEqual(task1, task2); 851 } 852 853 /** 854 * 855 */ 856 @Test 857 public void test_compare_MouseClick_04() { 858 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 859 860 IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 861 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 862 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 863 864 IEventType eventType2 = new MouseClick(MouseButtonInteraction.Button.LEFT, 3, 2); 865 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 866 867 assertSemanticallyEqual(task1, task2); 868 } 869 870 /** 871 * 872 */ 873 @Test 874 public void test_compare_MouseClick_05() { 875 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 876 877 IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 878 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 879 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 880 881 IEventType eventType2 = new MouseClick(MouseButtonInteraction.Button.RIGHT, 1, 2); 882 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 883 884 assertUnequal(task1, task2); 885 } 886 887 /** 888 * 889 */ 890 @Test 891 public void test_compare_MouseClick_06() { 892 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 893 894 IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 895 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 896 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 897 898 IEventType eventType2 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 899 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 900 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 901 902 assertUnequal(task1, task2); 903 } 904 905 /** 906 * 907 */ 908 @Test 909 public void test_compare_MouseDoubleClick_01() { 910 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 911 912 IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 913 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 914 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 915 916 assertLexicallyEqual(task1, task1); 917 } 918 919 /** 920 * 921 */ 922 @Test 923 public void test_compare_MouseDoubleClick_02() { 924 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 925 926 IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 927 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 928 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 929 930 IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 931 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 932 933 assertLexicallyEqual(task1, task2); 934 } 935 936 /** 937 * 938 */ 939 @Test 940 public void test_compare_MouseDoubleClick_03() { 941 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 942 943 IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 944 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 945 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 946 947 IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 3); 948 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 949 950 assertSemanticallyEqual(task1, task2); 951 } 952 953 /** 954 * 955 */ 956 @Test 957 public void test_compare_MouseDoubleClick_04() { 958 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 959 960 IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 961 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 962 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 963 964 IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 3, 2); 965 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 966 967 assertSemanticallyEqual(task1, task2); 968 } 969 970 /** 971 * 972 */ 973 @Test 974 public void test_compare_MouseDoubleClick_05() { 975 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 976 977 IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 978 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 979 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 980 981 IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.RIGHT, 1, 2); 982 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 983 984 assertUnequal(task1, task2); 985 } 986 987 /** 988 * 989 */ 990 @Test 991 public void test_compare_MouseDoubleClick_06() { 992 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 993 994 IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 995 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 996 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 997 998 IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 999 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 1000 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 1001 1002 assertUnequal(task1, task2); 1003 } 1004 1005 /** 1006 * 1007 */ 1008 @Test 1009 public void test_compare_MouseDragAndDrop_01() { 1010 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1011 1012 IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 1013 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1014 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1015 1016 assertLexicallyEqual(task1, task1); 1017 } 1018 1019 /** 1020 * 1021 */ 1022 @Test 1023 public void test_compare_MouseDragAndDrop_02() { 1024 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1025 1026 IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 1027 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1028 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1029 1030 IEventType eventType2 = new MouseDragAndDrop(1, 2, 3, 4); 1031 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 1032 1033 assertLexicallyEqual(task1, task2); 1034 } 1035 1036 /** 1037 * 1038 */ 1039 @Test 1040 public void test_compare_MouseDragAndDrop_03() { 1041 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1042 1043 IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 1044 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1045 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1046 1047 IEventType eventType2 = new MouseDragAndDrop(5, 2, 3, 4); 1048 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 1049 1050 assertSemanticallyEqual(task1, task2); 1051 } 1052 1053 /** 1054 * 1055 */ 1056 @Test 1057 public void test_compare_MouseDragAndDrop_04() { 1058 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1059 1060 IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 1061 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1062 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1063 1064 IEventType eventType2 = new MouseDragAndDrop(1, 5, 3, 4); 1065 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 1066 1067 assertSemanticallyEqual(task1, task2); 1068 } 1069 1070 /** 1071 * 1072 */ 1073 @Test 1074 public void test_compare_MouseDragAndDrop_05() { 1075 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1076 1077 IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 1078 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1079 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1080 1081 IEventType eventType2 = new MouseDragAndDrop(1, 2, 5, 4); 1082 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 1083 1084 assertSemanticallyEqual(task1, task2); 1085 } 1086 1087 /** 1088 * 1089 */ 1090 @Test 1091 public void test_compare_MouseDragAndDrop_06() { 1092 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1093 1094 IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 1095 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1096 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1097 1098 IEventType eventType2 = new MouseDragAndDrop(1, 2, 3, 5); 1099 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 1100 1101 assertSemanticallyEqual(task1, task2); 1102 } 1103 1104 /** 1105 * 1106 */ 1107 @Test 1108 public void test_compare_MouseDragAndDrop_07() { 1109 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1110 1111 IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 1112 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1113 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1114 1115 IEventType eventType2 = new MouseDragAndDrop(1, 2, 3, 4); 1116 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 1117 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 1118 1119 assertUnequal(task1, task2); 1120 } 1121 1122 /** 1123 * 1124 */ 1125 @Test 1126 public void test_compare_Scroll_01() { 1127 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1128 1129 IEventType eventType1 = new Scroll(1, 2); 1130 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1131 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1132 1133 assertLexicallyEqual(task1, task1); 1134 } 1135 1136 /** 1137 * 1138 */ 1139 @Test 1140 public void test_compare_Scroll_02() { 1141 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1142 1143 IEventType eventType1 = new Scroll(1, 2); 1144 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1145 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1146 1147 IEventType eventType2 = new Scroll(1, 2); 1148 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 1149 1150 assertLexicallyEqual(task1, task2); 1151 } 1152 1153 /** 1154 * 1155 */ 1156 @Test 1157 public void test_compare_Scroll_03() { 1158 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1159 1160 IEventType eventType1 = new Scroll(1, 2); 1161 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1162 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1163 1164 IEventType eventType2 = new Scroll(3, 2); 1165 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 1166 1167 assertSemanticallyEqual(task1, task2); 1168 } 1169 1170 /** 1171 * 1172 */ 1173 @Test 1174 public void test_compare_Scroll_04() { 1175 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1176 1177 IEventType eventType1 = new Scroll(1, 2); 1178 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1179 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1180 1181 IEventType eventType2 = new Scroll(1, 3); 1182 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 1183 1184 assertSemanticallyEqual(task1, task2); 1185 } 1186 1187 /** 1188 * 1189 */ 1190 @Test 1191 public void test_compare_Scroll_05() { 1192 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1193 1194 IEventType eventType1 = new Scroll(1, 2); 1195 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1196 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1197 1198 IEventType eventType2 = new Scroll(1, 2); 1199 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 1200 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 1201 1202 assertUnequal(task1, task2); 1203 } 1204 1205 /** 1206 * 1207 */ 1208 @Test 1209 public void test_compare_TextInput_01() { 1210 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1211 1212 IEventType eventType1 = new StringEventType("eventType1"); 1213 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 92 1214 List<Event> textInputEvents1 = new ArrayList<Event>(); 93 1215 textInputEvents1.add(new Event(eventType1, eventTarget1)); 94 1216 eventType1 = new TextInput("enteredText1", textInputEvents1); 95 task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 96 97 assertEquals(NodeEquality.UNEQUAL, rule.compare(task1, task2)); 98 assertEquals(NodeEquality.UNEQUAL, rule.compare(task2, task1)); 99 100 eventType2 = new TextInput("enteredText1", textInputEvents1); 101 task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 102 103 assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, task2)); 104 assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task2, task1)); 105 1217 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1218 1219 assertLexicallyEqual(task1, task1); 1220 } 1221 1222 /** 1223 * 1224 */ 1225 @Test 1226 public void test_compare_TextInput_02() { 1227 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1228 1229 IEventType eventType1 = new StringEventType("eventType1"); 1230 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1231 List<Event> textInputEvents1 = new ArrayList<Event>(); 1232 textInputEvents1.add(new Event(eventType1, eventTarget1)); 1233 eventType1 = new TextInput("enteredText1", textInputEvents1); 1234 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1235 1236 IEventType eventType2 = new TextInput("enteredText1", textInputEvents1); 1237 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 1238 1239 assertLexicallyEqual(task1, task2); 1240 } 1241 1242 /** 1243 * 1244 */ 1245 @Test 1246 public void test_compare_TextInput_03() { 1247 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1248 1249 IEventType eventType1 = new StringEventType("eventType1"); 1250 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1251 List<Event> textInputEvents1 = new ArrayList<Event>(); 1252 textInputEvents1.add(new Event(eventType1, eventTarget1)); 1253 eventType1 = new TextInput("enteredText1", textInputEvents1); 1254 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1255 1256 IEventType eventType2 = new StringEventType("eventType2"); 106 1257 List<Event> textInputEvents2 = new ArrayList<Event>(); 107 1258 textInputEvents2.add(new Event(eventType2, eventTarget1)); 108 1259 eventType2 = new TextInput("enteredText1", textInputEvents2); 109 task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 1260 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 1261 1262 assertSyntacticallyEqual(task1, task2); 1263 } 1264 1265 /** 1266 * 1267 */ 1268 @Test 1269 public void test_compare_TextInput_04() { 1270 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1271 1272 IEventType eventType1 = new StringEventType("eventType1"); 1273 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1274 List<Event> textInputEvents1 = new ArrayList<Event>(); 1275 textInputEvents1.add(new Event(eventType1, eventTarget1)); 1276 eventType1 = new TextInput("enteredText1", textInputEvents1); 1277 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1278 1279 IEventType eventType2 = new StringEventType("eventType2"); 1280 List<Event> textInputEvents2 = new ArrayList<Event>(); 1281 textInputEvents2.add(new Event(eventType2, eventTarget1)); 1282 eventType2 = new TextInput("enteredText2", textInputEvents2); 1283 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 1284 1285 assertSemanticallyEqual(task1, task2); 1286 } 1287 1288 /** 1289 * 1290 */ 1291 @Test 1292 public void test_compare_TextInput_05() { 1293 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1294 1295 IEventType eventType1 = new StringEventType("eventType1"); 1296 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1297 List<Event> textInputEvents1 = new ArrayList<Event>(); 1298 textInputEvents1.add(new Event(eventType1, eventTarget1)); 1299 eventType1 = new TextInput("enteredText1", textInputEvents1); 1300 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1301 1302 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 1303 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType1, eventTarget2); 1304 1305 assertUnequal(task1, task2); 1306 } 1307 1308 /** 1309 * 1310 */ 1311 @Test 1312 public void test_compare_TextSelection_01() { 1313 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1314 1315 IEventType eventType1 = new TextSelection(); 1316 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1317 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1318 1319 assertLexicallyEqual(task1, task1); 1320 } 1321 1322 /** 1323 * 1324 */ 1325 @Test 1326 public void test_compare_TextSelection_02() { 1327 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1328 1329 IEventType eventType1 = new TextSelection(); 1330 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1331 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1332 1333 IEventType eventType2 = new TextSelection(); 1334 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 1335 1336 assertLexicallyEqual(task1, task2); 1337 } 1338 1339 /** 1340 * 1341 */ 1342 @Test 1343 public void test_compare_TextSelection_03() { 1344 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1345 1346 IEventType eventType1 = new TextSelection(); 1347 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1348 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1349 1350 IEventType eventType2 = new TextSelection(); 1351 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 1352 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 1353 1354 assertUnequal(task1, task2); 1355 } 1356 1357 /** 1358 * 1359 */ 1360 @Test 1361 public void test_compare_ValueSelection_01() { 1362 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1363 1364 IEventType eventType1 = new ValueSelection<String>("value1"); 1365 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1366 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1367 1368 assertLexicallyEqual(task1, task1); 1369 } 1370 1371 /** 1372 * 1373 */ 1374 @Test 1375 public void test_compare_ValueSelection_02() { 1376 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1377 1378 IEventType eventType1 = new ValueSelection<String>("value1"); 1379 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1380 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1381 1382 IEventType eventType2 = new ValueSelection<String>("value1"); 1383 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 1384 1385 assertLexicallyEqual(task1, task2); 1386 } 1387 1388 /** 1389 * 1390 */ 1391 @Test 1392 public void test_compare_ValueSelection_03() { 1393 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1394 1395 IEventType eventType1 = new ValueSelection<String>("value1"); 1396 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1397 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1398 1399 IEventType eventType2 = new ValueSelection<String>("value2"); 1400 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 1401 1402 assertSemanticallyEqual(task1, task2); 1403 } 1404 1405 /** 1406 * 1407 */ 1408 @Test 1409 public void test_compare_ValueSelection_04() { 1410 ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); 1411 1412 IEventType eventType1 = new ValueSelection<String>("value1"); 1413 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1414 ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 1415 1416 IEventType eventType2 = new ValueSelection<String>("value1"); 1417 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 1418 ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 1419 1420 assertUnequal(task1, task2); 1421 } 1422 1423 /** 1424 * 1425 */ 1426 private void assertLexicallyEqual(ITaskTreeNode task1, ITaskTreeNode task2) { 1427 GUIEventTaskComparisonRule rule = new GUIEventTaskComparisonRule(); 1428 1429 assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, task2)); 1430 assertTrue(rule.areLexicallyEqual(task1, task2)); 1431 assertTrue(rule.areSyntacticallyEqual(task1, task2)); 1432 assertTrue(rule.areSemanticallyEqual(task1, task2)); 1433 1434 assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task2, task1)); 1435 assertTrue(rule.areLexicallyEqual(task2, task1)); 1436 assertTrue(rule.areSyntacticallyEqual(task2, task1)); 1437 assertTrue(rule.areSemanticallyEqual(task2, task1)); 1438 } 1439 1440 /** 1441 * 1442 */ 1443 private void assertSyntacticallyEqual(ITaskTreeNode task1, ITaskTreeNode task2) { 1444 GUIEventTaskComparisonRule rule = new GUIEventTaskComparisonRule(); 110 1445 111 1446 assertEquals(NodeEquality.SYNTACTICALLY_EQUAL, rule.compare(task1, task2)); 1447 assertFalse(rule.areLexicallyEqual(task1, task2)); 1448 assertTrue(rule.areSyntacticallyEqual(task1, task2)); 1449 assertTrue(rule.areSemanticallyEqual(task1, task2)); 1450 112 1451 assertEquals(NodeEquality.SYNTACTICALLY_EQUAL, rule.compare(task2, task1)); 113 114 eventType2 = new TextInput("enteredText2", textInputEvents2); 115 task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1); 1452 assertFalse(rule.areLexicallyEqual(task2, task1)); 1453 assertTrue(rule.areSyntacticallyEqual(task2, task1)); 1454 assertTrue(rule.areSemanticallyEqual(task2, task1)); 1455 } 1456 1457 /** 1458 * 1459 */ 1460 private void assertSemanticallyEqual(ITaskTreeNode task1, ITaskTreeNode task2) { 1461 GUIEventTaskComparisonRule rule = new GUIEventTaskComparisonRule(); 116 1462 117 1463 assertEquals(NodeEquality.SEMANTICALLY_EQUAL, rule.compare(task1, task2)); 1464 assertFalse(rule.areLexicallyEqual(task1, task2)); 1465 assertFalse(rule.areSyntacticallyEqual(task1, task2)); 1466 assertTrue(rule.areSemanticallyEqual(task1, task2)); 1467 118 1468 assertEquals(NodeEquality.SEMANTICALLY_EQUAL, rule.compare(task2, task1)); 119 120 // now ensure unequality for all combinations, if the event targets do not match 121 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 122 eventType1 = new KeyboardFocusChange(); 123 task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 124 task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2); 1469 assertFalse(rule.areLexicallyEqual(task2, task1)); 1470 assertFalse(rule.areSyntacticallyEqual(task2, task1)); 1471 assertTrue(rule.areSemanticallyEqual(task2, task1)); 1472 } 1473 1474 /** 1475 * 1476 */ 1477 private void assertUnequal(ITaskTreeNode task1, ITaskTreeNode task2) { 1478 GUIEventTaskComparisonRule rule = new GUIEventTaskComparisonRule(); 1479 125 1480 assertEquals(NodeEquality.UNEQUAL, rule.compare(task1, task2)); 1481 assertFalse(rule.areLexicallyEqual(task1, task2)); 1482 assertFalse(rule.areSyntacticallyEqual(task1, task2)); 1483 assertFalse(rule.areSemanticallyEqual(task1, task2)); 1484 126 1485 assertEquals(NodeEquality.UNEQUAL, rule.compare(task2, task1)); 127 128 eventType1 = new ValueSelection<String>("value1"); 129 task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 130 task2 = treeNodeFactory.createNewEventTask(eventType1, eventTarget2); 131 assertEquals(NodeEquality.UNEQUAL, rule.compare(task1, task2)); 132 assertEquals(NodeEquality.UNEQUAL, rule.compare(task2, task1)); 133 134 eventType1 = new TextInput("enteredText1", textInputEvents1); 135 task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1); 136 task2 = treeNodeFactory.createNewEventTask(eventType1, eventTarget2); 137 assertEquals(NodeEquality.UNEQUAL, rule.compare(task1, task2)); 138 assertEquals(NodeEquality.UNEQUAL, rule.compare(task2, task1)); 139 140 ISelection selection = treeNodeFactory.createNewSelection(); 141 assertNull(rule.compare(task1, selection)); 142 assertNull(rule.compare(selection, task1)); 143 assertNull(rule.compare(task2, selection)); 144 assertNull(rule.compare(selection, task2)); 145 } 146 1486 assertFalse(rule.areLexicallyEqual(task2, task1)); 1487 assertFalse(rule.areSyntacticallyEqual(task2, task1)); 1488 assertFalse(rule.areSemanticallyEqual(task2, task1)); 1489 } 147 1490 } -
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/IterationComparisonRuleTest.java
r927 r1125 52 52 ITaskTreeNode task2 = new TaskTreeNode("task2"); 53 53 54 assert Null(rule.compare(task1, task2));54 assertFalse(rule.isApplicable(task1, task2)); 55 55 56 56 IIteration iteration1 = treeNodeFactory.createNewIteration(); 57 assertEquals(NodeEquality. IDENTICAL, rule.compare(iteration1, iteration1));57 assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration1)); 58 58 59 59 IIteration iteration2 = treeNodeFactory.createNewIteration(); … … 96 96 assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); 97 97 98 assert Null(rule.compare(iteration1, selection1));99 assert Null(rule.compare(selection1, iteration1));100 assert Null(rule.compare(iteration2, selection1));101 assert Null(rule.compare(selection1, iteration2));98 assertFalse(rule.isApplicable(iteration1, selection1)); 99 assertFalse(rule.isApplicable(selection1, iteration1)); 100 assertFalse(rule.isApplicable(iteration2, selection1)); 101 assertFalse(rule.isApplicable(selection1, iteration2)); 102 102 103 assert Null(rule.compare(iteration1, selection2));104 assert Null(rule.compare(selection2, iteration1));105 assert Null(rule.compare(iteration2, selection2));106 assert Null(rule.compare(selection2, iteration2));103 assertFalse(rule.isApplicable(iteration1, selection2)); 104 assertFalse(rule.isApplicable(selection2, iteration1)); 105 assertFalse(rule.isApplicable(iteration2, selection2)); 106 assertFalse(rule.isApplicable(selection2, iteration2)); 107 107 } 108 108 -
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/SelectionComparisonRuleTest.java
r927 r1125 52 52 ITaskTreeNode task2 = new TaskTreeNode("task2"); 53 53 54 assert Null(rule.compare(task1, task2));54 assertFalse(rule.isApplicable(task1, task2)); 55 55 56 56 ISelection selection1 = treeNodeFactory.createNewSelection(); 57 assertEquals(NodeEquality. IDENTICAL, rule.compare(selection1, selection1));57 assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection1)); 58 58 59 59 ISelection selection2 = treeNodeFactory.createNewSelection(); … … 93 93 94 94 ISequence sequence = treeNodeFactory.createNewSequence(); 95 assert Null(rule.compare(selection1, sequence));96 assert Null(rule.compare(sequence, selection1));97 assert Null(rule.compare(selection2, sequence));98 assert Null(rule.compare(sequence, selection2));99 assert Null(rule.compare(selection3, sequence));100 assert Null(rule.compare(sequence, selection3));95 assertFalse(rule.isApplicable(selection1, sequence)); 96 assertFalse(rule.isApplicable(sequence, selection1)); 97 assertFalse(rule.isApplicable(selection2, sequence)); 98 assertFalse(rule.isApplicable(sequence, selection2)); 99 assertFalse(rule.isApplicable(selection3, sequence)); 100 assertFalse(rule.isApplicable(sequence, selection3)); 101 101 } 102 102 -
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/SequenceComparisonRuleTest.java
r927 r1125 52 52 ITaskTreeNode task2 = new TaskTreeNode("task2"); 53 53 54 assert Null(rule.compare(task1, task2));54 assertFalse(rule.isApplicable(task1, task2)); 55 55 56 56 ISequence sequence1 = treeNodeFactory.createNewSequence(); 57 assertEquals(NodeEquality. IDENTICAL, rule.compare(sequence1, sequence1));57 assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(sequence1, sequence1)); 58 58 59 59 ISequence sequence2 = treeNodeFactory.createNewSequence(); … … 92 92 93 93 ISelection selection = treeNodeFactory.createNewSelection(); 94 assert Null(rule.compare(sequence1, selection));95 assert Null(rule.compare(selection, sequence1));96 assert Null(rule.compare(sequence2, selection));97 assert Null(rule.compare(selection, sequence2));98 assert Null(rule.compare(sequence3, selection));99 assert Null(rule.compare(selection, sequence3));94 assertFalse(rule.isApplicable(sequence1, selection)); 95 assertFalse(rule.isApplicable(selection, sequence1)); 96 assertFalse(rule.isApplicable(sequence2, selection)); 97 assertFalse(rule.isApplicable(selection, sequence2)); 98 assertFalse(rule.isApplicable(sequence3, selection)); 99 assertFalse(rule.isApplicable(selection, sequence3)); 100 100 } 101 101 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/EventTaskComparisonRule.java
r1113 r1125 28 28 public class EventTaskComparisonRule implements NodeComparisonRule { 29 29 30 /* 31 * (non-Javadoc) 32 * 33 * @see de.ugoe.cs.tasktree.nodeequality.NodeEqualityRule#apply(TaskTreeNode, TaskTreeNode) 30 /* (non-Javadoc) 31 * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 34 32 */ 35 33 @Override 36 public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 37 if ((!(node1 instanceof IEventTask)) || (!(node2 instanceof IEventTask))) { 38 return null; 39 } 34 public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 35 return (node1 instanceof IEventTask) && (node2 instanceof IEventTask); 36 } 40 37 41 if (node1 == node2) { 42 return NodeEquality.IDENTICAL; 43 } 44 38 /* (non-Javadoc) 39 * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 40 */ 41 @Override 42 public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 45 43 IEventTask task1 = (IEventTask) node1; 46 44 IEventTask task2 = (IEventTask) node2; 47 45 48 if (task1.getEventType().equals(task2.getEventType()) && 49 task1.getEventTarget().equals(task2.getEventTarget())) 50 { 46 return (task1.getEventType().equals(task2.getEventType()) && 47 task1.getEventTarget().equals(task2.getEventTarget())); 48 } 49 50 /* (non-Javadoc) 51 * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 52 */ 53 @Override 54 public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 55 return areLexicallyEqual(node1, node2); 56 } 57 58 /* (non-Javadoc) 59 * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 60 */ 61 @Override 62 public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 63 return areLexicallyEqual(node1, node2); 64 } 65 66 @Override 67 public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 68 if (areLexicallyEqual(node1, node2)) { 51 69 return NodeEquality.LEXICALLY_EQUAL; 52 70 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/GUIEventTaskComparisonRule.java
r1113 r1125 17 17 import de.ugoe.cs.autoquest.eventcore.IEventTarget; 18 18 import de.ugoe.cs.autoquest.eventcore.gui.IInteraction; 19 import de.ugoe.cs.autoquest.eventcore.gui.KeyInteraction; 20 import de.ugoe.cs.autoquest.eventcore.gui.KeyPressed; 21 import de.ugoe.cs.autoquest.eventcore.gui.KeyReleased; 22 import de.ugoe.cs.autoquest.eventcore.gui.KeyTyped; 23 import de.ugoe.cs.autoquest.eventcore.gui.MouseButtonDown; 24 import de.ugoe.cs.autoquest.eventcore.gui.MouseButtonInteraction; 25 import de.ugoe.cs.autoquest.eventcore.gui.MouseButtonUp; 19 26 import de.ugoe.cs.autoquest.eventcore.gui.MouseClick; 20 27 import de.ugoe.cs.autoquest.eventcore.gui.MouseDoubleClick; 21 28 import de.ugoe.cs.autoquest.eventcore.gui.MouseDragAndDrop; 29 import de.ugoe.cs.autoquest.eventcore.gui.Scroll; 22 30 import de.ugoe.cs.autoquest.eventcore.gui.TextInput; 23 31 import de.ugoe.cs.autoquest.eventcore.gui.ValueSelection; … … 27 35 import de.ugoe.cs.autoquest.eventcore.guimodel.IImage; 28 36 import de.ugoe.cs.autoquest.eventcore.guimodel.IListBox; 37 import de.ugoe.cs.autoquest.eventcore.guimodel.IMenu; 29 38 import de.ugoe.cs.autoquest.eventcore.guimodel.IMenuButton; 30 39 import de.ugoe.cs.autoquest.eventcore.guimodel.IRadioButton; … … 51 60 public class GUIEventTaskComparisonRule implements NodeComparisonRule { 52 61 53 /* 54 * (non-Javadoc) 55 * 56 * @see de.ugoe.cs.tasktree.nodeequality.NodeEqualityRule#apply(TaskTreeNode, TaskTreeNode) 62 /* (non-Javadoc) 63 * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 64 */ 65 @Override 66 public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 67 return 68 ((node1 instanceof IEventTask) && (node2 instanceof IEventTask) && 69 (((IEventTask) node1).getEventType() instanceof IInteraction) && 70 (((IEventTask) node2).getEventType() instanceof IInteraction)); 71 } 72 73 /* (non-Javadoc) 74 * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 75 */ 76 @Override 77 public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 78 NodeEquality equality = getEquality(node1, node2, NodeEquality.LEXICALLY_EQUAL); 79 return (equality != null) && (equality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 80 } 81 82 /* (non-Javadoc) 83 * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 84 */ 85 @Override 86 public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 87 NodeEquality equality = getEquality(node1, node2, NodeEquality.SYNTACTICALLY_EQUAL); 88 return (equality != null) && (equality.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 89 } 90 91 /* (non-Javadoc) 92 * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 93 */ 94 @Override 95 public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 96 NodeEquality equality = getEquality(node1, node2, NodeEquality.SEMANTICALLY_EQUAL); 97 return (equality != null) && (equality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 98 } 99 100 /* (non-Javadoc) 101 * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 57 102 */ 58 103 @Override 59 104 public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 60 if ((!(node1 instanceof IEventTask)) || (!(node2 instanceof IEventTask))) { 61 return null; 62 } 63 105 return getEquality(node1, node2, null); 106 } 107 108 /** 109 * 110 */ 111 private NodeEquality getEquality(ITaskTreeNode node1, 112 ITaskTreeNode node2, 113 NodeEquality requiredEqualityLevel) 114 { 64 115 IEventTask task1 = (IEventTask) node1; 65 116 IEventTask task2 = (IEventTask) node2; 66 117 67 if ((!(task1.getEventType() instanceof IInteraction)) ||68 (!(task2.getEventType() instanceof IInteraction)))69 {70 return null;71 }72 73 if (node1 == node2) {74 return NodeEquality.IDENTICAL;75 }76 77 118 if (!task1.getEventTarget().equals(task2.getEventTarget())) { 78 119 return NodeEquality.UNEQUAL; … … 82 123 IInteraction interaction2 = (IInteraction) task2.getEventType(); 83 124 84 return compareInteractions(interaction1, interaction2, task1.getEventTarget()); 125 return compareInteractions 126 (interaction1, interaction2, task1.getEventTarget(), requiredEqualityLevel); 85 127 } 86 128 … … 105 147 private NodeEquality compareInteractions(IInteraction interaction1, 106 148 IInteraction interaction2, 107 IEventTarget eventTarget) 108 { 149 IEventTarget eventTarget, 150 NodeEquality equalityLevel) 151 { 152 NodeEquality level = equalityLevel; 153 154 if (level == null) { 155 level = NodeEquality.LEXICALLY_EQUAL; 156 } 157 109 158 if (interaction1 == interaction2) { 110 159 return NodeEquality.LEXICALLY_EQUAL; 111 160 } 161 else if ((interaction1 instanceof KeyInteraction) && 162 (interaction2 instanceof KeyInteraction)) 163 { 164 return compareKeyInteractions 165 ((KeyInteraction) interaction1, (KeyInteraction) interaction2, level); 166 } 167 else if ((interaction1 instanceof MouseButtonInteraction) && 168 (interaction2 instanceof MouseButtonInteraction)) 169 { 170 return compareMouseButtonInteractions 171 ((MouseButtonInteraction) interaction1, (MouseButtonInteraction) interaction2, 172 eventTarget, level); 173 } 174 else if ((interaction1 instanceof Scroll) && (interaction2 instanceof Scroll)) { 175 return compareScrolls((Scroll) interaction1, (Scroll) interaction2, level); 176 } 112 177 else if ((interaction1 instanceof TextInput) && (interaction2 instanceof TextInput)) { 113 return compareTextInputs((TextInput) interaction1, (TextInput) interaction2); 178 return compareTextInputs 179 ((TextInput) interaction1, (TextInput) interaction2, level); 114 180 } 115 181 else if ((interaction1 instanceof ValueSelection) && … … 117 183 { 118 184 return compareValueSelections 119 ((ValueSelection<?>) interaction1, (ValueSelection<?>) interaction2); 120 } 121 else if ((interaction1 instanceof MouseClick) && 122 (interaction2 instanceof MouseClick)) 123 { 124 return compareMouseClicks 125 ((MouseClick) interaction1, (MouseClick) interaction2, eventTarget); 126 } 127 else if ((interaction1 instanceof MouseDoubleClick) && 128 (interaction2 instanceof MouseDoubleClick)) 129 { 130 return compareMouseDoubleClicks 131 ((MouseDoubleClick) interaction1, (MouseDoubleClick) interaction2, eventTarget); 132 } 133 else if ((interaction1 instanceof MouseDragAndDrop) && 134 (interaction2 instanceof MouseDragAndDrop)) 135 { 136 return compareMouseDragAndDrops 137 ((MouseDragAndDrop) interaction1, (MouseDragAndDrop) interaction2); 185 ((ValueSelection<?>) interaction1, (ValueSelection<?>) interaction2, level); 138 186 } 139 187 else if (interaction1.equals(interaction2)) { … … 143 191 return NodeEquality.UNEQUAL; 144 192 } 193 } 194 195 /** 196 * <p> 197 * TODO: comment 198 * </p> 199 * 200 * @param interaction1 201 * @param interaction2 202 * @param eventTarget 203 * @param level 204 * @return 205 */ 206 private NodeEquality compareKeyInteractions(KeyInteraction interaction1, 207 KeyInteraction interaction2, 208 NodeEquality equalityLevel) 209 { 210 if (((interaction1 instanceof KeyPressed) && (interaction2 instanceof KeyPressed)) || 211 ((interaction1 instanceof KeyReleased) && (interaction2 instanceof KeyReleased)) || 212 ((interaction1 instanceof KeyTyped) && (interaction2 instanceof KeyTyped))) 213 { 214 if ((equalityLevel.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)) && 215 (interaction1.getKey() == interaction2.getKey())) 216 { 217 return NodeEquality.LEXICALLY_EQUAL; 218 } 219 else { 220 return NodeEquality.SEMANTICALLY_EQUAL; 221 } 222 } 223 224 return NodeEquality.UNEQUAL; 225 } 226 227 /** 228 * <p> 229 * compares two mouse drag and drops. If both drag and drops have the same start and end 230 * coordinates, they are lexically equal. Otherwise, they are semantically equal. 231 * </p> 232 * 233 * @param interaction1 the first mouse drag and drop to compare 234 * @param interaction2 the second mouse drag and drop to compare 235 * 236 * @return as described 237 */ 238 private NodeEquality compareMouseDragAndDrops(MouseDragAndDrop interaction1, 239 MouseDragAndDrop interaction2, 240 NodeEquality equalityLevel) 241 { 242 if (interaction1.getButton() != interaction2.getButton()) { 243 return NodeEquality.UNEQUAL; 244 } 245 246 if (equalityLevel.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)) { 247 int x1 = interaction1.getX(); 248 int x1Start = interaction1.getXStart(); 249 int x2 = interaction2.getX(); 250 int x2Start = interaction2.getXStart(); 251 int y1 = interaction1.getY(); 252 int y1Start = interaction1.getYStart(); 253 int y2 = interaction2.getY(); 254 int y2Start = interaction2.getYStart(); 255 256 if ((x1Start == x2Start) && (x1 == x2) && (y1Start == y2Start) && (y1 == y2)) { 257 return NodeEquality.LEXICALLY_EQUAL; 258 } 259 } 260 261 return NodeEquality.SEMANTICALLY_EQUAL; 262 } 263 264 /** 265 * <p> 266 * compares two mouse button interactions such as clicks, mouse button down, or double clicks. 267 * If both interactions have the same coordinates, they are lexically equal. Otherwise, they 268 * are semantically equal. Mouse clicks for which the coordinates make no lexical difference 269 * (see {@link #clickCoordinatesMakeLexicalDifference(IEventTarget)}) are treated as 270 * lexically equal. 271 * </p> 272 * 273 * @param interaction1 the first mouse button interaction to compare 274 * @param interaction2 the second mouse button interaction to compare 275 * @param eventTarget the event target on which the interactions happened (used within 276 * special comparisons like mouse clicks on buttons, where the coordinates 277 * can be ignored) 278 * 279 * @return as described 280 */ 281 private NodeEquality compareMouseButtonInteractions(MouseButtonInteraction interaction1, 282 MouseButtonInteraction interaction2, 283 IEventTarget eventTarget, 284 NodeEquality equalityLevel) 285 { 286 boolean coordinatesMatch = true; 287 288 if ((interaction1 instanceof MouseDragAndDrop) && 289 (interaction2 instanceof MouseDragAndDrop)) 290 { 291 return compareMouseDragAndDrops 292 ((MouseDragAndDrop) interaction1, (MouseDragAndDrop) interaction2, equalityLevel); 293 } 294 else if (interaction1.getButton() != interaction2.getButton()) { 295 return NodeEquality.UNEQUAL; 296 } 297 else if (equalityLevel.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL) && 298 clickCoordinatesMakeLexicalDifference(eventTarget)) 299 { 300 int x1 = interaction1.getX(); 301 int x2 = interaction2.getX(); 302 int y1 = interaction1.getY(); 303 int y2 = interaction2.getY(); 304 305 if ((x1 != x2) || (y1 != y2)) { 306 coordinatesMatch = false; 307 } 308 } 309 310 // up to now, they can be equal. Now check the types. Do it as last action as these 311 // checks take the most time and should, therefore, only be done latest 312 if (((interaction1 instanceof MouseClick) && (interaction2 instanceof MouseClick)) || 313 ((interaction1 instanceof MouseDoubleClick) && 314 (interaction2 instanceof MouseDoubleClick)) || 315 ((interaction1 instanceof MouseButtonDown) && 316 (interaction2 instanceof MouseButtonDown)) || 317 ((interaction1 instanceof MouseButtonUp) && 318 (interaction2 instanceof MouseButtonUp))) 319 { 320 if (coordinatesMatch) { 321 return NodeEquality.LEXICALLY_EQUAL; 322 } 323 else { 324 return NodeEquality.SEMANTICALLY_EQUAL; 325 } 326 } 327 328 return NodeEquality.UNEQUAL; 329 } 330 331 /** 332 * <p> 333 * compares two mouse button interactions such as clicks, mouse button down, or double clicks. 334 * If both interactions have the same coordinates, they are lexically equal. Otherwise, they 335 * are semantically equal. Mouse clicks for which the coordinates make no lexical difference 336 * (see {@link #clickCoordinatesMakeLexicalDifference(IEventTarget)}) are treated as 337 * lexically equal. 338 * </p> 339 * 340 * @param interaction1 the first mouse button interaction to compare 341 * @param interaction2 the second mouse button interaction to compare 342 * @param eventTarget the event target on which the interactions happened (used within 343 * special comparisons like mouse clicks on buttons, where the coordinates 344 * can be ignored) 345 * 346 * @return as described 347 */ 348 private NodeEquality compareScrolls(Scroll interaction1, 349 Scroll interaction2, 350 NodeEquality equalityLevel) 351 { 352 if (equalityLevel.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)) { 353 int x1 = interaction1.getXPosition(); 354 int x2 = interaction2.getXPosition(); 355 int y1 = interaction1.getYPosition(); 356 int y2 = interaction2.getYPosition(); 357 358 if ((x1 == x2) && (y1 == y2)) { 359 return NodeEquality.LEXICALLY_EQUAL; 360 } 361 } 362 363 return NodeEquality.SEMANTICALLY_EQUAL; 145 364 } 146 365 … … 158 377 * @return as described 159 378 */ 160 private NodeEquality compareTextInputs(TextInput interaction1, TextInput interaction2) { 161 if (interaction1.getEnteredText().equals(interaction2.getEnteredText())) { 162 if (interaction1.getTextInputEvents().equals(interaction2.getTextInputEvents())) { 163 return NodeEquality.LEXICALLY_EQUAL; 164 } 165 else { 166 return NodeEquality.SYNTACTICALLY_EQUAL; 167 } 168 } 169 else { 170 return NodeEquality.SEMANTICALLY_EQUAL; 379 private NodeEquality compareTextInputs(TextInput interaction1, 380 TextInput interaction2, 381 NodeEquality equalityLevel) 382 { 383 switch (equalityLevel) { 384 case LEXICALLY_EQUAL: 385 if (interaction1.getTextInputEvents().equals(interaction2.getTextInputEvents())) { 386 return NodeEquality.LEXICALLY_EQUAL; 387 } 388 // fall through 389 case SYNTACTICALLY_EQUAL: 390 if (interaction1.getEnteredText().equals(interaction2.getEnteredText())) { 391 return NodeEquality.SYNTACTICALLY_EQUAL; 392 } 393 // fall through 394 case SEMANTICALLY_EQUAL: 395 return NodeEquality.SEMANTICALLY_EQUAL; 396 default: 397 return NodeEquality.UNEQUAL; 171 398 } 172 399 } … … 185 412 */ 186 413 private NodeEquality compareValueSelections(ValueSelection<?> interaction1, 187 ValueSelection<?> interaction2) 188 { 189 Object value1 = interaction1.getSelectedValue(); 190 Object value2 = interaction2.getSelectedValue(); 191 192 if ((value1 == value2) || ((value1 != null) && (value1.equals(value2)))) { 193 return NodeEquality.LEXICALLY_EQUAL; 194 } 195 else { 196 return NodeEquality.SEMANTICALLY_EQUAL; 197 } 198 } 199 200 /** 201 * <p> 202 * compares two mouse clicks. If both clicks have the same coordinates, they are lexically 203 * equal. Otherwise, they are semantically equal. Mouse clicks for which the coordinates make 204 * no lexical difference (see {@link #clickCoordinatesMakeLexicalDifference(IEventTarget)}) 205 * are treated as lexically equal. 206 * </p> 207 * 208 * @param interaction1 the first mouse click to compare 209 * @param interaction2 the second mouse click to compare 210 * @param eventTarget the event target on which the interactions happened (used within 211 * special comparisons like mouse clicks on buttons, where the coordinates 212 * can be ignored) 213 * 214 * @return as described 215 */ 216 private NodeEquality compareMouseClicks(MouseClick interaction1, 217 MouseClick interaction2, 218 IEventTarget eventTarget) 219 { 220 if (interaction1.getButton() != interaction2.getButton()) { 221 return NodeEquality.UNEQUAL; 222 } 223 224 if (!clickCoordinatesMakeLexicalDifference(eventTarget)) { 225 return NodeEquality.LEXICALLY_EQUAL; 226 } 227 228 int x1 = interaction1.getX(); 229 int x2 = interaction2.getX(); 230 int y1 = interaction1.getY(); 231 int y2 = interaction2.getY(); 232 233 if ((x1 == x2) && (y1 == y2)) { 234 return NodeEquality.LEXICALLY_EQUAL; 235 } 236 else { 237 return NodeEquality.SEMANTICALLY_EQUAL; 238 } 239 } 240 241 /** 242 * <p> 243 * compares two mouse double clicks. If both double clicks have the same coordinates, they are 244 * lexically equal. Otherwise, they are semantically equal. Double clicks for which the 245 * coordinates make no lexical difference 246 * (see {@link #clickCoordinatesMakeLexicalDifference(IEventTarget)}) are treated as lexically 247 * equal. 248 * </p> 249 * 250 * @param interaction1 the first mouse double click to compare 251 * @param interaction2 the second mouse double click to compare 252 * @param eventTarget the event target on which the interactions happened (used within 253 * special comparisons like mouse clicks on buttons, where the coordinates 254 * can be ignored) 255 * 256 * @return as described 257 */ 258 private NodeEquality compareMouseDoubleClicks(MouseDoubleClick interaction1, 259 MouseDoubleClick interaction2, 260 IEventTarget eventTarget) 261 { 262 if (interaction1.getButton() != interaction2.getButton()) { 263 return NodeEquality.UNEQUAL; 264 } 265 266 if (!clickCoordinatesMakeLexicalDifference(eventTarget)) { 267 return NodeEquality.LEXICALLY_EQUAL; 268 } 269 270 int x1 = interaction1.getX(); 271 int x2 = interaction2.getX(); 272 int y1 = interaction1.getY(); 273 int y2 = interaction2.getY(); 274 275 if ((x1 == x2) && (y1 == y2)) { 276 return NodeEquality.LEXICALLY_EQUAL; 277 } 278 else { 279 return NodeEquality.SEMANTICALLY_EQUAL; 280 } 281 } 282 283 /** 284 * <p> 285 * compares two mouse drag and drops. If both drag and drops have the same start and end 286 * coordinates, they are lexically equal. Otherwise, they are semantically equal. 287 * </p> 288 * 289 * @param interaction1 the first mouse drag and drop to compare 290 * @param interaction2 the second mouse drag and drop to compare 291 * 292 * @return as described 293 */ 294 private NodeEquality compareMouseDragAndDrops(MouseDragAndDrop interaction1, 295 MouseDragAndDrop interaction2) 296 { 297 if (interaction1.getButton() != interaction2.getButton()) { 298 return NodeEquality.UNEQUAL; 299 } 300 301 int x1 = interaction1.getX(); 302 int x1Start = interaction1.getXStart(); 303 int x2 = interaction2.getX(); 304 int x2Start = interaction2.getXStart(); 305 int y1 = interaction1.getY(); 306 int y1Start = interaction1.getYStart(); 307 int y2 = interaction2.getY(); 308 int y2Start = interaction2.getYStart(); 309 310 if ((x1Start == x2Start) && (x1 == x2) && (y1Start == y2Start) && (y1 == y2)) { 311 return NodeEquality.LEXICALLY_EQUAL; 312 } 313 else { 314 return NodeEquality.SEMANTICALLY_EQUAL; 315 } 414 ValueSelection<?> interaction2, 415 NodeEquality equalityLevel) 416 { 417 if (equalityLevel.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)) { 418 Object value1 = interaction1.getSelectedValue(); 419 Object value2 = interaction2.getSelectedValue(); 420 421 if ((value1 == value2) || ((value1 != null) && (value1.equals(value2)))) { 422 return NodeEquality.LEXICALLY_EQUAL; 423 } 424 } 425 426 return NodeEquality.SEMANTICALLY_EQUAL; 316 427 } 317 428 … … 336 447 (eventTarget instanceof IImage) || 337 448 (eventTarget instanceof IListBox) || 449 (eventTarget instanceof IMenu) || 338 450 (eventTarget instanceof IMenuButton) || 339 451 (eventTarget instanceof IRadioButton) || -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/IterationComparisonRule.java
r1113 r1125 15 15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 16 16 17 import java.util.List; 18 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 17 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 18 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 19 23 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 20 24 … … 95 99 } 96 100 97 /* 98 * (non-Javadoc) 99 * 100 * @see de.ugoe.cs.tasktree.nodeequality.NodeEqualityRule#apply(TaskTreeNode, TaskTreeNode) 101 /* (non-Javadoc) 102 * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 103 */ 104 @Override 105 public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 106 return (node1 instanceof IIteration) && (node2 instanceof IIteration); 107 } 108 109 /* (non-Javadoc) 110 * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 111 */ 112 @Override 113 public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 114 List<ITaskTreeNode> children1 = node1.getChildren(); 115 List<ITaskTreeNode> children2 = node2.getChildren(); 116 117 if (children1.size() == children2.size()) { 118 if (children1.size() == 0) { 119 return true; 120 } 121 else { 122 ITaskTreeNode child1 = children1.get(0); 123 ITaskTreeNode child2 = children2.get(0); 124 125 // iterations may have 3 different structures. 126 // 1. they have one child, which is the iterated one 127 // 2. they have a sequence of children, which is iterated 128 // 3. they have a selection of different iterated variants (usually the variants 129 // are semantically equal) 130 // check if the type of children match. If not, return false. If they match, 131 // use the equality manager to perform further comparisons 132 133 if (((child1 instanceof ISelection) && (child2 instanceof ISelection)) || 134 ((child1 instanceof ISequence) && (child2 instanceof ISequence)) || 135 ((child1 instanceof IEventTask) && (child2 instanceof IEventTask))) 136 { 137 return getNodeEquality 138 (child1, child2).isAtLeast(NodeEquality.LEXICALLY_EQUAL); 139 } 140 } 141 } 142 143 return false; 144 } 145 146 /* (non-Javadoc) 147 * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 148 */ 149 @Override 150 public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 151 List<ITaskTreeNode> children1 = node1.getChildren(); 152 List<ITaskTreeNode> children2 = node2.getChildren(); 153 154 if (children1.size() == children2.size()) { 155 if (children1.size() == 0) { 156 return true; 157 } 158 else { 159 ITaskTreeNode child1 = children1.get(0); 160 ITaskTreeNode child2 = children2.get(0); 161 162 // iterations may have 3 different structures. 163 // 1. they have one child, which is the iterated one 164 // 2. they have a sequence of children, which is iterated 165 // 3. they have a selection of different iterated variants (usually the variants 166 // are semantically equal) 167 // ignore the type of the children but check them for equality. 168 169 return getNodeEquality(child1, child2).isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL); 170 } 171 } 172 173 return false; 174 } 175 176 /* (non-Javadoc) 177 * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 178 */ 179 @Override 180 public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 181 return compare(node1, node2).isAtLeast(NodeEquality.SEMANTICALLY_EQUAL); 182 } 183 184 /* (non-Javadoc) 185 * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 101 186 */ 102 187 @Override 103 188 public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 104 if ((!(node1 instanceof IIteration)) || (!(node2 instanceof IIteration))) { 105 return null; 106 } 107 108 if (node1 == node2) { 109 return NodeEquality.IDENTICAL; 110 } 189 List<ITaskTreeNode> children1 = node1.getChildren(); 190 List<ITaskTreeNode> children2 = node2.getChildren(); 111 191 112 192 // if both iterations do not have children, they are equal although this doesn't make sense 113 if (( node1.getChildren().size() == 0) && (node2.getChildren().size() == 0)) {193 if ((children1.size() == 0) && (children2.size() == 0)) { 114 194 return NodeEquality.LEXICALLY_EQUAL; 115 195 } 116 else if (( node1.getChildren().size() == 0) || (node2.getChildren().size() == 0)) {196 else if ((children1.size() == 0) || (children2.size() == 0)) { 117 197 return NodeEquality.UNEQUAL; 118 198 } 119 199 120 ITaskTreeNode child1 = node1.getChildren().get(0);121 ITaskTreeNode child2 = node2.getChildren().get(0);200 ITaskTreeNode child1 = children1.get(0); 201 ITaskTreeNode child2 = children2.get(0); 122 202 123 203 // iterations may have 3 different structures. … … 132 212 // This condition matches, if both iterations are the same variants of iteration. I.e. three 133 213 // combinations of the permutation are handled herewith. 134 NodeEquality nodeEquality = mRuleManager.applyRules(child1, child2); 214 NodeEquality nodeEquality = getNodeEquality(child1, child2); 215 216 if (nodeEquality != null) { 217 return nodeEquality; 218 } 219 220 // compare one iteration with a single node as a child and another one with a selection of 221 // semantically equal nodes 222 return selectionChildrenSemanticallyEqualNode(child1, child2); 223 224 // all other combinations (i.e. sequence with single child and sequence with selection) 225 // can not match 226 } 227 228 /** 229 * TODO update comment 230 */ 231 private NodeEquality getNodeEquality(ITaskTreeNode child1, ITaskTreeNode child2) { 232 NodeEquality nodeEquality = callRuleManager(child1, child2, null); 135 233 136 234 if (nodeEquality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)) { … … 144 242 } 145 243 } 146 147 // compare one iteration with a single node as a child and another one with a selection of 148 // semantically equal nodes 149 return selectionChildrenSemanticallyEqualNode(child1, child2); 150 151 // all other combinations (i.e. sequence with single child and sequence with selection) 152 // can not match 244 245 return NodeEquality.UNEQUAL; 153 246 } 154 247 … … 189 282 190 283 for (ITaskTreeNode child : selection.getChildren()) { 191 NodeEquality nodeEquality = mRuleManager.applyRules(node, child); 284 NodeEquality nodeEquality = 285 callRuleManager(node, child, commonDenominatorForAllComparisons); 192 286 193 287 if ((nodeEquality == null) || (nodeEquality == NodeEquality.UNEQUAL)) … … 203 297 } 204 298 299 /** 300 * <p> 301 * TODO: comment 302 * </p> 303 * 304 * @param child1 305 * @param child2 306 * @param requiredEqualityLevel 307 * @return 308 */ 309 private NodeEquality callRuleManager(ITaskTreeNode child1, 310 ITaskTreeNode child2, 311 NodeEquality requiredEqualityLevel) 312 { 313 if (requiredEqualityLevel == null) { 314 return mRuleManager.compare(child1, child2); 315 } 316 else if (mRuleManager.areAtLeastEqual(child1, child2, requiredEqualityLevel)) { 317 return requiredEqualityLevel; 318 } 319 else { 320 return NodeEquality.UNEQUAL; 321 } 322 } 205 323 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/NodeAndIterationComparisonRule.java
r1113 r1125 14 14 15 15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 16 17 import java.util.List; 16 18 17 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; … … 48 50 } 49 51 50 /* 51 * (non-Javadoc) 52 * 53 * @see de.ugoe.cs.tasktree.nodeequality.NodeEqualityRule#apply(TaskTreeNode, TaskTreeNode) 52 /* (non-Javadoc) 53 * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 54 */ 55 @Override 56 public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 57 return ((node1 instanceof IIteration) && (!(node2 instanceof IIteration))) || 58 ((node2 instanceof IIteration) && (!(node1 instanceof IIteration))); 59 } 60 61 /* (non-Javadoc) 62 * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 63 */ 64 @Override 65 public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 66 NodeEquality equality = getEquality(node1, node2, NodeEquality.LEXICALLY_EQUAL); 67 return (equality != null) && (equality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 68 } 69 70 /* (non-Javadoc) 71 * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 72 */ 73 @Override 74 public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 75 NodeEquality equality = getEquality(node1, node2, NodeEquality.SYNTACTICALLY_EQUAL); 76 return (equality != null) && (equality.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 77 } 78 79 /* (non-Javadoc) 80 * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 81 */ 82 @Override 83 public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 84 NodeEquality equality = getEquality(node1, node2, NodeEquality.SEMANTICALLY_EQUAL); 85 return (equality != null) && (equality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 86 } 87 88 /* (non-Javadoc) 89 * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 54 90 */ 55 91 @Override 56 92 public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 93 return getEquality(node1, node2, null); 94 } 95 96 /** 97 * 98 */ 99 private NodeEquality getEquality(ITaskTreeNode node1, 100 ITaskTreeNode node2, 101 NodeEquality requiredEqualityLevel) 102 { 57 103 IIteration iteration = null; 58 104 ITaskTreeNode node = null; … … 80 126 } 81 127 128 List<ITaskTreeNode> children = iteration.getChildren(); 129 82 130 // now, that we found the iteration and the node, lets compare the child of the iteration 83 131 // with the node. 84 if ( iteration.getChildren().size() < 1) {132 if (children.size() < 1) { 85 133 return null; 86 134 } 87 135 88 NodeEquality nodeEquality = mRuleManager.applyRules(iteration.getChildren().get(0), node);136 NodeEquality nodeEquality = callRuleManager(children.get(0), node, requiredEqualityLevel); 89 137 90 138 // although the subtask may be identical to the node, we can not return identical, as … … 98 146 99 147 } 148 149 /** 150 * <p> 151 * TODO: comment 152 * </p> 153 * 154 * @param child1 155 * @param child2 156 * @param requiredEqualityLevel 157 * @return 158 */ 159 private NodeEquality callRuleManager(ITaskTreeNode child1, 160 ITaskTreeNode child2, 161 NodeEquality requiredEqualityLevel) 162 { 163 if (requiredEqualityLevel == null) { 164 return mRuleManager.compare(child1, child2); 165 } 166 else if (mRuleManager.areAtLeastEqual(child1, child2, requiredEqualityLevel)) { 167 return requiredEqualityLevel; 168 } 169 else { 170 return NodeEquality.UNEQUAL; 171 } 172 } 100 173 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/NodeAndSelectionComparisonRule.java
r1113 r1125 14 14 15 15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 16 17 import java.util.List; 16 18 17 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; … … 33 35 /** the rule manager for internally comparing task tree nodes */ 34 36 private NodeEqualityRuleManager mRuleManager; 35 37 36 38 /** 37 39 * <p> … … 47 49 } 48 50 49 /* 50 * (non-Javadoc) 51 * 52 * @see de.ugoe.cs.tasktree.nodeequality.NodeEqualityRule#apply(TaskTreeNode, TaskTreeNode) 51 /* (non-Javadoc) 52 * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 53 */ 54 @Override 55 public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 56 return ((node1 instanceof ISelection) && (!(node2 instanceof ISelection))) || 57 ((node2 instanceof ISelection) && (!(node1 instanceof ISelection))); 58 } 59 60 /* (non-Javadoc) 61 * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 62 */ 63 @Override 64 public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 65 NodeEquality equality = getEquality(node1, node2, NodeEquality.LEXICALLY_EQUAL); 66 return (equality != null) && (equality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 67 } 68 69 /* (non-Javadoc) 70 * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 71 */ 72 @Override 73 public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 74 NodeEquality equality = getEquality(node1, node2, NodeEquality.SYNTACTICALLY_EQUAL); 75 return (equality != null) && (equality.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 76 } 77 78 /* (non-Javadoc) 79 * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 80 */ 81 @Override 82 public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 83 NodeEquality equality = getEquality(node1, node2, NodeEquality.SEMANTICALLY_EQUAL); 84 return (equality != null) && (equality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 85 } 86 87 /* (non-Javadoc) 88 * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 53 89 */ 54 90 @Override 55 91 public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 92 return getEquality(node1, node2, null); 93 } 94 95 /** 96 * 97 */ 98 private NodeEquality getEquality(ITaskTreeNode node1, 99 ITaskTreeNode node2, 100 NodeEquality requiredEqualityLevel) 101 { 56 102 ISelection selection = null; 57 103 ITaskTreeNode node = null; … … 59 105 if (node1 instanceof ISelection) { 60 106 if (node2 instanceof ISelection) { 61 // the rule is not responsible for two iterations107 // the rule is not responsible for two selections 62 108 return null; 63 109 } … … 68 114 else if (node2 instanceof ISelection) { 69 115 if (node1 instanceof ISelection) { 70 // the rule is not responsible for two iterations116 // the rule is not responsible for two selections 71 117 return null; 72 118 } … … 79 125 } 80 126 81 // now, that we found the iteration and the node, lets compare the child of the iteration127 // now, that we found the selection and the node, lets compare the children of the selection 82 128 // with the node. 83 if (selection.getChildren().size() < 1) { 129 List<ITaskTreeNode> children = selection.getChildren(); 130 131 if (children.size() < 1) { 84 132 return null; 85 133 } … … 87 135 NodeEquality mostConcreteNodeEquality = null; 88 136 89 for (ITaskTreeNode child : selection.getChildren()) {90 NodeEquality nodeEquality = mRuleManager.applyRules(child, node);137 for (ITaskTreeNode child : children) { 138 NodeEquality nodeEquality = callRuleManager(child, node, requiredEqualityLevel); 91 139 92 140 if (nodeEquality != NodeEquality.UNEQUAL) { … … 94 142 mostConcreteNodeEquality = nodeEquality; 95 143 } 96 else { 97 mostConcreteNodeEquality = 98 mostConcreteNodeEquality.getCommonDenominator(nodeEquality); 144 else if (mostConcreteNodeEquality.isAtLeast(nodeEquality)) { 145 mostConcreteNodeEquality = nodeEquality; 146 147 } 148 149 if ((requiredEqualityLevel != null) && 150 (mostConcreteNodeEquality.isAtLeast(requiredEqualityLevel))) 151 { 152 // if we found one child of the selection that is as equal as required, then 153 // we can consider the selection to be sufficiently equal to the other node. 154 // So we break up checking further children. 155 break; 99 156 } 100 157 } … … 111 168 112 169 } 170 171 /** 172 * <p> 173 * TODO: comment 174 * </p> 175 * 176 * @param child1 177 * @param child2 178 * @param requiredEqualityLevel 179 * @return 180 */ 181 private NodeEquality callRuleManager(ITaskTreeNode child1, 182 ITaskTreeNode child2, 183 NodeEquality requiredEqualityLevel) 184 { 185 if (requiredEqualityLevel == null) { 186 return mRuleManager.compare(child1, child2); 187 } 188 else if (mRuleManager.areAtLeastEqual(child1, child2, requiredEqualityLevel)) { 189 return requiredEqualityLevel; 190 } 191 else { 192 return NodeEquality.UNEQUAL; 193 } 194 } 113 195 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/NodeComparisonRule.java
r1113 r1125 30 30 /** 31 31 * <p> 32 * checks if the rule is applicable for comparing the two provided nodes 33 * </p> 34 * 35 * @param node1 the first task tree node to compare 36 * @param node2 the second task tree node to compare 37 * 38 * @return true, if the rule is applicable, false else 39 */ 40 public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2); 41 42 /** 43 * <p> 44 * checks, if the provided nodes are lexically equal 45 * </p> 46 * 47 * @param node1 the first task tree node to compare 48 * @param node2 the second task tree node to compare 49 * 50 * @return true, if the nodes are equal, false else 51 */ 52 public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2); 53 54 /** 55 * <p> 56 * checks, if the provided nodes are syntactically equal 57 * </p> 58 * 59 * @param node1 the first task tree node to compare 60 * @param node2 the second task tree node to compare 61 * 62 * @return true, if the nodes are equal, false else 63 */ 64 public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2); 65 66 /** 67 * <p> 68 * checks, if the provided nodes are semantically equal 69 * </p> 70 * 71 * @param node1 the first task tree node to compare 72 * @param node2 the second task tree node to compare 73 * 74 * @return true, if the nodes are equal, false else 75 */ 76 public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2); 77 78 /** 79 * <p> 32 80 * compares two nodes with each other. The result of the method is either a node equality or 33 81 * null. If it is null, it means, that the rule is not able to correctly compare the two given -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/NodeEqualityRuleManager.java
r1113 r1125 72 72 * manager before a call to this method. 73 73 */ 74 public NodeEquality applyRules(ITaskTreeNode node1, ITaskTreeNode node2)74 public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) 75 75 throws IllegalStateException 76 76 { … … 83 83 84 84 for (NodeComparisonRule rule : mRuleIndex) { 85 nodeEquality = rule.compare(node1, node2); 86 87 if (nodeEquality != null) { 88 // LOG.warning("used rule " + rule + " for equality check"); 89 return nodeEquality; 85 if (rule.isApplicable(node1, node2)) { 86 nodeEquality = rule.compare(node1, node2); 87 if (nodeEquality != null) { 88 // LOG.warning("used rule " + rule + " for equality check"); 89 return nodeEquality; 90 } 90 91 } 91 92 } … … 96 97 } 97 98 99 /** 100 * <p> 101 * TODO: comment 102 * </p> 103 * 104 * @param child1 105 * @param child2 106 * @param equalityLevel 107 * @return 108 */ 109 public boolean areAtLeastEqual(ITaskTreeNode node1, 110 ITaskTreeNode node2, 111 NodeEquality equalityLevel) 112 { 113 if (equalityLevel == null) { 114 throw new IllegalArgumentException("required equality level must not be null"); 115 } 116 117 switch (equalityLevel) { 118 case IDENTICAL: 119 return areIdentical(node1, node2); 120 case LEXICALLY_EQUAL: 121 return areLexicallyEqual(node1, node2); 122 case SYNTACTICALLY_EQUAL: 123 return areSyntacticallyEqual(node1, node2); 124 case SEMANTICALLY_EQUAL: 125 return areSemanticallyEqual(node1, node2); 126 case UNEQUAL: 127 return !areSemanticallyEqual(node1, node2); 128 default: 129 throw new IllegalArgumentException("unknown required equality: " + equalityLevel); 130 } 131 } 132 133 /** 134 * <p> 135 * TODO: comment 136 * </p> 137 * 138 * @param child1 139 * @param child2 140 * @return 141 */ 142 public boolean areIdentical(ITaskTreeNode node1, ITaskTreeNode node2) { 143 if (mRuleIndex == null) { 144 throw new IllegalStateException("not initialized"); 145 } 146 147 for (NodeComparisonRule rule : mRuleIndex) { 148 if (rule.isApplicable(node1, node2) && rule.areLexicallyEqual(node1, node2)) { 149 return true; 150 } 151 } 152 153 return false; 154 } 155 156 /** 157 * <p> 158 * TODO: comment 159 * </p> 160 * 161 * @param child1 162 * @param child2 163 * @return 164 */ 165 public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 166 if (mRuleIndex == null) { 167 throw new IllegalStateException("not initialized"); 168 } 169 170 for (NodeComparisonRule rule : mRuleIndex) { 171 if (rule.isApplicable(node1, node2) && rule.areLexicallyEqual(node1, node2)) { 172 return true; 173 } 174 } 175 176 return false; 177 } 178 179 /** 180 * <p> 181 * TODO: comment 182 * </p> 183 * 184 * @param child1 185 * @param child2 186 * @return 187 */ 188 public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 189 if (mRuleIndex == null) { 190 throw new IllegalStateException("not initialized"); 191 } 192 193 for (NodeComparisonRule rule : mRuleIndex) { 194 if (rule.isApplicable(node1, node2) && rule.areSyntacticallyEqual(node1, node2)) { 195 return true; 196 } 197 } 198 199 return false; 200 } 201 202 /** 203 * <p> 204 * TODO: comment 205 * </p> 206 * 207 * @param child1 208 * @param child2 209 * @return 210 */ 211 public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 212 if (mRuleIndex == null) { 213 throw new IllegalStateException("not initialized"); 214 } 215 216 for (NodeComparisonRule rule : mRuleIndex) { 217 if (rule.isApplicable(node1, node2) && rule.areSemanticallyEqual(node1, node2)) { 218 return true; 219 } 220 } 221 222 return false; 223 } 224 98 225 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/NodeIdentityRule.java
r1113 r1125 29 29 public class NodeIdentityRule implements NodeComparisonRule { 30 30 31 /* 32 * (non-Javadoc) 33 * 34 * @see de.ugoe.cs.tasktree.nodeequality.NodeEqualityRule#apply(TaskTreeNode, TaskTreeNode) 31 /* (non-Javadoc) 32 * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 33 */ 34 @Override 35 public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 36 return (node1 == node2); 37 } 38 39 /* (non-Javadoc) 40 * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 41 */ 42 @Override 43 public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 44 return (node1 == node2); 45 } 46 47 /* (non-Javadoc) 48 * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 49 */ 50 @Override 51 public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 52 return (node1 == node2); 53 } 54 55 /* (non-Javadoc) 56 * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 57 */ 58 @Override 59 public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 60 return (node1 == node2); 61 } 62 63 /* (non-Javadoc) 64 * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 35 65 */ 36 66 @Override 37 67 public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 38 if ( node1 == node2) {68 if (isApplicable(node1, node2)) { 39 69 return NodeEquality.IDENTICAL; 40 70 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/SelectionComparisonRule.java
r1113 r1125 14 14 15 15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 16 17 import java.util.List; 16 18 17 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; … … 51 53 } 52 54 53 /* 54 * (non-Javadoc) 55 /* (non-Javadoc) 56 * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 57 */ 58 @Override 59 public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 60 return (node1 instanceof ISelection) && (node2 instanceof ISelection); 61 } 62 63 /* (non-Javadoc) 64 * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 65 */ 66 @Override 67 public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 68 NodeEquality equality = getEquality(node1, node2, NodeEquality.LEXICALLY_EQUAL); 69 return (equality != null) && (equality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 70 } 71 72 /* (non-Javadoc) 73 * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 74 */ 75 @Override 76 public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 77 NodeEquality equality = getEquality(node1, node2, NodeEquality.SYNTACTICALLY_EQUAL); 78 return (equality != null) && (equality.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 79 } 80 81 /* (non-Javadoc) 82 * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 83 */ 84 @Override 85 public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 86 NodeEquality equality = getEquality(node1, node2, NodeEquality.SEMANTICALLY_EQUAL); 87 return (equality != null) && (equality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 88 } 89 90 /* (non-Javadoc) 91 * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 92 */ 93 @Override 94 public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 95 return getEquality(node1, node2, null); 96 } 97 98 /** 55 99 * 56 * @see de.ugoe.cs.tasktree.nodeequality.NodeEqualityRule#apply(TaskTreeNode, TaskTreeNode) 57 */ 58 @Override 59 public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 60 if ((!(node1 instanceof ISelection)) || (!(node2 instanceof ISelection))) { 61 return null; 62 } 63 64 if (node1 == node2) { 65 return NodeEquality.IDENTICAL; 66 } 67 68 // if both sequences do not have children, they are identical. If only one of them has 69 // children, they are unequal. 70 if ((node1.getChildren().size() == 0) && (node2.getChildren().size() == 0)) { 100 */ 101 private NodeEquality getEquality(ITaskTreeNode node1, 102 ITaskTreeNode node2, 103 NodeEquality requiredEqualityLevel) 104 { 105 List<ITaskTreeNode> children1 = node1.getChildren(); 106 List<ITaskTreeNode> children2 = node2.getChildren(); 107 108 // if both selections do not have children, they are lexically equal. If only one of them 109 // has children, they are unequal. 110 if ((children1.size() == 0) && (children2.size() == 0)) { 71 111 return NodeEquality.LEXICALLY_EQUAL; 72 112 } 73 else if (( node1.getChildren().size() == 0) || (node2.getChildren().size() == 0)) {113 else if ((children1.size() == 0) || (children2.size() == 0)) { 74 114 return NodeEquality.UNEQUAL; 75 115 } 76 116 77 NodeEquality selectionEquality = NodeEquality.LEXICALLY_EQUAL; 78 79 // compare each child of selection one with each child of selection two 117 NodeEquality selectionEquality; 118 119 if (requiredEqualityLevel == null) { 120 // calculate the common equality level for all children of both selections. 121 // do it in both directions to ensure commutative comparison 122 selectionEquality = getCommonEqualityLevel(children1, children2); 123 if (selectionEquality != NodeEquality.UNEQUAL) { 124 return selectionEquality.getCommonDenominator 125 (getCommonEqualityLevel(children2, children1)); 126 } 127 else { 128 return NodeEquality.UNEQUAL; 129 } 130 } 131 else { 132 // we are searching for a specific equality 133 if (checkEqualityLevel(children1, children2, requiredEqualityLevel) && 134 checkEqualityLevel(children2, children1, requiredEqualityLevel)) 135 { 136 return requiredEqualityLevel; 137 } 138 else { 139 return NodeEquality.UNEQUAL; 140 } 141 } 142 } 143 144 /** 145 * <p> 146 * TODO: comment 147 * </p> 148 * 149 * @param children1 150 * @param children2 151 * @param requiredEqualityLevel 152 */ 153 private NodeEquality getCommonEqualityLevel(List<ITaskTreeNode> children1, 154 List<ITaskTreeNode> children2) 155 { 156 NodeEquality listEquality = NodeEquality.LEXICALLY_EQUAL; 157 80 158 NodeEquality childEquality; 81 159 NodeEquality currentEquality; 82 for (ITaskTreeNode child1 : node1.getChildren()) {160 for (ITaskTreeNode child1 : children1) { 83 161 childEquality = null; 84 for (ITaskTreeNode child2 : node2.getChildren()) {85 currentEquality = mRuleManager.applyRules(child1, child2);162 for (ITaskTreeNode child2 : children2) { 163 currentEquality = callRuleManager(child1, child2, null); 86 164 if ((currentEquality != null) && (currentEquality != NodeEquality.UNEQUAL)) { 87 165 if (childEquality == null) { … … 91 169 childEquality = childEquality.getCommonDenominator(currentEquality); 92 170 } 93 } 94 } 95 96 if (childEquality != null) { 97 selectionEquality = selectionEquality.getCommonDenominator(childEquality); 98 } 99 else { 100 return NodeEquality.UNEQUAL; 101 } 102 } 103 104 // compare each child of selection two with each child of selection one 105 for (ITaskTreeNode child2 : node2.getChildren()) { 106 childEquality = null; 107 for (ITaskTreeNode child1 : node1.getChildren()) { 108 currentEquality = mRuleManager.applyRules(child1, child2); 109 if ((currentEquality != null) && (currentEquality != NodeEquality.UNEQUAL)) { 110 if (childEquality == null) { 111 childEquality = currentEquality; 112 } 113 else { 114 childEquality = childEquality.getCommonDenominator(currentEquality); 171 172 if (childEquality == NodeEquality.SEMANTICALLY_EQUAL) { 173 // as we calculate only the common denominator, we can break up here for 174 // the current child. We will not improve the denominator anymore 175 break; 115 176 } 116 177 } 117 178 } 118 179 119 if (childEquality != null) { 120 selectionEquality = selectionEquality.getCommonDenominator(childEquality); 180 if (childEquality == null) { 181 // we did not find any child in the second list, that is equal to the searched 182 // child 183 return NodeEquality.UNEQUAL; 121 184 } 122 185 else { 123 return NodeEquality.UNEQUAL; 124 } 125 } 126 127 return selectionEquality; 186 listEquality = listEquality.getCommonDenominator(childEquality); 187 } 188 } 189 190 return listEquality; 191 } 192 193 /** 194 * <p> 195 * TODO: comment 196 * </p> 197 * 198 * @param children1 199 * @param children2 200 * @param requiredEqualityLevel 201 */ 202 private boolean checkEqualityLevel(List<ITaskTreeNode> children1, 203 List<ITaskTreeNode> children2, 204 NodeEquality requiredEqualityLevel) 205 { 206 NodeEquality childEquality; 207 NodeEquality currentEquality; 208 for (ITaskTreeNode child1 : children1) { 209 childEquality = null; 210 for (ITaskTreeNode child2 : children2) { 211 currentEquality = callRuleManager(child1, child2, requiredEqualityLevel); 212 if ((currentEquality != null) && (currentEquality.isAtLeast(requiredEqualityLevel))) 213 { 214 // we found at least one equal child with sufficient equality in the 215 // second list. So be can break up for this child. 216 childEquality = currentEquality; 217 break; 218 } 219 } 220 221 if (childEquality == null) { 222 // we did not find any child in the second list, that is equal to the searched 223 // child 224 return false; 225 } 226 } 227 228 // for all children, we found an equality 229 return true; 230 } 231 232 /** 233 * <p> 234 * TODO: comment 235 * </p> 236 * 237 * @param child1 238 * @param child2 239 * @param requiredEqualityLevel 240 * @return 241 */ 242 private NodeEquality callRuleManager(ITaskTreeNode child1, 243 ITaskTreeNode child2, 244 NodeEquality requiredEqualityLevel) 245 { 246 if (requiredEqualityLevel == null) { 247 return mRuleManager.compare(child1, child2); 248 } 249 else if (mRuleManager.areAtLeastEqual(child1, child2, requiredEqualityLevel)) { 250 return requiredEqualityLevel; 251 } 252 else { 253 return NodeEquality.UNEQUAL; 254 } 128 255 } 129 256 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/SequenceComparisonRule.java
r1113 r1125 14 14 15 15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 16 17 import java.util.List; 16 18 17 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; … … 47 49 } 48 50 49 /* 50 * (non-Javadoc) 51 * 52 * @see de.ugoe.cs.tasktree.nodeequality.NodeEqualityRule#apply(TaskTreeNode, TaskTreeNode) 51 /* (non-Javadoc) 52 * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 53 */ 54 @Override 55 public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 56 return (node1 instanceof ISequence) && (node2 instanceof ISequence); 57 } 58 59 /* (non-Javadoc) 60 * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 61 */ 62 @Override 63 public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 64 NodeEquality equality = getEquality(node1, node2, NodeEquality.LEXICALLY_EQUAL); 65 return (equality != null) && (equality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 66 } 67 68 /* (non-Javadoc) 69 * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 70 */ 71 @Override 72 public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 73 NodeEquality equality = getEquality(node1, node2, NodeEquality.SYNTACTICALLY_EQUAL); 74 return (equality != null) && (equality.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 75 } 76 77 /* (non-Javadoc) 78 * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 79 */ 80 @Override 81 public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 82 NodeEquality equality = getEquality(node1, node2, NodeEquality.SEMANTICALLY_EQUAL); 83 return (equality != null) && (equality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 84 } 85 86 /* (non-Javadoc) 87 * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 53 88 */ 54 89 @Override 55 90 public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 56 if ((!(node1 instanceof ISequence)) || (!(node2 instanceof ISequence))) { 57 return null; 58 } 91 return getEquality(node1, node2, null); 92 } 59 93 60 if (node1 == node2) { 61 return NodeEquality.IDENTICAL; 62 } 94 /** 95 * 96 */ 97 private NodeEquality getEquality(ITaskTreeNode node1, 98 ITaskTreeNode node2, 99 NodeEquality requiredEqualityLevel) 100 { 101 List<ITaskTreeNode> children1 = node1.getChildren(); 102 List<ITaskTreeNode> children2 = node2.getChildren(); 63 103 64 104 // if both sequences do not have children, they are equal although this doesn't make sense 65 if (( node1.getChildren().size() == 0) && (node2.getChildren().size() == 0)) {105 if ((children1.size() == 0) && (children2.size() == 0)) { 66 106 return NodeEquality.LEXICALLY_EQUAL; 67 107 } 68 108 69 if ( node1.getChildren().size() != node2.getChildren().size()) {109 if (children1.size() != children2.size()) { 70 110 return NodeEquality.UNEQUAL; 71 111 } 72 112 73 113 NodeEquality resultingEquality = NodeEquality.LEXICALLY_EQUAL; 74 for (int i = 0; i < node1.getChildren().size(); i++) {75 ITaskTreeNode child1 = node1.getChildren().get(i);76 ITaskTreeNode child2 = node2.getChildren().get(i);114 for (int i = 0; i < children1.size(); i++) { 115 ITaskTreeNode child1 = children1.get(i); 116 ITaskTreeNode child2 = children2.get(i); 77 117 78 NodeEquality nodeEquality = mRuleManager.applyRules(child1, child2);118 NodeEquality nodeEquality = callRuleManager(child1, child2, requiredEqualityLevel); 79 119 80 120 if ((nodeEquality == null) || (nodeEquality == NodeEquality.UNEQUAL)) { … … 88 128 } 89 129 130 /** 131 * <p> 132 * TODO: comment 133 * </p> 134 * 135 * @param child1 136 * @param child2 137 * @param requiredEqualityLevel 138 * @return 139 */ 140 private NodeEquality callRuleManager(ITaskTreeNode child1, 141 ITaskTreeNode child2, 142 NodeEquality requiredEqualityLevel) 143 { 144 if (requiredEqualityLevel == null) { 145 return mRuleManager.compare(child1, child2); 146 } 147 else if (mRuleManager.areAtLeastEqual(child1, child2, requiredEqualityLevel)) { 148 return requiredEqualityLevel; 149 } 150 else { 151 return NodeEquality.UNEQUAL; 152 } 153 } 90 154 }
Note: See TracChangeset
for help on using the changeset viewer.