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

Last change on this file since 1319 was 1319, checked in by khartmann, 11 years ago
  • Reworked Filters to use the first instance of a task to provide type and target
  • Added a function to extract all tasks matching a given filter
  • Added simple console feedback for matched usability problems
  • Property svn:mime-type set to text/plain
File size: 4.5 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.SELECTION;
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.tasktrees.treeifc.ITaskModel;
26import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPattern;
27import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPatternBuilder;
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 StartsWithEventAndContainsPatternTest {
38
39    @Test
40    public void starts_and_ends_with_pattern_positive() {
41        // Given
42        String spec = "UserSession {" +
43                              "  Sequence seq1 {" +
44                      "    TextInput t1 {}" +
45                      "    Selection sel1 {" +
46                      "      Sequence seq2 {" +
47                      "        MouseClick t2 {}" +
48                      "      }" +
49                      "    }" +
50                      "    Selection sel1 {" +
51                      "      Sequence seq3 {" +
52                      "        EventTask t3 {}" +
53                      "        MouseClick t5 {}" +
54                      "      }" +
55                      "    }" +
56                      "  }" +
57                      "}";
58        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
59        InteractionPattern endsWithPattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).startsWithEvent(MOUSE_CLICK).patternFinished().build();
60        InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithEvent(TEXT_INPUT).endsWithPattern(endsWithPattern).patternFinished().build();
61        // When
62        boolean patternContained = pattern.containedIn(taskTree);
63        // Then
64        assertThat(patternContained).isTrue();
65    }
66   
67    @Test
68    public void starts_and_ends_with_pattern_negative() {
69        // Given
70        String spec = "UserSession {" +
71                              "  Selection sel1 {" +
72                      "    Sequence seq1 {" +
73                      "      MouseClick target1 {}" +
74                      "    }" +
75                      "  }" +
76                      "  Selection sel1 {" +
77                      "    Sequence seq2 {" +
78                      "      TextInput t2 {}" +
79                      "    }" +
80                      "  }" +
81                      "  Selection sel1 {" +
82                      "    Sequence seq3 {" +
83                      "      MouseClick t3 {}" +
84                      "    }" +
85                      "  }" +
86                      "  Sequence seq4 {" +
87                      "    EventTask target3 {}" +
88                      "    EventTask target4 {}" +
89                      "    EventTask target5 {}" +
90                      "    MouseClick target6 {}" +
91                      "  }" +
92                      "}";
93        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
94        InteractionPattern endsWithPattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithEvent(TEXT_INPUT).endsWithEvent(MOUSE_CLICK).patternFinished().build();
95        InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithEvent(MOUSE_CLICK).endsWithPattern(endsWithPattern).patternFinished().build();
96        // When
97        boolean patternContained = pattern.containedIn(taskTree);
98        // Then
99        assertThat(patternContained).isFalse();
100    }
101
102}
Note: See TracBrowser for help on using the repository browser.