[1170] | 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 |
|
---|
| 15 | package de.ugoe.cs.autoquest.usability.rules.patterns.visitors.startswith;
|
---|
| 16 |
|
---|
[1218] | 17 | import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.EventTypeFilter.MOUSE_CLICK;
|
---|
| 18 | import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.EventTypeFilter.TEXT_INPUT;
|
---|
| 19 | import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.TaskTypeFilter.SEQUENCE;
|
---|
[1170] | 20 | import static org.fest.assertions.api.Assertions.assertThat;
|
---|
| 21 |
|
---|
| 22 | import org.junit.Test;
|
---|
| 23 |
|
---|
| 24 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
|
---|
[1205] | 25 | import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPattern;
|
---|
| 26 | import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPatternBuilder;
|
---|
[1170] | 27 | import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
|
---|
| 28 |
|
---|
| 29 | /**
|
---|
| 30 | * <p>
|
---|
| 31 | * TODO comment
|
---|
| 32 | * </p>
|
---|
| 33 | *
|
---|
| 34 | * @author Alexander Deicke
|
---|
| 35 | */
|
---|
| 36 | public class StartsWithEventAndContainsEventTest {
|
---|
| 37 |
|
---|
| 38 | @Test
|
---|
| 39 | public void starts_and_ends_with_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 | " }" +
|
---|
| 50 | " }" +
|
---|
| 51 | "}";
|
---|
| 52 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1218] | 53 | InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithEvent(TEXT_INPUT).containsEvent(MOUSE_CLICK).patternFinished().build();
|
---|
[1170] | 54 | // When
|
---|
| 55 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 56 | // Then
|
---|
| 57 | assertThat(patternContained).isTrue();
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | @Test
|
---|
| 61 | public void sequence_starts_and_ends_with_event_negative() {
|
---|
| 62 | // Given
|
---|
| 63 | String spec = "UserSession {" +
|
---|
| 64 | " Selection sel1 {" +
|
---|
| 65 | " Sequence seq1 {" +
|
---|
| 66 | " TextInput target1 {}" +
|
---|
| 67 | " EventTask target2 {}" +
|
---|
| 68 | " }" +
|
---|
| 69 | " }" +
|
---|
| 70 | " Selection sel1 {" +
|
---|
| 71 | " Sequence seq2 {" +
|
---|
| 72 | " EventTask target3 {}" +
|
---|
| 73 | " EventTask target4 {}" +
|
---|
| 74 | " }" +
|
---|
| 75 | " }" +
|
---|
| 76 | " Selection sel1 {" +
|
---|
| 77 | " Sequence seq3 {" +
|
---|
| 78 | " EventTask target5 {}" +
|
---|
| 79 | " MouseClick target6 {}" +
|
---|
| 80 | " }" +
|
---|
| 81 | " }" +
|
---|
| 82 | "}";
|
---|
| 83 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1218] | 84 | InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithEvent(TEXT_INPUT).containsEvent(MOUSE_CLICK).patternFinished().build();
|
---|
[1170] | 85 | // When
|
---|
| 86 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 87 | // Then
|
---|
| 88 | assertThat(patternContained).isFalse();
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | }
|
---|