- Timestamp:
- 08/17/12 08:33:29 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-core-tasktrees-test/src/test/java/de/ugoe/cs/quest/tasktrees/manager/TaskTreeManagerTest.java
r468 r557 1 //-------------------------------------------------------------------------------------------------2 1 // Module : $RCSfile: TaskTreeManagerTest.java,v $ 3 2 // Version : $Revision: 0.0 $ $Author: Patrick $ $Date: 08.11.2011 21:32:36 $ … … 5 4 // Creation : 2011 by Patrick 6 5 // Copyright : Patrick Harms, 2011 7 //-------------------------------------------------------------------------------------------------8 6 9 7 package de.ugoe.cs.quest.tasktrees.manager; … … 15 13 import org.junit.Test; 16 14 17 import de.ugoe.cs.quest.eventcore. guimodel.GUIElement;18 import de.ugoe.cs.quest.eventcore. userinteraction.Interaction;19 import de.ugoe.cs.quest.eventcore. userinteraction.InteractionEvent;15 import de.ugoe.cs.quest.eventcore.Event; 16 import de.ugoe.cs.quest.eventcore.IEventTarget; 17 import de.ugoe.cs.quest.eventcore.IEventType; 20 18 import de.ugoe.cs.quest.tasktrees.testutils.DummyGUIElement; 21 19 import de.ugoe.cs.quest.tasktrees.testutils.DummyInteraction; … … 23 21 import de.ugoe.cs.quest.tasktrees.testutils.TaskTreeChecker; 24 22 25 //-------------------------------------------------------------------------------------------------26 23 /** 27 24 * TODO comment 28 * 25 * 29 26 * @version $Revision: $ $Date: $ 30 * @author 27 * @author 2011, last modified by $Author: $ 31 28 */ 32 //------------------------------------------------------------------------------------------------- 33 34 public class TaskTreeManagerTest 35 { 36 /** */ 37 TaskTreeManager mManager; 38 39 //----------------------------------------------------------------------------------------------- 40 /** 41 * 42 */ 43 //----------------------------------------------------------------------------------------------- 44 @Before 45 public void setUp() 46 { 47 Logger.getLogger("").getHandlers()[0].setFormatter(new SimpleLogFormatter()); 29 public class TaskTreeManagerTest { 48 30 49 mManager = new TaskTreeManager(); 50 } 51 52 //----------------------------------------------------------------------------------------------- 53 /** 54 * 55 */ 56 //----------------------------------------------------------------------------------------------- 57 @After 58 public void tearDown() 59 { 60 mManager = null; 61 ComponentManager.clearInstance(); 62 } 63 64 //----------------------------------------------------------------------------------------------- 65 /** 66 * 67 */ 68 //----------------------------------------------------------------------------------------------- 69 @Test 70 public void testOneInteractionOnOneElement() 71 { 72 simulateInteraction(new DummyGUIElement("elem1"), new DummyInteraction("bla", 1)); 73 new TaskTreeChecker().assertTaskTree 74 ("Sequence sequence {" + 75 " Interaction bla {}" + 76 "}", mManager.getTaskTree()); 77 } 78 79 //----------------------------------------------------------------------------------------------- 80 /** 81 * 82 */ 83 //----------------------------------------------------------------------------------------------- 84 @Test 85 public void testManyInteractionsOnOneElement() 86 { 87 GUIElement element = new DummyGUIElement("elem1"); 88 simulateInteraction(element, new DummyInteraction("bla", 1)); 89 simulateInteraction(element, new DummyInteraction("bli", 1)); 90 simulateInteraction(element, new DummyInteraction("blo", 1)); 91 simulateInteraction(element, new DummyInteraction("blu", 1)); 92 simulateInteraction(element, new DummyInteraction("bla", 1)); 93 94 new TaskTreeChecker().assertTaskTree 95 ("Sequence sequence {" + 96 " Interaction bla {}" + 97 " Interaction bli {}" + 98 " Interaction blo {}" + 99 " Interaction blu {}" + 100 " Interaction bla {}" + 101 "}", mManager.getTaskTree()); 102 } 103 104 //----------------------------------------------------------------------------------------------- 105 /** 106 * 107 */ 108 //----------------------------------------------------------------------------------------------- 109 @Test 110 public void testOneInteractionOnManyElements() 111 { 112 GUIElement element1 = new DummyGUIElement("elem1"); 113 GUIElement element2 = new DummyGUIElement("elem2"); 114 GUIElement element3 = new DummyGUIElement("elem3"); 115 GUIElement element4 = new DummyGUIElement("elem4"); 116 GUIElement element5 = new DummyGUIElement("elem5"); 117 GUIElement element6 = new DummyGUIElement("elem6"); 118 simulateInteraction(element1, new DummyInteraction("bla", 1)); 119 simulateInteraction(element2, new DummyInteraction("bli", 1)); 120 simulateInteraction(element3, new DummyInteraction("bla", 1)); 121 simulateInteraction(element4, new DummyInteraction("bli", 1)); 122 simulateInteraction(element5, new DummyInteraction("blo", 1)); 123 simulateInteraction(element6, new DummyInteraction("bla", 1)); 124 125 new TaskTreeChecker().assertTaskTree 126 ("Sequence sequence0 {" + 127 " Sequence sequence1 {" + 128 " Interaction bla {}" + 129 " }" + 130 " Sequence sequence2 {" + 131 " Interaction bli {}" + 132 " }" + 133 " Sequence sequence3 {" + 134 " Interaction bla {}" + 135 " }" + 136 " Sequence sequence4 {" + 137 " Interaction bli {}" + 138 " }" + 139 " Sequence sequence5 {" + 140 " Interaction blo {}" + 141 " }" + 142 " Sequence sequence6 {" + 143 " Interaction bla {}" + 144 " }" + 145 "}", mManager.getTaskTree()); 146 } 147 148 //----------------------------------------------------------------------------------------------- 149 /** 150 * 151 */ 152 //----------------------------------------------------------------------------------------------- 153 @Test 154 public void testManyInteractionsOnManyElements() 155 { 156 GUIElement element1 = new DummyGUIElement("elem1"); 157 GUIElement element2 = new DummyGUIElement("elem2"); 158 GUIElement element3 = new DummyGUIElement("elem3"); 159 GUIElement element4 = new DummyGUIElement("elem4"); 160 GUIElement element5 = new DummyGUIElement("elem5"); 161 GUIElement element6 = new DummyGUIElement("elem6"); 162 simulateInteraction(element1, new DummyInteraction("bla", 1)); 163 simulateInteraction(element1, new DummyInteraction("bli", 1)); 164 simulateInteraction(element1, new DummyInteraction("bla", 1)); 165 simulateInteraction(element2, new DummyInteraction("bli", 1)); 166 simulateInteraction(element2, new DummyInteraction("blo", 1)); 167 simulateInteraction(element3, new DummyInteraction("bla", 1)); 168 simulateInteraction(element4, new DummyInteraction("bli", 1)); 169 simulateInteraction(element4, new DummyInteraction("bla", 1)); 170 simulateInteraction(element4, new DummyInteraction("bli", 1)); 171 simulateInteraction(element4, new DummyInteraction("blo", 1)); 172 simulateInteraction(element5, new DummyInteraction("bla", 1)); 173 simulateInteraction(element6, new DummyInteraction("bli", 1)); 174 simulateInteraction(element6, new DummyInteraction("bla", 1)); 175 simulateInteraction(element6, new DummyInteraction("bli", 1)); 176 simulateInteraction(element6, new DummyInteraction("blo", 1)); 177 178 new TaskTreeChecker().assertTaskTree 179 ("Sequence sequence0 {" + 180 " Sequence sequence1 {" + 181 " Interaction bla {}" + 182 " Interaction bli {}" + 183 " Interaction bla {}" + 184 " }" + 185 " Sequence sequence2 {" + 186 " Interaction bli {}" + 187 " Interaction blo {}" + 188 " }" + 189 " Sequence sequence3 {" + 190 " Interaction bla {}" + 191 " }" + 192 " Sequence sequence4 {" + 193 " Interaction bli {}" + 194 " Interaction bla {}" + 195 " Interaction bli {}" + 196 " Interaction blo {}" + 197 " }" + 198 " Sequence sequence5 {" + 199 " Interaction bla {}" + 200 " }" + 201 " Sequence sequence6 {" + 202 " Interaction bli {}" + 203 " Interaction bla {}" + 204 " Interaction bli {}" + 205 " Interaction blo {}" + 206 " }" + 207 "}", mManager.getTaskTree()); 208 } 209 210 //----------------------------------------------------------------------------------------------- 211 /** 212 * 213 */ 214 //----------------------------------------------------------------------------------------------- 215 @Test 216 public void testInteractionIterationDetection() throws Exception 217 { 218 GUIElement element1 = new DummyGUIElement("elem1"); 219 Interaction interaction1 = new DummyInteraction("bla", 1); 220 simulateInteraction(element1, interaction1); 221 new TaskTreeChecker().assertTaskTree 222 ("Sequence sequence1 {" + 223 " Interaction bla {}" + 224 "}", mManager.getTaskTree()); 225 226 simulateInteraction(element1, interaction1); 227 new TaskTreeChecker().assertTaskTree 228 ("Sequence sequence1 {" + 229 " Iteration iteration1 {" + 230 " Interaction bla {}" + 231 " }" + 232 "}", mManager.getTaskTree()); 233 234 simulateInteraction(element1, interaction1); 235 new TaskTreeChecker().assertTaskTree 236 ("Sequence sequence1 {" + 237 " Iteration iteration1 {" + 238 " Interaction bla {}" + 239 " }" + 240 "}", mManager.getTaskTree()); 241 242 for (int i = 0; i < 10; i++) 243 { 244 simulateInteraction(element1, interaction1); 245 } 246 247 new TaskTreeChecker().assertTaskTree 248 ("Sequence sequence1 {" + 249 " Iteration iteration1 {" + 250 " Interaction bla {}" + 251 " }" + 252 "}", mManager.getTaskTree()); 253 254 // now test with preceding and trailing other interactions 255 Interaction interaction2 = new DummyInteraction("bli", 1); 256 Interaction interaction3 = new DummyInteraction("blup", 1); 257 258 simulateInteraction(element1, interaction2); 259 simulateInteraction(element1, interaction3); 260 for (int i = 0; i < 10; i++) 261 { 262 simulateInteraction(element1, interaction1); 263 } 264 simulateInteraction(element1, interaction3); 265 simulateInteraction(element1, interaction2); 266 267 new TaskTreeChecker().assertTaskTree 268 ("Sequence sequence1 {" + 269 " Iteration iteration1 {" + 270 " Interaction bla {}" + 271 " }" + 272 " Interaction bli {}" + 273 " Interaction blup {}" + 274 " Iteration iteration2 {" + 275 " Interaction bla {}" + 276 " }" + 277 " Interaction blup {}" + 278 " Interaction bli {}" + 279 "}", mManager.getTaskTree()); 280 281 // now test with iterations of iterations 282 283 for (int i = 0; i < 10; i++) 284 { 285 for (int j = 0; j < 5; j++) 286 { 287 simulateInteraction(element1, interaction1); 288 } 289 for (int j = 0; j < 5; j++) 290 { 291 simulateInteraction(element1, interaction2); 292 } 293 for (int j = 0; j < 5; j++) 294 { 295 simulateInteraction(element1, interaction3); 296 } 297 } 298 299 new TaskTreeChecker().assertTaskTree 300 ("Sequence sequence0 {" + 301 " Iteration iteration0 {" + 302 " Interaction bla {}" + 303 " }" + 304 " Interaction bli {}" + 305 " Interaction blup {}" + 306 " Iteration iteration1 {" + 307 " Interaction bla {}" + 308 " }" + 309 " Interaction blup {}" + 310 " Interaction bli {}" + 311 " Iteration iteration2 {" + 312 " Sequence sequence1 {" + 313 " Iteration iteration3 {" + 314 " Interaction bla {}" + 315 " }" + 316 " Iteration iteration4 {" + 317 " Interaction bli {}" + 318 " }" + 319 " Iteration iteration5 {" + 320 " Interaction blup {}" + 321 " }" + 322 " }" + 323 " }" + 324 "}", mManager.getTaskTree()); 325 326 } 327 328 //----------------------------------------------------------------------------------------------- 329 /** 330 * 331 */ 332 //----------------------------------------------------------------------------------------------- 333 @Test 334 public void testSequenceIterationDetection() throws Exception 335 { 336 GUIElement element1 = new DummyGUIElement("elem1"); 337 Interaction interaction1 = new DummyInteraction("bla", 1); 338 Interaction interaction2 = new DummyInteraction("bli", 1); 339 Interaction interaction3 = new DummyInteraction("blup", 1); 340 simulateInteraction(element1, interaction1); 341 simulateInteraction(element1, interaction2); 342 simulateInteraction(element1, interaction3); 343 new TaskTreeChecker().assertTaskTree 344 ("Sequence sequence1 {" + 345 " Interaction bla {}" + 346 " Interaction bli {}" + 347 " Interaction blup {}" + 348 "}", mManager.getTaskTree()); 349 350 simulateInteraction(element1, interaction1); 351 simulateInteraction(element1, interaction2); 352 simulateInteraction(element1, interaction3); 353 new TaskTreeChecker().assertTaskTree 354 ("Sequence sequence1 {" + 355 " Iteration iteration1 {" + 356 " Sequence sequence2 {" + 357 " Interaction bla {}" + 358 " Interaction bli {}" + 359 " Interaction blup {}" + 360 " }" + 361 " }" + 362 "}", mManager.getTaskTree()); 363 364 simulateInteraction(element1, interaction1); 365 simulateInteraction(element1, interaction2); 366 simulateInteraction(element1, interaction3); 367 new TaskTreeChecker().assertTaskTree 368 ("Sequence sequence1 {" + 369 " Iteration iteration1 {" + 370 " Sequence sequence2 {" + 371 " Interaction bla {}" + 372 " Interaction bli {}" + 373 " Interaction blup {}" + 374 " }" + 375 " }" + 376 "}", mManager.getTaskTree()); 377 378 for (int i = 0; i < 10; i++) 379 { 380 simulateInteraction(element1, interaction1); 381 simulateInteraction(element1, interaction2); 382 simulateInteraction(element1, interaction3); 383 } 384 385 new TaskTreeChecker().assertTaskTree 386 ("Sequence sequence1 {" + 387 " Iteration iteration1 {" + 388 " Sequence sequence2 {" + 389 " Interaction bla {}" + 390 " Interaction bli {}" + 391 " Interaction blup {}" + 392 " }" + 393 " }" + 394 "}", mManager.getTaskTree()); 395 396 // now test with preceding and trailing other interactions 397 Interaction interaction4 = new DummyInteraction("ble", 1); 398 Interaction interaction5 = new DummyInteraction("blo", 1); 399 Interaction interaction6 = new DummyInteraction("blu", 1); 400 simulateInteraction(element1, interaction4); 401 simulateInteraction(element1, interaction5); 402 simulateInteraction(element1, interaction6); 403 for (int i = 0; i < 10; i++) 404 { 405 simulateInteraction(element1, interaction1); 406 simulateInteraction(element1, interaction2); 407 simulateInteraction(element1, interaction3); 408 } 409 simulateInteraction(element1, interaction6); 410 simulateInteraction(element1, interaction5); 411 simulateInteraction(element1, interaction4); 412 413 new TaskTreeChecker().assertTaskTree 414 ("Sequence sequence1 {" + 415 " Iteration iteration1 {" + 416 " Sequence sequence2 {" + 417 " Interaction bla {}" + 418 " Interaction bli {}" + 419 " Interaction blup {}" + 420 " }" + 421 " }" + 422 " Interaction ble {}" + 423 " Interaction blo {}" + 424 " Interaction blu {}" + 425 " Iteration iteration2 {" + 426 " Sequence sequence3 {" + 427 " Interaction bla {}" + 428 " Interaction bli {}" + 429 " Interaction blup {}" + 430 " }" + 431 " }" + 432 " Interaction blu {}" + 433 " Interaction blo {}" + 434 " Interaction ble {}" + 435 "}", mManager.getTaskTree()); 436 437 // now test with iterations of iterations 438 for (int i = 0; i < 10; i++) 439 { 440 for (int j = 0; j < 5; j++) 441 { 442 simulateInteraction(element1, interaction1); 443 simulateInteraction(element1, interaction2); 444 simulateInteraction(element1, interaction3); 445 } 446 for (int j = 0; j < 5; j++) 447 { 448 simulateInteraction(element1, interaction2); 449 simulateInteraction(element1, interaction1); 450 simulateInteraction(element1, interaction3); 451 } 452 for (int j = 0; j < 5; j++) 453 { 454 simulateInteraction(element1, interaction1); 455 simulateInteraction(element1, interaction2); 456 simulateInteraction(element1, interaction3); 457 } 458 } 459 460 new TaskTreeChecker().assertTaskTree 461 ("Sequence sequence1 {" + 462 " Iteration iteration1 {" + 463 " Sequence sequence2 {" + 464 " Interaction bla {}" + 465 " Interaction bli {}" + 466 " Interaction blup {}" + 467 " }" + 468 " }" + 469 " Interaction ble {}" + 470 " Interaction blo {}" + 471 " Interaction blu {}" + 472 " Iteration iteration2 {" + 473 " Sequence sequence3 {" + 474 " Interaction bla {}" + 475 " Interaction bli {}" + 476 " Interaction blup {}" + 477 " }" + 478 " }" + 479 " Interaction blu {}" + 480 " Interaction blo {}" + 481 " Interaction ble {}" + 482 " Iteration iteration3 {" + 483 " Sequence sequence4 {" + 484 " Iteration iteration4 {" + 485 " Sequence sequence4 {" + 486 " Interaction bla {}" + 487 " Interaction bli {}" + 488 " Interaction blup {}" + 489 " }" + 490 " }" + 491 " Iteration iteration5 {" + 492 " Sequence sequence5 {" + 493 " Interaction bli {}" + 494 " Interaction bla {}" + 495 " Interaction blup {}" + 496 " }" + 497 " }" + 498 " Iteration iteration6 {" + 499 " Sequence sequence6 {" + 500 " Interaction bla {}" + 501 " Interaction bli {}" + 502 " Interaction blup {}" + 503 " }" + 504 " }" + 505 " }" + 506 " }" + 507 "}", mManager.getTaskTree()); 508 } 509 510 //----------------------------------------------------------------------------------------------- 511 /** 512 * 513 */ 514 //----------------------------------------------------------------------------------------------- 515 @Test 516 public void testGUIElementHierarchyChanges() throws Exception 517 { 518 GUIElement element1 = new DummyGUIElement("elem1"); 519 GUIElement element2 = new DummyGUIElement("elem2"); 520 GUIElement element3 = new DummyGUIElement("elem3"); 521 GUIElement parent1 = new DummyGUIElement("parent1"); 522 GUIElement parent2 = new DummyGUIElement("parent2"); 523 GUIElement parent3 = new DummyGUIElement("parent3"); 524 525 element1.setParent(parent1); 526 element2.setParent(parent2); 527 element3.setParent(parent3); 528 529 parent1.setParent(parent2); 530 parent2.setParent(parent3); 531 532 Interaction interaction1 = new DummyInteraction("bla", 1); 533 simulateInteraction(element1, interaction1); 534 simulateInteraction(element2, interaction1); 535 simulateInteraction(element3, interaction1); 536 simulateInteraction(element2, interaction1); 537 simulateInteraction(element3, interaction1); 538 simulateInteraction(element2, interaction1); 539 simulateInteraction(element1, interaction1); 540 541 new TaskTreeChecker().assertTaskTree 542 ("Sequence sequence0 {" + 543 " Sequence sequence1 {" + 544 " Interaction bla {}" + 545 " }" + 546 " Sequence sequence2 {" + 547 " Interaction bla {}" + 548 " }" + 549 " Iteration iteration0 {" + 550 " Sequence sequence3 {" + 551 " Sequence sequence4 {" + 552 " Interaction bla {}" + 553 " }" + 554 " Sequence sequence5 {" + 555 " Interaction bla {}" + 556 " }" + 557 " }" + 558 " }" + 559 " Sequence sequence6 {" + 560 " Interaction bla {}" + 561 " }" + 562 "}", mManager.getTaskTree()); 563 564 } 565 566 //----------------------------------------------------------------------------------------------- 567 /** 568 * @param interactionsDoNotOverwriteElement 569 */ 570 //----------------------------------------------------------------------------------------------- 571 private void simulateInteraction(GUIElement GUIElement, Interaction interaction) 572 { 573 mManager.handleNewInteractionEvent(new InteractionEvent(GUIElement, interaction)); 574 } 31 /** */ 32 TaskTreeManager manager; 33 34 /** 35 * 36 */ 37 @Before 38 public void setUp() { 39 Logger.getLogger("").getHandlers()[0].setFormatter(new SimpleLogFormatter()); 40 41 manager = new TaskTreeManager(); 42 } 43 44 /** 45 * 46 */ 47 @After 48 public void tearDown() { 49 manager = null; 50 ComponentManager.clearInstance(); 51 } 52 53 /** 54 * 55 */ 56 @Test 57 public void testOneEventOnOneElement() { 58 simulateEvent(new DummyInteraction("bla", 1), new DummyGUIElement("elem1")); 59 new TaskTreeChecker().assertTaskTree 60 ("Sequence sequence {" + 61 " Event bla {}" + 62 "}", manager.getTaskTree()); 63 } 64 65 /** 66 * 67 */ 68 @Test 69 public void testManyEventsOnOneElement() { 70 IEventTarget eventTarget = new DummyGUIElement("elem1"); 71 simulateEvent(new DummyInteraction("bla", 1), eventTarget); 72 simulateEvent(new DummyInteraction("bli", 1), eventTarget); 73 simulateEvent(new DummyInteraction("blo", 1), eventTarget); 74 simulateEvent(new DummyInteraction("blu", 1), eventTarget); 75 simulateEvent(new DummyInteraction("bla", 1), eventTarget); 76 77 new TaskTreeChecker().assertTaskTree 78 ("Sequence sequence {" + 79 " Event bla {}" + 80 " Event bli {}" + 81 " Event blo {}" + 82 " Event blu {}" + 83 " Event bla {}" + 84 "}", manager.getTaskTree()); 85 } 86 87 /** 88 * 89 */ 90 @Test 91 public void testOneEventOnManyElements() { 92 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 93 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 94 IEventTarget eventTarget3 = new DummyGUIElement("elem3"); 95 IEventTarget eventTarget4 = new DummyGUIElement("elem4"); 96 IEventTarget eventTarget5 = new DummyGUIElement("elem5"); 97 IEventTarget eventTarget6 = new DummyGUIElement("elem6"); 98 simulateEvent(new DummyInteraction("bla", 1), eventTarget1); 99 simulateEvent(new DummyInteraction("bli", 1), eventTarget2); 100 simulateEvent(new DummyInteraction("bla", 1), eventTarget3); 101 simulateEvent(new DummyInteraction("bli", 1), eventTarget4); 102 simulateEvent(new DummyInteraction("blo", 1), eventTarget5); 103 simulateEvent(new DummyInteraction("bla", 1), eventTarget6); 104 105 new TaskTreeChecker().assertTaskTree 106 ("Sequence sequence0 {" + 107 " Sequence sequence1 {" + 108 " Event bla {}" + 109 " }" + 110 " Sequence sequence2 {" + 111 " Event bli {}" + 112 " }" + 113 " Sequence sequence3 {" + 114 " Event bla {}" + 115 " }" + 116 " Sequence sequence4 {" + 117 " Event bli {}" + 118 " }" + 119 " Sequence sequence5 {" + 120 " Event blo {}" + 121 " }" + 122 " Sequence sequence6 {" + 123 " Event bla {}" + 124 " }" + 125 "}", manager.getTaskTree()); 126 } 127 128 /** 129 * 130 */ 131 @Test 132 public void testManyEventsOnManyElements() { 133 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 134 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 135 IEventTarget eventTarget3 = new DummyGUIElement("elem3"); 136 IEventTarget eventTarget4 = new DummyGUIElement("elem4"); 137 IEventTarget eventTarget5 = new DummyGUIElement("elem5"); 138 IEventTarget eventTarget6 = new DummyGUIElement("elem6"); 139 simulateEvent(new DummyInteraction("bla", 1), eventTarget1); 140 simulateEvent(new DummyInteraction("bli", 1), eventTarget1); 141 simulateEvent(new DummyInteraction("bla", 1), eventTarget1); 142 simulateEvent(new DummyInteraction("bli", 1), eventTarget2); 143 simulateEvent(new DummyInteraction("blo", 1), eventTarget2); 144 simulateEvent(new DummyInteraction("bla", 1), eventTarget3); 145 simulateEvent(new DummyInteraction("bli", 1), eventTarget4); 146 simulateEvent(new DummyInteraction("bla", 1), eventTarget4); 147 simulateEvent(new DummyInteraction("bli", 1), eventTarget4); 148 simulateEvent(new DummyInteraction("blo", 1), eventTarget4); 149 simulateEvent(new DummyInteraction("bla", 1), eventTarget5); 150 simulateEvent(new DummyInteraction("bli", 1), eventTarget6); 151 simulateEvent(new DummyInteraction("bla", 1), eventTarget6); 152 simulateEvent(new DummyInteraction("bli", 1), eventTarget6); 153 simulateEvent(new DummyInteraction("blo", 1), eventTarget6); 154 155 new TaskTreeChecker().assertTaskTree 156 ("Sequence sequence0 {" + 157 " Sequence sequence1 {" + 158 " Event bla {}" + 159 " Event bli {}" + 160 " Event bla {}" + 161 " }" + 162 " Sequence sequence2 {" + 163 " Event bli {}" + 164 " Event blo {}" + 165 " }" + 166 " Sequence sequence3 {" + 167 " Event bla {}" + 168 " }" + 169 " Sequence sequence4 {" + 170 " Event bli {}" + 171 " Event bla {}" + 172 " Event bli {}" + 173 " Event blo {}" + 174 " }" + 175 " Sequence sequence5 {" + 176 " Event bla {}" + 177 " }" + 178 " Sequence sequence6 {" + 179 " Event bli {}" + 180 " Event bla {}" + 181 " Event bli {}" + 182 " Event blo {}" + 183 " }" + 184 "}", manager.getTaskTree()); 185 } 186 187 /** 188 * 189 */ 190 @Test 191 public void testEventIterationDetection() throws Exception { 192 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 193 IEventType event1 = new DummyInteraction("bla", 1); 194 simulateEvent(event1, eventTarget1); 195 new TaskTreeChecker().assertTaskTree 196 ("Sequence sequence1 {" + 197 " Event bla {}" + 198 "}", manager.getTaskTree()); 199 200 simulateEvent(event1, eventTarget1); 201 new TaskTreeChecker().assertTaskTree 202 ("Sequence sequence1 {" + 203 " Iteration iteration1 {" + 204 " Event bla {}" + 205 " }" + 206 "}", manager.getTaskTree()); 207 208 simulateEvent(event1, eventTarget1); 209 new TaskTreeChecker().assertTaskTree 210 ("Sequence sequence1 {" + 211 " Iteration iteration1 {" + 212 " Event bla {}" + 213 " }" + 214 "}", manager.getTaskTree()); 215 216 for (int i = 0; i < 10; i++) { 217 simulateEvent(event1, eventTarget1); 218 } 219 220 new TaskTreeChecker().assertTaskTree 221 ("Sequence sequence1 {" + 222 " Iteration iteration1 {" + 223 " Event bla {}" + 224 " }" + 225 "}", manager.getTaskTree()); 226 227 // now test with preceding and trailing other interactions 228 IEventType event2 = new DummyInteraction("bli", 1); 229 IEventType event3 = new DummyInteraction("blup", 1); 230 231 simulateEvent(event2, eventTarget1); 232 simulateEvent(event3, eventTarget1); 233 for (int i = 0; i < 10; i++) { 234 simulateEvent(event1, eventTarget1); 235 } 236 simulateEvent(event3, eventTarget1); 237 simulateEvent(event2, eventTarget1); 238 239 new TaskTreeChecker().assertTaskTree 240 ("Sequence sequence1 {" + 241 " Iteration iteration1 {" + 242 " Event bla {}" + 243 " }" + 244 " Event bli {}" + 245 " Event blup {}" + 246 " Iteration iteration2 {" + 247 " Event bla {}" + 248 " }" + 249 " Event blup {}" + 250 " Event bli {}" + 251 "}", manager.getTaskTree()); 252 253 // now test with iterations of iterations 254 255 for (int i = 0; i < 10; i++) { 256 for (int j = 0; j < 5; j++) { 257 simulateEvent(event1, eventTarget1); 258 } 259 for (int j = 0; j < 5; j++) { 260 simulateEvent(event2, eventTarget1); 261 } 262 for (int j = 0; j < 5; j++) { 263 simulateEvent(event3, eventTarget1); 264 } 265 } 266 267 new TaskTreeChecker().assertTaskTree 268 ("Sequence sequence0 {" + 269 " Iteration iteration0 {" + 270 " Event bla {}" + 271 " }" + 272 " Event bli {}" + 273 " Event blup {}" + 274 " Iteration iteration1 {" + 275 " Event bla {}" + 276 " }" + 277 " Event blup {}" + 278 " Event bli {}" + 279 " Iteration iteration2 {" + 280 " Sequence sequence1 {" + 281 " Iteration iteration3 {" + 282 " Event bla {}" + 283 " }" + 284 " Iteration iteration4 {" + 285 " Event bli {}" + 286 " }" + 287 " Iteration iteration5 {" + 288 " Event blup {}" + 289 " }" + 290 " }" + 291 " }" + 292 "}", manager.getTaskTree()); 293 294 } 295 296 /** 297 * 298 */ 299 @Test 300 public void testSequenceIterationDetection() throws Exception { 301 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 302 IEventType event1 = new DummyInteraction("bla", 1); 303 IEventType event2 = new DummyInteraction("bli", 1); 304 IEventType event3 = new DummyInteraction("blup", 1); 305 simulateEvent(event1, eventTarget1); 306 simulateEvent(event2, eventTarget1); 307 simulateEvent(event3, eventTarget1); 308 new TaskTreeChecker().assertTaskTree 309 ("Sequence sequence1 {" + 310 " Event bla {}" + 311 " Event bli {}" + 312 " Event blup {}" + 313 "}", manager.getTaskTree()); 314 315 simulateEvent(event1, eventTarget1); 316 simulateEvent(event2, eventTarget1); 317 simulateEvent(event3, eventTarget1); 318 new TaskTreeChecker().assertTaskTree 319 ("Sequence sequence1 {" + 320 " Iteration iteration1 {" + 321 " Sequence sequence2 {" + 322 " Event bla {}" + 323 " Event bli {}" + 324 " Event blup {}" + 325 " }" + 326 " }" + 327 "}", manager.getTaskTree()); 328 329 simulateEvent(event1, eventTarget1); 330 simulateEvent(event2, eventTarget1); 331 simulateEvent(event3, eventTarget1); 332 new TaskTreeChecker().assertTaskTree 333 ("Sequence sequence1 {" + 334 " Iteration iteration1 {" + 335 " Sequence sequence2 {" + 336 " Event bla {}" + 337 " Event bli {}" + 338 " Event blup {}" + 339 " }" + 340 " }" + 341 "}", manager.getTaskTree()); 342 343 for (int i = 0; i < 10; i++) { 344 simulateEvent(event1, eventTarget1); 345 simulateEvent(event2, eventTarget1); 346 simulateEvent(event3, eventTarget1); 347 } 348 349 new TaskTreeChecker().assertTaskTree 350 ("Sequence sequence1 {" + 351 " Iteration iteration1 {" + 352 " Sequence sequence2 {" + 353 " Event bla {}" + 354 " Event bli {}" + 355 " Event blup {}" + 356 " }" + 357 " }" + 358 "}", manager.getTaskTree()); 359 360 // now test with preceding and trailing other interactions 361 IEventType event4 = new DummyInteraction("ble", 1); 362 IEventType event5 = new DummyInteraction("blo", 1); 363 IEventType event6 = new DummyInteraction("blu", 1); 364 simulateEvent(event4, eventTarget1); 365 simulateEvent(event5, eventTarget1); 366 simulateEvent(event6, eventTarget1); 367 for (int i = 0; i < 10; i++) { 368 simulateEvent(event1, eventTarget1); 369 simulateEvent(event2, eventTarget1); 370 simulateEvent(event3, eventTarget1); 371 } 372 simulateEvent(event6, eventTarget1); 373 simulateEvent(event5, eventTarget1); 374 simulateEvent(event4, eventTarget1); 375 376 new TaskTreeChecker().assertTaskTree 377 ("Sequence sequence1 {" + 378 " Iteration iteration1 {" + 379 " Sequence sequence2 {" + 380 " Event bla {}" + 381 " Event bli {}" + 382 " Event blup {}" + 383 " }" + 384 " }" + 385 " Event ble {}" + 386 " Event blo {}" + 387 " Event blu {}" + 388 " Iteration iteration2 {" + 389 " Sequence sequence3 {" + 390 " Event bla {}" + 391 " Event bli {}" + 392 " Event blup {}" + 393 " }" + 394 " }" + 395 " Event blu {}" + 396 " Event blo {}" + 397 " Event ble {}" + 398 "}", manager.getTaskTree()); 399 400 // now test with iterations of iterations 401 for (int i = 0; i < 10; i++) { 402 for (int j = 0; j < 5; j++) { 403 simulateEvent(event1, eventTarget1); 404 simulateEvent(event2, eventTarget1); 405 simulateEvent(event3, eventTarget1); 406 } 407 for (int j = 0; j < 5; j++) { 408 simulateEvent(event2, eventTarget1); 409 simulateEvent(event1, eventTarget1); 410 simulateEvent(event3, eventTarget1); 411 } 412 for (int j = 0; j < 5; j++) { 413 simulateEvent(event1, eventTarget1); 414 simulateEvent(event2, eventTarget1); 415 simulateEvent(event3, eventTarget1); 416 } 417 } 418 419 new TaskTreeChecker().assertTaskTree 420 ("Sequence sequence1 {" + 421 " Iteration iteration1 {" + 422 " Sequence sequence2 {" + 423 " Event bla {}" + 424 " Event bli {}" + 425 " Event blup {}" + 426 " }" + 427 " }" + 428 " Event ble {}" + 429 " Event blo {}" + 430 " Event blu {}" + 431 " Iteration iteration2 {" + 432 " Sequence sequence3 {" + 433 " Event bla {}" + 434 " Event bli {}" + 435 " Event blup {}" + 436 " }" + 437 " }" + 438 " Event blu {}" + 439 " Event blo {}" + 440 " Event ble {}" + 441 " Iteration iteration3 {" + 442 " Sequence sequence4 {" + 443 " Iteration iteration4 {" + 444 " Sequence sequence4 {" + 445 " Event bla {}" + 446 " Event bli {}" + 447 " Event blup {}" + 448 " }" + 449 " }" + 450 " Iteration iteration5 {" + 451 " Sequence sequence5 {" + 452 " Event bli {}" + 453 " Event bla {}" + 454 " Event blup {}" + 455 " }" + 456 " }" + 457 " Iteration iteration6 {" + 458 " Sequence sequence6 {" + 459 " Event bla {}" + 460 " Event bli {}" + 461 " Event blup {}" + 462 " }" + 463 " }" + 464 " }" + 465 " }" + 466 "}", manager.getTaskTree()); 467 } 468 469 /** 470 * 471 */ 472 private void simulateEvent(IEventType eventType, IEventTarget eventTarget) { 473 manager.handleNewEvent(new Event(eventType, eventTarget)); 474 } 575 475 576 476 }
Note: See TracChangeset
for help on using the changeset viewer.