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

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

Added tests for usage pattern detection-

  • Property svn:mime-type set to text/plain
File size: 4.4 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.ITaskTree;
30import de.ugoe.cs.autoquest.usability.result.UsabilityDefect;
31import de.ugoe.cs.autoquest.usability.rules.metrics.NoLetterOrDigitRatioMetric;
32
33/**
34 * <p>
35 * TODO comment
36 * </p>
37 *
38 * @author Alexander Deicke
39 */
40public class NoLetterOrDigitTextInputsEvaluatorTest extends AbstractUsabilityEvaluationTC {
41
42    @Test
43    public void should_return_no_recommendation() {
44        // Given
45        String spec = "Sequence {" +
46                      "  TextInput () {}" +
47                      "}";
48        ITaskTree taskTree = createTaskTree(spec);
49        // When
50        Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
51        // Then
52        assertThat(recommendation).is(absent());
53    }
54
55    @Test
56    public void should_return_recommendation_with_info_severity_level() {
57        // Given
58        String spec =
59            "Sequence {" +
60            "  TextInput (1234567890123456789012345678901234567890123456789_01234567890" +
61                         "12345678901234567890123456789012345) {}" +
62            "}";
63        ITaskTree taskTree = createTaskTree(spec);
64        // When
65        Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
66        // Then
67        assertThat(recommendation).is(present()).has(infoRecommendationSeverityLevel());
68    }
69
70    @Test
71    public void should_return_recommendation_with_low_severity_level() {
72        // Given
73        String spec =
74            "Sequence {" +
75            "  TextInput (123456789012345678901234567890_123456789012345) {}" +
76            "}";
77        ITaskTree taskTree = createTaskTree(spec);
78        // When
79        Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
80        // Then
81        assertThat(recommendation).is(present()).has(lowRecommendationSeverityLevel());
82    }
83
84    @Test
85    public void should_return_recommendation_with_medium_severity_level() {
86        // Given
87        String spec = "Sequence {" +
88                      "  TextInput (12345_6789012345) {}" +
89                      "}";
90        ITaskTree taskTree = createTaskTree(spec);
91        // When
92        Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
93        // Then
94        assertThat(recommendation).is(present()).has(mediumRecommendationSeverityLevel());
95    }
96
97    @Test
98    public void should_return_recommendation_with_high_severity_level() {
99        // Given
100        String spec = "Sequence {" +
101                      "  TextInput (_a_b_c_) {}" +
102                      "}";
103        ITaskTree taskTree = createTaskTree(spec);
104        // When
105        Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
106        // Then
107        assertThat(recommendation).is(present()).has(highRecommendationSeverityLevel());
108    }
109}
Note: See TracBrowser for help on using the repository browser.