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.metrics;
|
---|
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;
|
---|
30 | import de.ugoe.cs.autoquest.usability.result.UsabilityDefect;
|
---|
31 | import de.ugoe.cs.autoquest.usability.rules.metrics.TextInputRatioMetric;
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * <p>
|
---|
35 | * TODO comment
|
---|
36 | * </p>
|
---|
37 | *
|
---|
38 | * @author Alexander Deicke
|
---|
39 | */
|
---|
40 | public class TextInputRatioEvaluatorTest extends AbstractUsabilityEvaluationTC {
|
---|
41 |
|
---|
42 | @Test
|
---|
43 | public void should_return_no_recommendation() {
|
---|
44 | // Given
|
---|
45 | String spec =
|
---|
46 | "Sequence {" + " Interaction {}" + " TextInput (a) {}" + " Interaction {}"
|
---|
47 | + " Interaction {}" + " TextInput (c) {}" + " Interaction {}"
|
---|
48 | + " Interaction {}" + " Interaction {}" + "}";
|
---|
49 | ITaskTree taskTree = createTaskTree(spec);
|
---|
50 | // When
|
---|
51 | Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
|
---|
52 | // Then
|
---|
53 | assertThat(recommendation).is(absent());
|
---|
54 | }
|
---|
55 |
|
---|
56 | @Test
|
---|
57 | public void should_return_recommendation_with_info_severity_level() {
|
---|
58 | // Given
|
---|
59 | String spec =
|
---|
60 | "Sequence {" + " Interaction {}" + " TextInput (a) {}" + " Interaction {}"
|
---|
61 | + " Interaction {}" + " TextInput (c) {}" + "}";
|
---|
62 | ITaskTree taskTree = createTaskTree(spec);
|
---|
63 | // When
|
---|
64 | Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
|
---|
65 | // Then
|
---|
66 | assertThat(recommendation).is(present()).has(infoRecommendationSeverityLevel());
|
---|
67 | }
|
---|
68 |
|
---|
69 | @Test
|
---|
70 | public void should_return_recommendation_with_low_severity_level() {
|
---|
71 | // Given
|
---|
72 | String spec =
|
---|
73 | "Sequence {" + " Interaction {}" + " TextInput (a) {}" + " TextInput (b) {}"
|
---|
74 | + " Interaction {}" + " TextInput (c) {}" + "}";
|
---|
75 | ITaskTree taskTree = createTaskTree(spec);
|
---|
76 | // When
|
---|
77 | Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
|
---|
78 | // Then
|
---|
79 | assertThat(recommendation).is(present()).has(lowRecommendationSeverityLevel());
|
---|
80 | }
|
---|
81 |
|
---|
82 | @Test
|
---|
83 | public void should_return_recommendation_with_medium_severity_level() {
|
---|
84 | // Given
|
---|
85 | String spec =
|
---|
86 | "Sequence {" + " TextInput (a) {}" + " TextInput (b) {}" + " Interaction {}"
|
---|
87 | + " TextInput (c) {}" + "}";
|
---|
88 | ITaskTree taskTree = createTaskTree(spec);
|
---|
89 | // When
|
---|
90 | Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
|
---|
91 | // Then
|
---|
92 | assertThat(recommendation).is(present()).has(mediumRecommendationSeverityLevel());
|
---|
93 | }
|
---|
94 |
|
---|
95 | @Test
|
---|
96 | public void should_return_recommendation_with_high_severity_level() {
|
---|
97 | // Given
|
---|
98 | String spec = "TextInput (bla) {}";
|
---|
99 | ITaskTree taskTree = createTaskTree(spec);
|
---|
100 | // When
|
---|
101 | Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
|
---|
102 | // Then
|
---|
103 | assertThat(recommendation).is(present()).has(highRecommendationSeverityLevel());
|
---|
104 | }
|
---|
105 | }
|
---|