[1127] | 1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany |
---|
| 2 | // |
---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
---|
| 4 | // you may not use this file except in compliance with the License. |
---|
| 5 | // You may obtain a copy of the License at |
---|
| 6 | // |
---|
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 8 | // |
---|
| 9 | // Unless required by applicable law or agreed to in writing, software |
---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 12 | // See the License for the specific language governing permissions and |
---|
| 13 | // limitations under the License. |
---|
| 14 | |
---|
| 15 | package de.ugoe.cs.autoquest.tasktrees.temporalrelation; |
---|
| 16 | |
---|
| 17 | import org.junit.Test; |
---|
| 18 | |
---|
| 19 | import de.ugoe.cs.autoquest.eventcore.IEventTarget; |
---|
| 20 | import de.ugoe.cs.autoquest.eventcore.IEventType; |
---|
| 21 | import de.ugoe.cs.autoquest.tasktrees.TaskTreeChecker; |
---|
| 22 | import de.ugoe.cs.autoquest.test.DummyGUIElement; |
---|
| 23 | import de.ugoe.cs.autoquest.test.DummyInteraction; |
---|
| 24 | |
---|
| 25 | /** |
---|
| 26 | * TODO comment |
---|
| 27 | * |
---|
| 28 | * @version $Revision: $ $Date: 28.04.2012$ |
---|
| 29 | * @author 2012, last modified by $Author: patrick$ |
---|
| 30 | */ |
---|
| 31 | public class SimpleIterationDetectionRuleTest extends AbstractTemporalRelationshipTC { |
---|
| 32 | |
---|
| 33 | /** |
---|
| 34 | * |
---|
| 35 | */ |
---|
| 36 | @Test |
---|
| 37 | public void testInteractionIterationDetection() throws Exception { |
---|
| 38 | IEventTarget element1 = new DummyGUIElement("elem1"); |
---|
| 39 | IEventType event1 = new DummyInteraction("bla", 1); |
---|
| 40 | simulateEvent(event1, element1); |
---|
| 41 | new TaskTreeChecker().assertTaskTree |
---|
| 42 | ("Sequence sequence1 {" + |
---|
| 43 | " Event bla {}" + |
---|
| 44 | "}", getTaskTree(SimpleIterationDetectionRule.class, null)); |
---|
| 45 | |
---|
| 46 | simulateEvent(event1, element1); |
---|
| 47 | new TaskTreeChecker().assertTaskTree |
---|
| 48 | ("Sequence sequence1 {" + |
---|
| 49 | " Iteration iteration1 {" + |
---|
| 50 | " Event bla {}" + |
---|
| 51 | " }" + |
---|
| 52 | "}", getTaskTree(SimpleIterationDetectionRule.class, null)); |
---|
| 53 | |
---|
| 54 | simulateEvent(event1, element1); |
---|
| 55 | new TaskTreeChecker().assertTaskTree |
---|
| 56 | ("Sequence sequence1 {" + |
---|
| 57 | " Iteration iteration1 {" + |
---|
| 58 | " Event bla {}" + |
---|
| 59 | " }" + |
---|
| 60 | "}", getTaskTree(SimpleIterationDetectionRule.class, null)); |
---|
| 61 | |
---|
| 62 | for (int i = 0; i < 10; i++) { |
---|
| 63 | simulateEvent(event1, element1); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | new TaskTreeChecker().assertTaskTree |
---|
| 67 | ("Sequence sequence1 {" + |
---|
| 68 | " Iteration iteration1 {" + |
---|
| 69 | " Event bla {}" + |
---|
| 70 | " }" + |
---|
| 71 | "}", getTaskTree(SimpleIterationDetectionRule.class, null)); |
---|
| 72 | |
---|
| 73 | // now test with preceding and trailing other events |
---|
| 74 | IEventType event2 = new DummyInteraction("bli", 1); |
---|
| 75 | IEventType event3 = new DummyInteraction("blup", 1); |
---|
| 76 | |
---|
| 77 | simulateEvent(event2, element1); |
---|
| 78 | simulateEvent(event3, element1); |
---|
| 79 | for (int i = 0; i < 10; i++) { |
---|
| 80 | simulateEvent(event1, element1); |
---|
| 81 | } |
---|
| 82 | simulateEvent(event3, element1); |
---|
| 83 | simulateEvent(event2, element1); |
---|
| 84 | |
---|
| 85 | new TaskTreeChecker().assertTaskTree |
---|
| 86 | ("Sequence sequence1 {" + |
---|
| 87 | " Iteration iteration1 {" + |
---|
| 88 | " Event bla {}" + |
---|
| 89 | " }" + |
---|
| 90 | " Event bli {}" + |
---|
| 91 | " Event blup {}" + |
---|
| 92 | " Iteration iteration2 {" + |
---|
| 93 | " Event bla {}" + |
---|
| 94 | " }" + |
---|
| 95 | " Event blup {}" + |
---|
| 96 | " Event bli {}" + |
---|
| 97 | "}", getTaskTree(SimpleIterationDetectionRule.class, null)); |
---|
| 98 | |
---|
| 99 | // now test with iterations of iterations |
---|
| 100 | |
---|
| 101 | for (int i = 0; i < 5; i++) { |
---|
| 102 | for (int j = 0; j < 5; j++) { |
---|
| 103 | simulateEvent(event1, element1); |
---|
| 104 | } |
---|
| 105 | for (int j = 0; j < 5; j++) { |
---|
| 106 | simulateEvent(event2, element1); |
---|
| 107 | } |
---|
| 108 | for (int j = 0; j < 5; j++) { |
---|
| 109 | simulateEvent(event3, element1); |
---|
| 110 | } |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | new TaskTreeChecker().assertTaskTree |
---|
| 114 | ("Sequence sequence1 {" + |
---|
| 115 | " Iteration iteration1 {" + |
---|
| 116 | " Event bla {}" + |
---|
| 117 | " }" + |
---|
| 118 | " Event bli {}" + |
---|
| 119 | " Event blup {}" + |
---|
| 120 | " Iteration iteration2 {" + |
---|
| 121 | " Event bla {}" + |
---|
| 122 | " }" + |
---|
| 123 | " Event blup {}" + |
---|
| 124 | " Event bli {}" + |
---|
| 125 | " Iteration iteration4 {" + |
---|
| 126 | " Event bla {}" + |
---|
| 127 | " }" + |
---|
| 128 | " Iteration iteration5 {" + |
---|
| 129 | " Event bli {}" + |
---|
| 130 | " }" + |
---|
| 131 | " Iteration iteration6 {" + |
---|
| 132 | " Event blup {}" + |
---|
| 133 | " }" + |
---|
| 134 | " Iteration iteration7 {" + |
---|
| 135 | " Event bla {}" + |
---|
| 136 | " }" + |
---|
| 137 | " Iteration iteration8 {" + |
---|
| 138 | " Event bli {}" + |
---|
| 139 | " }" + |
---|
| 140 | " Iteration iteration9 {" + |
---|
| 141 | " Event blup {}" + |
---|
| 142 | " }" + |
---|
| 143 | " Iteration iteration10 {" + |
---|
| 144 | " Event bla {}" + |
---|
| 145 | " }" + |
---|
| 146 | " Iteration iteration11 {" + |
---|
| 147 | " Event bli {}" + |
---|
| 148 | " }" + |
---|
| 149 | " Iteration iteration12 {" + |
---|
| 150 | " Event blup {}" + |
---|
| 151 | " }" + |
---|
| 152 | " Iteration iteration13 {" + |
---|
| 153 | " Event bla {}" + |
---|
| 154 | " }" + |
---|
| 155 | " Iteration iteration14 {" + |
---|
| 156 | " Event bli {}" + |
---|
| 157 | " }" + |
---|
| 158 | " Iteration iteration15 {" + |
---|
| 159 | " Event blup {}" + |
---|
| 160 | " }" + |
---|
| 161 | " Iteration iteration16 {" + |
---|
| 162 | " Event bla {}" + |
---|
| 163 | " }" + |
---|
| 164 | " Iteration iteration17 {" + |
---|
| 165 | " Event bli {}" + |
---|
| 166 | " }" + |
---|
| 167 | " Iteration iteration18 {" + |
---|
| 168 | " Event blup {}" + |
---|
| 169 | " }" + |
---|
| 170 | "}", getTaskTree(SimpleIterationDetectionRule.class, null)); |
---|
| 171 | |
---|
| 172 | } |
---|
| 173 | |
---|
| 174 | } |
---|