source: trunk/autoquest-plugin-usability2-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/patterns/visitors/startswith/StartsAndEndsWithEventAndContainsEventTest.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: 3.9 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.SEQUENCE;
20import static org.fest.assertions.api.Assertions.assertThat;
21
22import org.junit.Test;
23
24import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPattern;
25import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPatternBuilder;
26import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
27import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
28
29/**
30 * <p>
31 * TODO comment
32 * </p>
33 *
34 * @author Alexander Deicke
35 */
36public class StartsAndEndsWithEventAndContainsEventTest {
37   
38    @Test
39    public void starts_and_ends_with_event_and_contains_event_positive() {
40        // Given
41        String spec = "UserSession {" +
42                              "  Selection sel1 {" +
43                      "    EventTask target1 {}" +
44                      "  }" +
45                      "  Selection sel1 {" +
46                      "    Sequence seq1 {" +
47                      "      TextInput target2 {}" +
48                      "      MouseClick target3 {}" +
49                      "      TextInput target2 {}" +
50                      "    }" +
51                      "  }" +
52                      "}";
53        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
54        InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithEvent(TEXT_INPUT).containsEvent(MOUSE_CLICK).endsWithEvent(TEXT_INPUT).patternFinished().build();
55        // When
56        boolean patternContained = pattern.containedIn(taskTree);
57        // Then
58        assertThat(patternContained).isTrue();
59    }
60   
61    @Test
62    public void starts_and_ends_with_event_and_contains_event_negative() {
63        // Given
64        String spec = "UserSession {" +
65                              "  Selection sel1 {" +
66                      "    Sequence seq1 {" +
67                      "      TextInput target1 {}" +
68                      "      EventTask target2 {}" +
69                      "    }" +
70                      "  }" +
71                      "  Selection sel1 {" +
72                      "    Sequence seq2 {" +
73                      "      EventTask target3 {}" +
74                      "      EventTask target4 {}" +
75                      "    }" +
76                      "  }" +
77                      "  Selection sel1 {" +
78                      "    Sequence seq3 {" +
79                      "      EventTask target5 {}" +
80                      "      MouseClick target6 {}" +
81                      "    }" +
82                      "  }" +
83                      "}";
84        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
85        InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithEvent(TEXT_INPUT).containsEvent(MOUSE_CLICK).endsWithEvent(TEXT_INPUT).patternFinished().build();
86        // When
87        boolean patternContained = pattern.containedIn(taskTree);
88        // Then
89        assertThat(patternContained).isFalse();
90    }
91
92}
Note: See TracBrowser for help on using the repository browser.