source: trunk/autoquest-plugin-usability2-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/patterns/visitors/startswith/StartsWithPatternAndContainsEventTest.java @ 1326

Last change on this file since 1326 was 1326, checked in by khartmann, 10 years ago

Moved alexanders code into a new plugin project.
First commit of my experimental code (needs a lot of cleanup).

  • Property svn:mime-type set to text/plain
File size: 4.0 KB
Line 
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
15package de.ugoe.cs.autoquest.usability.rules.patterns.visitors.startswith;
16
17import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.EventTypeFilter.MOUSE_CLICK;
18import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.EventTypeFilter.TEXT_INPUT;
19import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.TaskTypeFilter.ITERATION;
20import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.TaskTypeFilter.SEQUENCE;
21import static org.fest.assertions.api.Assertions.assertThat;
22
23import org.junit.Test;
24
25import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPattern;
26import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPatternBuilder;
27import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
28import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
29
30/**
31 * <p>
32 * TODO comment
33 * </p>
34 *
35 * @author Alexander Deicke
36 */
37public class StartsWithPatternAndContainsEventTest {
38   
39    @Test
40    public void starts_with_pattern_and_contains_event_positive() {
41        // Given
42        String spec = "UserSession {" +
43                              "  Selection sel1 {" +
44                      "    EventTask target1 {}" +
45                      "  }" +
46                      "  Selection sel1 {" +
47                      "    Sequence seq1 {" +
48                      "      Iteration iter1 {" +
49                      "        TextInput target4 {}" +
50                      "      }" +
51                      "      MouseClick t2 {}" +
52                      "    }" +
53                      "  }" +
54                      "}";
55        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
56        InteractionPattern startsWithPattern = InteractionPatternBuilder.newPattern().rootTask(ITERATION).startsWithEvent(TEXT_INPUT).patternFinished().build();
57        InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithPattern(startsWithPattern).containsEvent(MOUSE_CLICK).patternFinished().build();
58        // When
59        boolean patternContained = pattern.containedIn(taskTree);
60        // Then
61        assertThat(patternContained).isTrue();
62    }
63   
64    @Test
65    public void starts_with_pattern_and_contains_event_negative() {
66        String spec = "UserSession {" +
67                              "  Selection sel1 {" +
68                      "    EventTask target1 {}" +
69                      "  }" +
70                      "  Selection sel1 {" +
71                      "    Sequence seq1 {" +
72                      "      Iteration iter1 {" +
73                      "        TextInput target4 {}" +
74                      "      }" +
75                      "      EventTask t2 {}" +
76                      "    }" +
77                      "  }" +
78                      "}";
79        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
80        InteractionPattern startsWithPattern = InteractionPatternBuilder.newPattern().rootTask(ITERATION).containsEvent(TEXT_INPUT).patternFinished().build();
81        InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithPattern(startsWithPattern).containsEvent(MOUSE_CLICK).patternFinished().build();
82        // When
83        boolean patternContained = pattern.containedIn(taskTree);
84        // Then
85        assertThat(patternContained).isFalse();
86    }
87
88}
Note: See TracBrowser for help on using the repository browser.