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

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

Added startsWith test cases.

  • Property svn:mime-type set to text/plain
File size: 5.8 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.tasktree.filters.EventTypeFilter.MOUSE_CLICK;
18import static de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter.TEXT_INPUT;
19import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SELECTION;
20import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SEQUENCE;
21import static org.fest.assertions.api.Assertions.assertThat;
22
23import org.junit.Test;
24
25import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
26import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePattern;
27import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePatternBuilder;
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 StartsWithPatternContainsEventAndEndsWithPatternTest {
38
39    @Test
40    public void starts_with_pattern_contains_event_and_ends_with_pattern_positive() {
41        // Given
42        String spec = "UserSession {" +
43                              "  Sequence seq1 {" +
44                      "    Selection sel1 {" +
45                      "      Sequence seq2{" +
46                      "        TextInput target4 {}" +
47                      "        MouseClick target2 {}" +
48                      "      }" +
49                      "    }" +
50                      "    Selection sel1 {" +
51                      "      Sequence seq3 {" +
52                      "        TextInput target4 {}" +
53                      "        EventTask target2 {}" +
54                      "      }" +
55                      "    }" +
56                      "  }" +
57                      "  MouseClick target2 {}" +
58                      "  TextInput target3 {}" +
59                      "  Selection sel2 {" +
60                      "    Sequence seq4 {" +
61                      "      TextInput target4 {}" +
62                      "      MouseClick target2 {}" +
63                      "    }" +
64                      "  }" +
65                      "  Selection sel2 {" +
66                      "    Sequence seq5 {" +
67                      "      TextInput target4 {}" +
68                      "      EventTask target2 {}" +
69                      "    }" +
70                      "  }" +
71                      "}";
72        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
73        UsagePatternBuilder patternBuilder = new UsagePatternBuilder();
74        UsagePattern startsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(TEXT_INPUT).endsWith(MOUSE_CLICK).build();
75        UsagePattern endsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(TEXT_INPUT).endsWith(MOUSE_CLICK).build();
76        UsagePattern pattern = patternBuilder.concernedNode(SEQUENCE).startsWith(startsWithPattern).contains(MOUSE_CLICK).endsWith(endsWithPattern).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 target2 {}" +
92                      "      }" +
93                      "    }" +
94                      "    Selection sel1 {" +
95                      "      Sequence seq3 {" +
96                      "        TextInput target4 {}" +
97                      "        EventTask target2 {}" +
98                      "      }" +
99                      "    }" +
100                      "  }" +
101                      "  EventTask target2 {}" +
102                      "  TextInput target3 {}" +
103                      "  Selection sel2 {" +
104                      "    Sequence seq4 {" +
105                      "      TextInput target4 {}" +
106                      "      MouseClick target2 {}" +
107                      "    }" +
108                      "  }" +
109                      "  Selection sel2 {" +
110                      "    Sequence seq5 {" +
111                      "      TextInput target4 {}" +
112                      "      EventTask target2 {}" +
113                      "    }" +
114                      "  }" +
115                      "}";
116        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
117        UsagePatternBuilder patternBuilder = new UsagePatternBuilder();
118        UsagePattern startsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(TEXT_INPUT).endsWith(MOUSE_CLICK).build();
119        UsagePattern endsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(TEXT_INPUT).endsWith(MOUSE_CLICK).build();
120        UsagePattern pattern = patternBuilder.concernedNode(SEQUENCE).startsWith(startsWithPattern).contains(MOUSE_CLICK).endsWith(endsWithPattern).build();
121        // When
122        boolean patternContained = pattern.containedIn(taskTree);
123        // Then
124        assertThat(patternContained).isFalse();
125    }
126   
127}
Note: See TracBrowser for help on using the repository browser.