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.ITaskModel;
|
---|
30 | import de.ugoe.cs.autoquest.usability.result.UsabilityDefect;
|
---|
31 | import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * <p>
|
---|
35 | * TODO comment
|
---|
36 | * </p>
|
---|
37 | *
|
---|
38 | * @author Alexander Deicke
|
---|
39 | */
|
---|
40 | public class TextInputRatioEvaluatorTest {
|
---|
41 |
|
---|
42 | @Test
|
---|
43 | public void should_return_no_recommendation() {
|
---|
44 | // Given
|
---|
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 | "}";
|
---|
57 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
58 | // When
|
---|
59 | Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
|
---|
60 | // Then
|
---|
61 | assertThat(recommendation).is(absent());
|
---|
62 | }
|
---|
63 |
|
---|
64 | @Test
|
---|
65 | public void should_return_recommendation_with_info_severity_level() {
|
---|
66 | // Given
|
---|
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 | "}";
|
---|
76 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
77 | // When
|
---|
78 | Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
|
---|
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
|
---|
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 | "}";
|
---|
95 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
96 | // When
|
---|
97 | Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
|
---|
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
|
---|
105 | String spec = "UserSession {" +
|
---|
106 | " Sequence seq1 {" +
|
---|
107 | " TextInput t1 (a) {}" +
|
---|
108 | " TextInput t2 (b) {}" +
|
---|
109 | " Interaction t3 {}" +
|
---|
110 | " TextInput t4 (c) {}" +
|
---|
111 | " }" +
|
---|
112 | "}";
|
---|
113 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
114 | // When
|
---|
115 | Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
|
---|
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
|
---|
123 | String spec = "UserSession {" +
|
---|
124 | " TextInput t1 (bla) {}" +
|
---|
125 | "}";
|
---|
126 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
127 | // When
|
---|
128 | Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
|
---|
129 | // Then
|
---|
130 | assertThat(recommendation).is(present()).has(highRecommendationSeverityLevel());
|
---|
131 | }
|
---|
132 | }
|
---|