source: trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/patterns/visitors/startswith/StartsWithPatternContainsEventAndEndsWithPatternTest.java @ 1218

Last change on this file since 1218 was 1218, checked in by adeicke, 11 years ago

Adjustments according to renaming refactorings.

  • Property svn:mime-type set to text/plain
File size: 6.2 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.SCROLL;
19import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.EventTypeFilter.TEXT_INPUT;
20import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.TaskTypeFilter.SELECTION;
21import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.TaskTypeFilter.SEQUENCE;
22import static org.fest.assertions.api.Assertions.assertThat;
23
24import org.junit.Test;
25
26import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
27import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPattern;
28import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPatternBuilder;
29import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
30
31/**
32 * <p>
33 * TODO comment
34 * </p>
35 *
36 * @author Alexander Deicke
37 */
38public class StartsWithPatternContainsEventAndEndsWithPatternTest {
39
40    @Test
41    public void starts_with_pattern_contains_event_and_ends_with_pattern_positive() {
42        // Given
43        String spec = "UserSession {" +
44                              "  Sequence seq1 {" +
45                      "    Selection sel1 {" +
46                      "      Sequence seq2{" +
47                      "        TextInput target4 {}" +
48                      "        MouseClick target2 {}" +
49                      "      }" +
50                      "    }" +
51                      "    Selection sel1 {" +
52                      "      Sequence seq3 {" +
53                      "        TextInput target4 {}" +
54                      "        EventTask target2 {}" +
55                      "      }" +
56                      "    }" +
57                      "    MouseClick target2 {}" +
58                      "    TextInput target3 {}" +
59                      "    Selection sel2 {" +
60                      "      Sequence seq5 {" +
61                      "        TextInput target4 {}" +
62                      "        MouseClick target2 {}" +
63                      "      }" +
64                      "    }" +
65                      "    Selection sel2 {" +
66                      "      Sequence seq6 {" +
67                      "        TextInput target4 {}" +
68                      "        EventTask target2 {}" +
69                      "      }" +
70                      "    }" +
71                      "  }" +
72                      "}";
73        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
74        InteractionPattern startsWithPattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).startsWithEvent(TEXT_INPUT).endsWithEvent(MOUSE_CLICK).patternFinished().build();
75        InteractionPattern endsWithPattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).startsWithEvent(TEXT_INPUT).endsWithEvent(MOUSE_CLICK).patternFinished().build();
76        InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithPattern(startsWithPattern).containsEvent(MOUSE_CLICK).endsWithPattern(endsWithPattern).patternFinished().build();
77        // When
78        boolean patternContained = pattern.containedIn(taskTree);
79        // Then
80        assertThat(patternContained).isTrue();
81    }
82   
83    @Test
84    public void starts_with_pattern_contains_event_and_ends_with_pattern_negative() {
85        // Given
86        String spec = "UserSession {" +
87                              "  Sequence seq1 {" +
88                      "    Selection sel1 {" +
89                      "      Sequence seq2 {" +
90                      "        TextInput target4 {}" +
91                      "        MouseClick target3 {}" +
92                      "      }" +
93                      "    }" +
94                      "    Selection sel1 {" +
95                      "      Sequence seq3 {" +
96                      "        TextInput target4 {}" +
97                      "        EventTask target2 {}" +
98                      "      }" +
99                      "    }" +
100                      "    EventTask target2 {}" +
101                      "    TextInput target1 {}" +
102                      "    Selection sel2 {" +
103                      "      Sequence seq5 {" +
104                      "        TextInput target4 {}" +
105                      "        MouseClick target3 {}" +
106                      "      }" +
107                      "    }" +
108                      "    Selection sel2 {" +
109                      "      Sequence seq6 {" +
110                      "        TextInput target4 {}" +
111                      "        EventTask target2 {}" +
112                      "      }" +
113                      "    }" +
114                      "  }" +
115                      "}";
116        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
117        InteractionPattern startsWithPattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).startsWithEvent(TEXT_INPUT).endsWithEvent(MOUSE_CLICK).patternFinished().build();
118        InteractionPattern endsWithPattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).startsWithEvent(TEXT_INPUT).endsWithEvent(MOUSE_CLICK).patternFinished().build();
119        InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithPattern(startsWithPattern).containsEvent(SCROLL).endsWithPattern(endsWithPattern).patternFinished().build();
120        // When
121        boolean patternContained = pattern.containedIn(taskTree);
122        // Then
123        assertThat(patternContained).isFalse();
124    }
125   
126}
Note: See TracBrowser for help on using the repository browser.