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