[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 |
|
---|
[1171] | 29 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
|
---|
[1141] | 30 | import de.ugoe.cs.autoquest.usability.result.UsabilityDefect;
|
---|
[1171] | 31 | import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
|
---|
[1030] | 32 |
|
---|
[1040] | 33 | /**
|
---|
| 34 | * <p>
|
---|
| 35 | * TODO comment
|
---|
| 36 | * </p>
|
---|
| 37 | *
|
---|
| 38 | * @author Alexander Deicke
|
---|
| 39 | */
|
---|
[1171] | 40 | public class TextInputRatioEvaluatorTest {
|
---|
[1030] | 41 |
|
---|
| 42 | @Test
|
---|
| 43 | public void should_return_no_recommendation() {
|
---|
| 44 | // Given
|
---|
[1201] | 45 | String spec = "UserSession {" +
|
---|
| 46 | " Sequence seq1 {" +
|
---|
| 47 | " Interaction iter1 {}" +
|
---|
| 48 | " TextInput t1 (a) {}" +
|
---|
| 49 | " Interaction iter1 {}" +
|
---|
| 50 | " Interaction t2 {}" +
|
---|
| 51 | " TextInput t3 (c) {}" +
|
---|
| 52 | " Interaction t4 {}" +
|
---|
| 53 | " Interaction t5 {}" +
|
---|
| 54 | " Interaction t6 {}" +
|
---|
| 55 | " }" +
|
---|
| 56 | "}";
|
---|
[1171] | 57 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1030] | 58 | // When
|
---|
[1151] | 59 | Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
|
---|
[1030] | 60 | // Then
|
---|
| 61 | assertThat(recommendation).is(absent());
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | @Test
|
---|
| 65 | public void should_return_recommendation_with_info_severity_level() {
|
---|
| 66 | // Given
|
---|
[1201] | 67 | String spec = "UserSession {" +
|
---|
| 68 | " Sequence se1 {" +
|
---|
| 69 | " Interaction t1 {}" +
|
---|
| 70 | " TextInput t2 (a) {}" +
|
---|
| 71 | " Interaction t3 {}" +
|
---|
| 72 | " Interaction t4 {}" +
|
---|
| 73 | " TextInput t5 (c) {}" +
|
---|
| 74 | " }" +
|
---|
| 75 | "}";
|
---|
[1171] | 76 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1030] | 77 | // When
|
---|
[1151] | 78 | Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
|
---|
[1030] | 79 | // Then
|
---|
| 80 | assertThat(recommendation).is(present()).has(infoRecommendationSeverityLevel());
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | @Test
|
---|
| 84 | public void should_return_recommendation_with_low_severity_level() {
|
---|
| 85 | // Given
|
---|
[1201] | 86 | String spec = "UserSession {" +
|
---|
| 87 | " Sequence seq1 {" +
|
---|
| 88 | " Interaction t1 {}" +
|
---|
| 89 | " TextInput t2 (a) {}" +
|
---|
| 90 | " TextInput t3 (b) {}" +
|
---|
| 91 | " Interaction t4 {}" +
|
---|
| 92 | " TextInput t5 (c) {}" +
|
---|
| 93 | " }" +
|
---|
| 94 | "}";
|
---|
[1171] | 95 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1030] | 96 | // When
|
---|
[1151] | 97 | Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
|
---|
[1030] | 98 | // Then
|
---|
| 99 | assertThat(recommendation).is(present()).has(lowRecommendationSeverityLevel());
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | @Test
|
---|
| 103 | public void should_return_recommendation_with_medium_severity_level() {
|
---|
| 104 | // Given
|
---|
[1201] | 105 | String spec = "UserSession {" +
|
---|
| 106 | " Sequence seq1 {" +
|
---|
| 107 | " TextInput t1 (a) {}" +
|
---|
| 108 | " TextInput t2 (b) {}" +
|
---|
| 109 | " Interaction t3 {}" +
|
---|
| 110 | " TextInput t4 (c) {}" +
|
---|
| 111 | " }" +
|
---|
| 112 | "}";
|
---|
[1171] | 113 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1030] | 114 | // When
|
---|
[1151] | 115 | Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
|
---|
[1030] | 116 | // Then
|
---|
| 117 | assertThat(recommendation).is(present()).has(mediumRecommendationSeverityLevel());
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | @Test
|
---|
| 121 | public void should_return_recommendation_with_high_severity_level() {
|
---|
| 122 | // Given
|
---|
[1201] | 123 | String spec = "UserSession {" +
|
---|
| 124 | " TextInput t1 (bla) {}" +
|
---|
| 125 | "}";
|
---|
[1171] | 126 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1030] | 127 | // When
|
---|
[1151] | 128 | Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
|
---|
[1030] | 129 | // Then
|
---|
| 130 | assertThat(recommendation).is(present()).has(highRecommendationSeverityLevel());
|
---|
| 131 | }
|
---|
| 132 | }
|
---|