source: trunk/quest-core-tasktrees/src/test/java/de/ugoe/cs/quest/tasktrees/manager/TaskTreeManagerTest.java @ 439

Last change on this file since 439 was 439, checked in by pharms, 12 years ago

initial import after refactoring of module structure with Steffen

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