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.gui.ValueSelection; |
---|
20 | import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement; |
---|
21 | import de.ugoe.cs.autoquest.eventcore.guimodel.ITrackBar; |
---|
22 | import de.ugoe.cs.autoquest.tasktrees.TaskTreeChecker; |
---|
23 | import de.ugoe.cs.autoquest.test.DummyGUIElement; |
---|
24 | import de.ugoe.cs.autoquest.test.DummyInteraction; |
---|
25 | |
---|
26 | /** |
---|
27 | * TODO comment |
---|
28 | * |
---|
29 | * @version $Revision: $ $Date: 28.04.2012$ |
---|
30 | * @author 2012, last modified by $Author: patrick$ |
---|
31 | */ |
---|
32 | public class TrackBarSelectionDetectionRuleTest extends AbstractTemporalRelationshipTC { |
---|
33 | |
---|
34 | /** |
---|
35 | * |
---|
36 | */ |
---|
37 | @Test |
---|
38 | public void testSimpleDetection() throws Exception { |
---|
39 | IGUIElement element1 = new DummyTrackBar(); |
---|
40 | simulateEvent(new ValueSelection<Integer>(1), element1); |
---|
41 | new TaskTreeChecker().assertTaskTree |
---|
42 | ("Sequence sequence1 {" + |
---|
43 | " Iteration iteration1 {" + |
---|
44 | " Selection selection1 {" + |
---|
45 | " Event ValueSelection(\"1\") {}" + |
---|
46 | " }" + |
---|
47 | " }" + |
---|
48 | "}", getTaskTree(TrackBarSelectionDetectionRule.class, null)); |
---|
49 | |
---|
50 | simulateEvent(new ValueSelection<Integer>(2), element1); |
---|
51 | new TaskTreeChecker().assertTaskTree |
---|
52 | ("Sequence sequence1 {" + |
---|
53 | " Iteration iteration1 {" + |
---|
54 | " Selection selection1 {" + |
---|
55 | " Event ValueSelection(\"1\") {}" + |
---|
56 | " Event ValueSelection(\"2\") {}" + |
---|
57 | " }" + |
---|
58 | " }" + |
---|
59 | "}", getTaskTree(TrackBarSelectionDetectionRule.class, null)); |
---|
60 | |
---|
61 | simulateEvent(new ValueSelection<Integer>(3), element1); |
---|
62 | new TaskTreeChecker().assertTaskTree |
---|
63 | ("Sequence sequence1 {" + |
---|
64 | " Iteration iteration1 {" + |
---|
65 | " Selection selection1 {" + |
---|
66 | " Event ValueSelection(\"1\") {}" + |
---|
67 | " Event ValueSelection(\"2\") {}" + |
---|
68 | " Event ValueSelection(\"3\") {}" + |
---|
69 | " }" + |
---|
70 | " }" + |
---|
71 | "}", getTaskTree(TrackBarSelectionDetectionRule.class, null)); |
---|
72 | |
---|
73 | simulateEvent(new ValueSelection<Integer>(2), element1); |
---|
74 | new TaskTreeChecker().assertTaskTree |
---|
75 | ("Sequence sequence1 {" + |
---|
76 | " Iteration iteration1 {" + |
---|
77 | " Selection selection1 {" + |
---|
78 | " Event ValueSelection(\"1\") {}" + |
---|
79 | " Event ValueSelection(\"2\") {}" + |
---|
80 | " Event ValueSelection(\"3\") {}" + |
---|
81 | " }" + |
---|
82 | " }" + |
---|
83 | "}", getTaskTree(TrackBarSelectionDetectionRule.class, null)); |
---|
84 | |
---|
85 | simulateEvent(new ValueSelection<Integer>(3), element1); |
---|
86 | new TaskTreeChecker().assertTaskTree |
---|
87 | ("Sequence sequence1 {" + |
---|
88 | " Iteration iteration1 {" + |
---|
89 | " Selection selection1 {" + |
---|
90 | " Event ValueSelection(\"1\") {}" + |
---|
91 | " Event ValueSelection(\"2\") {}" + |
---|
92 | " Event ValueSelection(\"3\") {}" + |
---|
93 | " }" + |
---|
94 | " }" + |
---|
95 | "}", getTaskTree(TrackBarSelectionDetectionRule.class, null)); |
---|
96 | |
---|
97 | } |
---|
98 | |
---|
99 | /** |
---|
100 | * |
---|
101 | */ |
---|
102 | @Test |
---|
103 | public void testComplexDetection() throws Exception { |
---|
104 | IGUIElement element1 = new DummyTrackBar(); |
---|
105 | simulateEvent(new ValueSelection<Integer>(1), element1); |
---|
106 | simulateEvent(new ValueSelection<Integer>(2), element1); |
---|
107 | simulateEvent(new ValueSelection<Integer>(3), element1); |
---|
108 | simulateEvent(new ValueSelection<Integer>(1), element1); |
---|
109 | simulateEvent(new DummyInteraction("bla", 1), element1); |
---|
110 | simulateEvent(new DummyInteraction("bla", 2), element1); |
---|
111 | simulateEvent(new ValueSelection<Integer>(2), element1); |
---|
112 | simulateEvent(new ValueSelection<Integer>(1), element1); |
---|
113 | simulateEvent(new DummyInteraction("bla", 3), element1); |
---|
114 | simulateEvent(new ValueSelection<Integer>(3), element1); |
---|
115 | simulateEvent(new ValueSelection<Integer>(2), element1); |
---|
116 | simulateEvent(new ValueSelection<Integer>(3), element1); |
---|
117 | simulateEvent(new DummyInteraction("bla", 1), element1); |
---|
118 | simulateEvent(new DummyInteraction("bla", 2), element1); |
---|
119 | simulateEvent(new ValueSelection<Integer>(1), element1); |
---|
120 | simulateEvent(new ValueSelection<Integer>(1), element1); |
---|
121 | |
---|
122 | new TaskTreeChecker().assertTaskTree |
---|
123 | ("Sequence sequence1 {" + |
---|
124 | " Iteration iteration1 {" + |
---|
125 | " Selection selection1 {" + |
---|
126 | " Event ValueSelection(\"1\") {}" + |
---|
127 | " Event ValueSelection(\"2\") {}" + |
---|
128 | " Event ValueSelection(\"3\") {}" + |
---|
129 | " }" + |
---|
130 | " }" + |
---|
131 | " Event bla {}" + |
---|
132 | " Event bla {}" + |
---|
133 | " Iteration iteration2 {" + |
---|
134 | " Selection selection2 {" + |
---|
135 | " Event ValueSelection(\"2\") {}" + |
---|
136 | " Event ValueSelection(\"1\") {}" + |
---|
137 | " }" + |
---|
138 | " }" + |
---|
139 | " Event bla {}" + |
---|
140 | " Iteration iteration3 {" + |
---|
141 | " Selection selection3 {" + |
---|
142 | " Event ValueSelection(\"3\") {}" + |
---|
143 | " Event ValueSelection(\"2\") {}" + |
---|
144 | " }" + |
---|
145 | " }" + |
---|
146 | " Event bla {}" + |
---|
147 | " Event bla {}" + |
---|
148 | " Iteration iteration4 {" + |
---|
149 | " Selection selection4 {" + |
---|
150 | " Event ValueSelection(\"1\") {}" + |
---|
151 | " }" + |
---|
152 | " }" + |
---|
153 | "}", getTaskTree(TrackBarSelectionDetectionRule.class, null)); |
---|
154 | } |
---|
155 | |
---|
156 | /** |
---|
157 | * |
---|
158 | */ |
---|
159 | @Test |
---|
160 | public void testSubsequentSelectionsOnDifferentTrackbars() throws Exception { |
---|
161 | IGUIElement element1 = new DummyTrackBar(); |
---|
162 | IGUIElement element2 = new DummyTrackBar(); |
---|
163 | simulateEvent(new ValueSelection<Integer>(1), element1); |
---|
164 | simulateEvent(new ValueSelection<Integer>(2), element1); |
---|
165 | simulateEvent(new ValueSelection<Integer>(3), element1); |
---|
166 | simulateEvent(new ValueSelection<Integer>(1), element1); |
---|
167 | simulateEvent(new ValueSelection<Integer>(2), element2); |
---|
168 | simulateEvent(new ValueSelection<Integer>(1), element2); |
---|
169 | simulateEvent(new ValueSelection<Integer>(3), element1); |
---|
170 | simulateEvent(new ValueSelection<Integer>(2), element1); |
---|
171 | simulateEvent(new ValueSelection<Integer>(3), element1); |
---|
172 | simulateEvent(new ValueSelection<Integer>(1), element2); |
---|
173 | simulateEvent(new ValueSelection<Integer>(1), element2); |
---|
174 | |
---|
175 | new TaskTreeChecker().assertTaskTree |
---|
176 | ("Sequence sequence1 {" + |
---|
177 | " Iteration iteration1 {" + |
---|
178 | " Selection selection1 {" + |
---|
179 | " Event ValueSelection(\"1\") {}" + |
---|
180 | " Event ValueSelection(\"2\") {}" + |
---|
181 | " Event ValueSelection(\"3\") {}" + |
---|
182 | " }" + |
---|
183 | " }" + |
---|
184 | " Iteration iteration2 {" + |
---|
185 | " Selection selection2 {" + |
---|
186 | " Event ValueSelection(\"2\") {}" + |
---|
187 | " Event ValueSelection(\"1\") {}" + |
---|
188 | " }" + |
---|
189 | " }" + |
---|
190 | " Iteration iteration3 {" + |
---|
191 | " Selection selection3 {" + |
---|
192 | " Event ValueSelection(\"3\") {}" + |
---|
193 | " Event ValueSelection(\"2\") {}" + |
---|
194 | " }" + |
---|
195 | " }" + |
---|
196 | " Iteration iteration4 {" + |
---|
197 | " Selection selection4 {" + |
---|
198 | " Event ValueSelection(\"1\") {}" + |
---|
199 | " }" + |
---|
200 | " }" + |
---|
201 | "}", getTaskTree(TrackBarSelectionDetectionRule.class, null)); |
---|
202 | } |
---|
203 | |
---|
204 | /** |
---|
205 | * TODO comment |
---|
206 | * |
---|
207 | * @version $Revision: $ $Date: 28.04.2012$ |
---|
208 | * @author 2012, last modified by $Author: patrick$ |
---|
209 | */ |
---|
210 | public class DummyTrackBar extends DummyGUIElement implements ITrackBar { |
---|
211 | |
---|
212 | /** */ |
---|
213 | private static final long serialVersionUID = 1L; |
---|
214 | |
---|
215 | /** |
---|
216 | * |
---|
217 | */ |
---|
218 | public DummyTrackBar() { |
---|
219 | super("DummyTrackBar"); |
---|
220 | } |
---|
221 | } |
---|
222 | |
---|
223 | } |
---|