[1040] | 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.
|
---|
[1030] | 14 |
|
---|
[1141] | 15 | package de.ugoe.cs.autoquest.usability.rules.metrics;
|
---|
[1030] | 16 |
|
---|
| 17 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.absent;
|
---|
| 18 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.highRecommendationSeverityLevel;
|
---|
| 19 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.infoRecommendationSeverityLevel;
|
---|
| 20 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.lowRecommendationSeverityLevel;
|
---|
| 21 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.mediumRecommendationSeverityLevel;
|
---|
| 22 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.present;
|
---|
| 23 | import static org.fest.assertions.api.Assertions.assertThat;
|
---|
| 24 |
|
---|
| 25 | import org.junit.Test;
|
---|
| 26 |
|
---|
| 27 | import com.google.common.base.Optional;
|
---|
| 28 |
|
---|
| 29 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree;
|
---|
[1141] | 30 | import de.ugoe.cs.autoquest.usability.result.UsabilityDefect;
|
---|
| 31 | import de.ugoe.cs.autoquest.usability.rules.metrics.TextInputEntryRepetitionsMetric;
|
---|
[1030] | 32 |
|
---|
[1040] | 33 | /**
|
---|
| 34 | * <p>
|
---|
| 35 | * TODO comment
|
---|
| 36 | * </p>
|
---|
| 37 | *
|
---|
| 38 | * @author Alexander Deicke
|
---|
| 39 | */
|
---|
[1030] | 40 | public class TextInputEntryRepetitionsEvaluatorTest extends AbstractUsabilityEvaluationTC {
|
---|
| 41 |
|
---|
| 42 | @Test
|
---|
| 43 | public void should_return_no_recommendation() {
|
---|
| 44 | // Given
|
---|
| 45 | String spec = "Sequence {" + " TextInput () {}" + "}";
|
---|
| 46 | ITaskTree taskTree = createTaskTree(spec);
|
---|
| 47 | // When
|
---|
[1151] | 48 | Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate();
|
---|
[1030] | 49 | // Then
|
---|
| 50 | assertThat(recommendation).is(absent());
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | @Test
|
---|
| 54 | public void should_return_recommendation_with_info_severity_level() {
|
---|
| 55 | // Given
|
---|
| 56 | String spec =
|
---|
| 57 | "Sequence {" + " TextInput (a b c) {}" + " Sequence {" + " TextInput (a) {}"
|
---|
| 58 | + " TextInput (d) {}" + " TextInput (e) {}" + " }" + "}";
|
---|
| 59 | ITaskTree taskTree = createTaskTree(spec);
|
---|
| 60 | // When
|
---|
[1151] | 61 | Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate();
|
---|
[1030] | 62 | // Then
|
---|
| 63 | assertThat(recommendation).is(present()).has(infoRecommendationSeverityLevel());
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | @Test
|
---|
| 67 | public void should_return_recommendation_with_low_severity_level() {
|
---|
| 68 | // Given
|
---|
| 69 | String spec =
|
---|
| 70 | "Sequence {" + " TextInput (a b c) {}" + " Sequence {" + " TextInput (a) {}"
|
---|
| 71 | + " TextInput (b) {}" + " TextInput (c) {}" + " }" + "}";
|
---|
| 72 | ITaskTree taskTree = createTaskTree(spec);
|
---|
| 73 | // When
|
---|
[1151] | 74 | Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate();
|
---|
[1030] | 75 | // Then
|
---|
[1040] | 76 | assertThat(recommendation).is(present()).has(lowRecommendationSeverityLevel());
|
---|
| 77 | }
|
---|
[1030] | 78 |
|
---|
| 79 | @Test
|
---|
| 80 | public void should_return_recommendation_with_medium_severity_level() {
|
---|
| 81 | // Given
|
---|
| 82 | String spec =
|
---|
| 83 | "Sequence {" + " TextInput (a b c d e f g h i j k l m) {}" + " Sequence {"
|
---|
| 84 | + " TextInput (a) {}" + " TextInput (b) {}" + " TextInput (c) {}"
|
---|
| 85 | + " TextInput (d) {}" + " }" + " Iteration {" + " TextInput (e) {}" + " }"
|
---|
| 86 | + " TextInput (a) {}" + " Selection {" + " TextInput (b) {}"
|
---|
| 87 | + " TextInput (c) {}" + " TextInput (d) {}" + " TextInput (e) {}" + " }"
|
---|
| 88 | + " Sequence {" + " TextInput (a) {}" + " Sequence {"
|
---|
| 89 | + " TextInput (b) {}" + " TextInput (c) {}" + " TextInput (d) {}"
|
---|
| 90 | + " TextInput (e) {}" + " }" + " }" + " TextInput (f) {}" + "}";
|
---|
| 91 | ITaskTree taskTree = createTaskTree(spec);
|
---|
| 92 | // When
|
---|
[1151] | 93 | Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate();
|
---|
[1030] | 94 | // Then
|
---|
| 95 | assertThat(recommendation).is(present()).has(mediumRecommendationSeverityLevel());
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | @Test
|
---|
| 99 | public void should_return_recommendation_with_high_severity_level() {
|
---|
| 100 | // Given
|
---|
| 101 | String spec =
|
---|
| 102 | "Sequence {" + " TextInput (a b c) {}" + " Sequence {" + " TextInput (a) {}"
|
---|
| 103 | + " TextInput (b) {}" + " TextInput (c) {}" + " TextInput (a) {}" + " }"
|
---|
| 104 | + " Iteration {" + " TextInput (a) {}" + " }" + " TextInput (a) {}"
|
---|
| 105 | + " Selection {" + " TextInput (b c) {}" + " TextInput (a) {}"
|
---|
| 106 | + " TextInput (a c) {}" + " TextInput (b a) {}" + " }" + " Sequence {"
|
---|
| 107 | + " TextInput (b c) {}" + " Sequence {" + " TextInput (d a c) {}"
|
---|
| 108 | + " TextInput (b b b a) {}" + " TextInput (a a c c) {}"
|
---|
| 109 | + " TextInput (b b a) {}" + " }" + " }" + " TextInput (d) {}" + "}";
|
---|
| 110 | ITaskTree taskTree = createTaskTree(spec);
|
---|
| 111 | // When
|
---|
[1151] | 112 | Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate();
|
---|
[1030] | 113 | // Then
|
---|
| 114 | assertThat(recommendation).is(present()).has(highRecommendationSeverityLevel());
|
---|
| 115 | }
|
---|
| 116 | }
|
---|