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

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

Fixing taskmodel specs and apply renaming refactoring (UsagePattern? -> InteractionPattern?).

  • Property svn:mime-type set to text/plain
File size: 6.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.tasktree.filters.EventTypeFilter.MOUSE_CLICK;
18import static de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter.SCROLL;
19import static de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter.TEXT_INPUT;
20import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SELECTION;
21import static de.ugoe.cs.autoquest.usability.tasktree.filters.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        InteractionPatternBuilder patternBuilder = new InteractionPatternBuilder();
75        InteractionPattern startsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(TEXT_INPUT).endsWith(MOUSE_CLICK).build();
76        InteractionPattern endsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(TEXT_INPUT).endsWith(MOUSE_CLICK).build();
77        InteractionPattern pattern = patternBuilder.concernedNode(SEQUENCE).startsWith(startsWithPattern).contains(MOUSE_CLICK).endsWith(endsWithPattern).build();
78        // When
79        boolean patternContained = pattern.containedIn(taskTree);
80        // Then
81        assertThat(patternContained).isTrue();
82    }
83   
84    @Test
85    public void starts_with_pattern_contains_event_and_ends_with_pattern_negative() {
86        // Given
87        String spec = "UserSession {" +
88                              "  Sequence seq1 {" +
89                      "    Selection sel1 {" +
90                      "      Sequence seq2 {" +
91                      "        TextInput target4 {}" +
92                      "        MouseClick target3 {}" +
93                      "      }" +
94                      "    }" +
95                      "    Selection sel1 {" +
96                      "      Sequence seq3 {" +
97                      "        TextInput target4 {}" +
98                      "        EventTask target2 {}" +
99                      "      }" +
100                      "    }" +
101                      "    EventTask target2 {}" +
102                      "    TextInput target1 {}" +
103                      "    Selection sel2 {" +
104                      "      Sequence seq5 {" +
105                      "        TextInput target4 {}" +
106                      "        MouseClick target3 {}" +
107                      "      }" +
108                      "    }" +
109                      "    Selection sel2 {" +
110                      "      Sequence seq6 {" +
111                      "        TextInput target4 {}" +
112                      "        EventTask target2 {}" +
113                      "      }" +
114                      "    }" +
115                      "  }" +
116                      "}";
117        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
118        InteractionPatternBuilder patternBuilder = new InteractionPatternBuilder();
119        InteractionPattern startsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(TEXT_INPUT).endsWith(MOUSE_CLICK).build();
120        InteractionPattern endsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(TEXT_INPUT).endsWith(MOUSE_CLICK).build();
121        InteractionPattern pattern = patternBuilder.concernedNode(SEQUENCE).startsWith(startsWithPattern).contains(SCROLL).endsWith(endsWithPattern).build();
122        // When
123        boolean patternContained = pattern.containedIn(taskTree);
124        // Then
125        assertThat(patternContained).isFalse();
126    }
127   
128}
Note: See TracBrowser for help on using the repository browser.