source: trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/metrics/TextInputRatioEvaluatorTest.java @ 1201

Last change on this file since 1201 was 1201, checked in by adeicke, 11 years ago

Fixed tests.

  • Property svn:mime-type set to text/plain
File size: 5.2 KB
Line 
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
15package de.ugoe.cs.autoquest.usability.rules.metrics;
16
17import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.absent;
18import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.highRecommendationSeverityLevel;
19import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.infoRecommendationSeverityLevel;
20import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.lowRecommendationSeverityLevel;
21import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.mediumRecommendationSeverityLevel;
22import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.present;
23import static org.fest.assertions.api.Assertions.assertThat;
24
25import org.junit.Test;
26
27import com.google.common.base.Optional;
28
29import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
30import de.ugoe.cs.autoquest.usability.result.UsabilityDefect;
31import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
32
33/**
34 * <p>
35 * TODO comment
36 * </p>
37 *
38 * @author Alexander Deicke
39 */
40public 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}
Note: See TracBrowser for help on using the repository browser.