source: trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TrackBarSelectionDetectionRuleTest.java @ 1132

Last change on this file since 1132 was 1106, checked in by pharms, 11 years ago
  • implemented rule tests to work without inference of other rules
File size: 8.6 KB
RevLine 
[927]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
[922]15package de.ugoe.cs.autoquest.tasktrees.temporalrelation;
[445]16
17import org.junit.Test;
18
[922]19import de.ugoe.cs.autoquest.eventcore.gui.ValueSelection;
20import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement;
21import de.ugoe.cs.autoquest.eventcore.guimodel.ITrackBar;
22import de.ugoe.cs.autoquest.tasktrees.TaskTreeChecker;
23import de.ugoe.cs.autoquest.test.DummyGUIElement;
24import de.ugoe.cs.autoquest.test.DummyInteraction;
[445]25
26/**
27 * TODO comment
28 *
29 * @version $Revision: $ $Date: 28.04.2012$
30 * @author 2012, last modified by $Author: patrick$
31 */
[557]32public class TrackBarSelectionDetectionRuleTest extends AbstractTemporalRelationshipTC {
[445]33
[557]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 {" +
[974]43             "  Iteration iteration1 {" +
[557]44             "    Selection selection1 {" +
[974]45             "      Event ValueSelection(\"1\") {}" +
[557]46             "    }" +
47             "  }" +
[1106]48             "}", getTaskTree(TrackBarSelectionDetectionRule.class, null));
[445]49
[557]50        simulateEvent(new ValueSelection<Integer>(2), element1);
51        new TaskTreeChecker().assertTaskTree
52            ("Sequence sequence1 {" +
[974]53             "  Iteration iteration1 {" +
[557]54             "    Selection selection1 {" +
[974]55             "      Event ValueSelection(\"1\") {}" +
56             "      Event ValueSelection(\"2\") {}" +
[557]57             "    }" +
58             "  }" +
[1106]59             "}", getTaskTree(TrackBarSelectionDetectionRule.class, null));
[445]60
[557]61        simulateEvent(new ValueSelection<Integer>(3), element1);
62        new TaskTreeChecker().assertTaskTree
63            ("Sequence sequence1 {" +
[974]64             "  Iteration iteration1 {" +
[557]65             "    Selection selection1 {" +
[974]66             "      Event ValueSelection(\"1\") {}" +
67             "      Event ValueSelection(\"2\") {}" +
68             "      Event ValueSelection(\"3\") {}" +
[557]69             "    }" +
70             "  }" +
[1106]71             "}", getTaskTree(TrackBarSelectionDetectionRule.class, null));
[445]72
[557]73        simulateEvent(new ValueSelection<Integer>(2), element1);
74        new TaskTreeChecker().assertTaskTree
75            ("Sequence sequence1 {" +
[974]76             "  Iteration iteration1 {" +
[557]77             "    Selection selection1 {" +
[974]78             "      Event ValueSelection(\"1\") {}" +
79             "      Event ValueSelection(\"2\") {}" +
80             "      Event ValueSelection(\"3\") {}" +
[557]81             "    }" +
82             "  }" +
[1106]83             "}", getTaskTree(TrackBarSelectionDetectionRule.class, null));
[445]84
[557]85        simulateEvent(new ValueSelection<Integer>(3), element1);
86        new TaskTreeChecker().assertTaskTree
87            ("Sequence sequence1 {" +
[974]88             "  Iteration iteration1 {" +
[557]89             "    Selection selection1 {" +
[974]90             "      Event ValueSelection(\"1\") {}" +
91             "      Event ValueSelection(\"2\") {}" +
92             "      Event ValueSelection(\"3\") {}" +
[557]93             "    }" +
94             "  }" +
[1106]95             "}", getTaskTree(TrackBarSelectionDetectionRule.class, null));
[445]96
[557]97    }
[445]98
99    /**
100     *
101     */
[557]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 {" +
[974]124             "  Iteration iteration1 {" +
[557]125             "    Selection selection1 {" +
[974]126             "      Event ValueSelection(\"1\") {}" +
127             "      Event ValueSelection(\"2\") {}" +
128             "      Event ValueSelection(\"3\") {}" +
[557]129             "    }" +
130             "  }" +
131             "  Event bla {}" +
132             "  Event bla {}" +
[974]133             "  Iteration iteration2 {" +
[557]134             "    Selection selection2 {" +
[974]135             "      Event ValueSelection(\"2\") {}" +
136             "      Event ValueSelection(\"1\") {}" +
[557]137             "    }" +
138             "  }" +
139             "  Event bla {}" +
[974]140             "  Iteration iteration3 {" +
[557]141             "    Selection selection3 {" +
[974]142             "      Event ValueSelection(\"3\") {}" +
143             "      Event ValueSelection(\"2\") {}" +
[557]144             "    }" +
145             "  }" +
146             "  Event bla {}" +
147             "  Event bla {}" +
[974]148             "  Iteration iteration4 {" +
[557]149             "    Selection selection4 {" +
[974]150             "      Event ValueSelection(\"1\") {}" +
[557]151             "    }" +
152             "  }" +
[1106]153             "}", getTaskTree(TrackBarSelectionDetectionRule.class, null));
[445]154    }
155
[557]156    /**
[974]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 {" +
[1106]178             "    Selection selection1 {" +
179             "      Event ValueSelection(\"1\") {}" +
180             "      Event ValueSelection(\"2\") {}" +
181             "      Event ValueSelection(\"3\") {}" +
[974]182             "    }" +
183             "  }" +
[1106]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));
[974]202    }
203
204    /**
[557]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
[445]223}
Note: See TracBrowser for help on using the repository browser.