source: trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/patterns/visitors/startswith/StartsWithEventContainsPatternAndEndsWithEventTest.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: 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.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.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 StartsWithEventContainsPatternAndEndsWithEventTest {
38
39    @Test
40    public void starts_with_event_contains_pattern_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                      "        TextInput t3 {}" +
49                      "      }" +
50                      "    }" +
51                      "    Selection sel1 {" +
52                      "      MouseClick t2 {}" +
53                      "    }" +
54                      "    TextInput t3 {}" +
55                      "    MouseClick t2 {}" +
56                      "    Iteration iter1 {" +
57                      "      TextInput t4 {}" +
58                      "    }" +
59                      "  }" +
60                      "}";
61        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
62        InteractionPatternBuilder builder = new InteractionPatternBuilder();
63        InteractionPattern containedPattern = builder.concernedNode(SELECTION).startsWith(MOUSE_CLICK).endsWith(TEXT_INPUT).build();
64        InteractionPattern pattern = new InteractionPatternBuilder().concernedNode(SEQUENCE).startsWith(TEXT_INPUT).contains(containedPattern).endsWith(TEXT_INPUT).build();
65        // When
66        boolean patternContained = pattern.containedIn(taskTree);
67        // Then
68        assertThat(patternContained).isTrue();
69    }
70   
71    @Test
72    public void starts_with_event_contains_pattern_ends_with_pattern_negative() {
73        // Given
74        String spec = "UserSession {" +
75                                      "  Sequence seq1 {" +
76                              "    TextInput t1 {}" +
77                              "    Selection sel1 {" +
78                              "      Sequence seq2 {" +
79                              "        MouseClick t2 {}" +
80                              "        TextInput t3 {}" +
81                              "      }" +
82                              "    }" +
83                              "    Selection sel1 {" +
84                              "      MouseClick t2 {}" +
85                              "    }" +
86                              "  }" +
87                              "  TextInput t3 {}" +
88                              "  MouseClick t2 {}" +
89                              "  Iteration iter1 {" +
90                              "    TextInput t4 {}" +
91                              "  }" +
92                      "}";
93        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
94        InteractionPatternBuilder builder = new InteractionPatternBuilder();
95        InteractionPattern containedPattern = builder.concernedNode(SELECTION).startsWith(MOUSE_CLICK).endsWith(TEXT_INPUT).build();
96        InteractionPattern pattern = new InteractionPatternBuilder().concernedNode(SEQUENCE).startsWith(TEXT_INPUT).contains(containedPattern).endsWith(TEXT_INPUT).build();
97        // When
98        boolean patternContained = pattern.containedIn(taskTree);
99        // Then
100        assertThat(patternContained).isFalse();
101    }
102   
103}
Note: See TracBrowser for help on using the repository browser.