[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 |
|
---|
| 15 | package de.ugoe.cs.autoquest.usability.evaluation.rule.evaluator;
|
---|
| 16 |
|
---|
| 17 | import static de.ugoe.cs.autoquest.usability.evaluation.rule.set.RulesetFactory.textInputUsabiliyRuleset;
|
---|
| 18 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.absent;
|
---|
| 19 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.highRecommendationSeverityLevel;
|
---|
| 20 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.infoRecommendationSeverityLevel;
|
---|
| 21 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.lowRecommendationSeverityLevel;
|
---|
| 22 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.mediumRecommendationSeverityLevel;
|
---|
| 23 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.present;
|
---|
| 24 | import static org.fest.assertions.api.Assertions.assertThat;
|
---|
| 25 |
|
---|
| 26 | import java.util.EnumSet;
|
---|
| 27 |
|
---|
| 28 | import org.junit.After;
|
---|
| 29 | import org.junit.Before;
|
---|
| 30 | import org.junit.Test;
|
---|
| 31 |
|
---|
| 32 | import com.google.common.base.Optional;
|
---|
| 33 | import com.google.common.base.Predicate;
|
---|
| 34 | import com.google.common.collect.Iterables;
|
---|
| 35 |
|
---|
| 36 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree;
|
---|
| 37 | import de.ugoe.cs.autoquest.usability.evaluation.result.UsabilityDefect;
|
---|
| 38 | import de.ugoe.cs.autoquest.usability.evaluation.rule.set.UsabilityRule;
|
---|
| 39 | import de.ugoe.cs.autoquest.usability.tasktree.filter.FilterStatisticCache;
|
---|
| 40 |
|
---|
[1040] | 41 | /**
|
---|
| 42 | * <p>
|
---|
| 43 | * TODO comment
|
---|
| 44 | * </p>
|
---|
| 45 | *
|
---|
| 46 | * @author Alexander Deicke
|
---|
| 47 | */
|
---|
[1030] | 48 | public class TextInputRatioEvaluatorTest extends AbstractUsabilityEvaluationTC {
|
---|
| 49 |
|
---|
| 50 | private UsabilityRule ruleUnderTest;
|
---|
| 51 |
|
---|
| 52 | @Before
|
---|
| 53 | public void initRuleUnderTest() {
|
---|
[1040] | 54 | EnumSet<? extends UsabilityRule> ruleset = textInputUsabiliyRuleset().evaluationRules();
|
---|
[1030] | 55 | this.ruleUnderTest = Iterables.find(ruleset, new Predicate<UsabilityRule>() {
|
---|
| 56 |
|
---|
| 57 | public boolean apply(UsabilityRule usabilityRule) {
|
---|
| 58 | return usabilityRule.ruleIdentifier().equals("TEXT_FIELD_INPUT_RATIO");
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | });
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | @After
|
---|
| 65 | public void clearFilterStatisticCache() {
|
---|
| 66 | FilterStatisticCache.instance().clear();
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | @Test
|
---|
| 70 | public void should_return_no_recommendation() {
|
---|
| 71 | // Given
|
---|
| 72 | String spec =
|
---|
| 73 | "Sequence {" + " Interaction {}" + " TextInput (a) {}" + " Interaction {}"
|
---|
| 74 | + " Interaction {}" + " TextInput (c) {}" + " Interaction {}"
|
---|
| 75 | + " Interaction {}" + " Interaction {}" + "}";
|
---|
| 76 | ITaskTree taskTree = createTaskTree(spec);
|
---|
| 77 | // When
|
---|
| 78 | Optional<UsabilityDefect> recommendation =
|
---|
| 79 | new TextInputRatioEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
|
---|
| 80 | // Then
|
---|
| 81 | assertThat(recommendation).is(absent());
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | @Test
|
---|
| 85 | public void should_return_recommendation_with_info_severity_level() {
|
---|
| 86 | // Given
|
---|
| 87 | String spec =
|
---|
| 88 | "Sequence {" + " Interaction {}" + " TextInput (a) {}" + " Interaction {}"
|
---|
| 89 | + " Interaction {}" + " TextInput (c) {}" + "}";
|
---|
| 90 | ITaskTree taskTree = createTaskTree(spec);
|
---|
| 91 | // When
|
---|
| 92 | Optional<UsabilityDefect> recommendation =
|
---|
| 93 | new TextInputRatioEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
|
---|
| 94 | // Then
|
---|
| 95 | assertThat(recommendation).is(present()).has(infoRecommendationSeverityLevel());
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | @Test
|
---|
| 99 | public void should_return_recommendation_with_low_severity_level() {
|
---|
| 100 | // Given
|
---|
| 101 | String spec =
|
---|
| 102 | "Sequence {" + " Interaction {}" + " TextInput (a) {}" + " TextInput (b) {}"
|
---|
| 103 | + " Interaction {}" + " TextInput (c) {}" + "}";
|
---|
| 104 | ITaskTree taskTree = createTaskTree(spec);
|
---|
| 105 | // When
|
---|
| 106 | Optional<UsabilityDefect> recommendation =
|
---|
| 107 | new TextInputRatioEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
|
---|
| 108 | // Then
|
---|
| 109 | assertThat(recommendation).is(present()).has(lowRecommendationSeverityLevel());
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | @Test
|
---|
| 113 | public void should_return_recommendation_with_medium_severity_level() {
|
---|
| 114 | // Given
|
---|
| 115 | String spec =
|
---|
| 116 | "Sequence {" + " TextInput (a) {}" + " TextInput (b) {}" + " Interaction {}"
|
---|
| 117 | + " TextInput (c) {}" + "}";
|
---|
| 118 | ITaskTree taskTree = createTaskTree(spec);
|
---|
| 119 | // When
|
---|
| 120 | Optional<UsabilityDefect> recommendation =
|
---|
| 121 | new TextInputRatioEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
|
---|
| 122 | // Then
|
---|
| 123 | assertThat(recommendation).is(present()).has(mediumRecommendationSeverityLevel());
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | @Test
|
---|
| 127 | public void should_return_recommendation_with_high_severity_level() {
|
---|
| 128 | // Given
|
---|
| 129 | String spec = "TextInput (bla) {}";
|
---|
| 130 | ITaskTree taskTree = createTaskTree(spec);
|
---|
| 131 | // When
|
---|
| 132 | Optional<UsabilityDefect> recommendation =
|
---|
| 133 | new TextInputRatioEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
|
---|
| 134 | // Then
|
---|
| 135 | assertThat(recommendation).is(present()).has(highRecommendationSeverityLevel());
|
---|
| 136 | }
|
---|
| 137 | }
|
---|