source: trunk/autoquest-plugin-usability2-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/patterns/visitors/startswith/StartsWithEventContainsPatternAndEndsWithPatternTest.java @ 1326

Last change on this file since 1326 was 1326, checked in by khartmann, 10 years ago

Moved alexanders code into a new plugin project.
First commit of my experimental code (needs a lot of cleanup).

  • Property svn:mime-type set to text/plain
File size: 4.7 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.ITERATION;
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.usability.rules.patterns.InteractionPattern;
27import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPatternBuilder;
28import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
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 StartsWithEventContainsPatternAndEndsWithPatternTest {
39
40    @Test
41    public void starts_with_event_contains_pattern_ends_with_pattern_positive() {
42        // Given
43        String spec = "UserSession {" +
44                      "  Sequence seq1 {" +
45                      "    TextInput t1 {}" +
46                      "    Selection sel1 {" +
47                      "      Sequence seq2 {" +
48                      "        MouseClick t2 {}" +
49                      "        TextInput t3 {}" +
50                      "      }" +
51                      "    }" +
52                      "    Iteration iter1 {" +
53                      "      MouseClick t2 {}" +
54                      "    }" +
55                      "  }" +
56                      "  TextInput t3 {}" +
57                      "  MouseClick t2 {}" +
58                      "  Iteration iter1 {" +
59                      "    MouseClick t2 {}" +
60                      "  }" +
61                      "}";
62        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
63        InteractionPattern containedPattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).startsWithEvent(MOUSE_CLICK).endsWithEvent(TEXT_INPUT).patternFinished().build();
64        InteractionPattern endsWithPattern = InteractionPatternBuilder.newPattern().rootTask(ITERATION).startsWithEvent(MOUSE_CLICK).patternFinished().build();
65        InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithEvent(TEXT_INPUT).containsPattern(containedPattern).endsWithPattern(endsWithPattern).patternFinished().build();
66        // When
67        boolean patternContained = pattern.containedIn(taskTree);
68        // Then
69        assertThat(patternContained).isTrue();
70    }
71   
72    @Test
73    public void starts_with_event_contains_pattern_ends_with_pattern_negative() {
74        // Given
75        String spec = "UserSession {" +
76                              "  Sequence seq1 {" +
77                      "    TextInput t1 {}" +
78                      "    Selection sel1{" +
79                      "      TextInput t2 {}" +
80                      "    }" +
81                      "    Selection sel1 {" +
82                      "      MouseClick t3 {}" +
83                      "    }" +
84                      "  }" +
85                      "  TextInput t2 {}" +
86                      "  MouseClick t4 {}" +
87                      "  Iteration iter1 {" +
88                      "    MouseClick t5 {}" +
89                      "  }" +
90                      "}";
91        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
92        InteractionPattern endsWithPattern = InteractionPatternBuilder.newPattern().rootTask(ITERATION).startsWithEvent(MOUSE_CLICK).patternFinished().build();
93        InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithEvent(TEXT_INPUT).containsEvent(MOUSE_CLICK).endsWithPattern(endsWithPattern).patternFinished().build();
94        // When
95        boolean patternContained = pattern.containedIn(taskTree);
96        // Then
97        assertThat(patternContained).isFalse();
98    }
99   
100}
Note: See TracBrowser for help on using the repository browser.