source: trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/rules/patterns/LongFormUsageDefect.java @ 1150

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

Added usage patterns and mechanism for detecting them.

  • Property svn:mime-type set to text/plain
File size: 3.3 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.patterns;
16
17import static de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter.MOUSE_CLICK;
18import static de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter.SCROLL;
19import static de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter.TEXT_INPUT;
20import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTreeNodeTypeFilter.ITERATION;
21import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTreeNodeTypeFilter.SEQUENCE;
22
23import com.google.common.base.Optional;
24
25import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree;
26import de.ugoe.cs.autoquest.usability.EvaluationMethodCaller;
27import de.ugoe.cs.autoquest.usability.result.DefectDescriptionResolver;
28import de.ugoe.cs.autoquest.usability.result.UsabilityDefect;
29import de.ugoe.cs.autoquest.usability.rules.UsabilityRule;
30import de.ugoe.cs.autoquest.usability.rules.UsabilityUsageDefect;
31
32/**
33 * <p>
34 * TODO comment
35 * </p>
36 *
37 * @author Alexander Deicke
38 */
39public class LongFormUsageDefect extends UsabilityRule implements UsabilityUsageDefect {
40
41    private UsagePattern longFormUsagePattern;
42   
43    /**
44     * <p>
45     * TODO: comment
46     * </p>
47     *
48     * @param taskTree
49     */
50    public LongFormUsageDefect(ITaskTree taskTree) {
51        super(taskTree);
52        this.name = "LongFormUsagePattern";
53        this.defect = new DefectDescriptionResolver().descriptionFor(this.getClass().getSimpleName());
54        initUsagePattern();
55    }
56
57    /**
58     * <p>
59     * TODO: comment
60     * </p>
61     *
62     */
63    private void initUsagePattern() {
64        UsagePatternBuilder builder = new UsagePatternBuilder();
65        UsagePattern fillFormPattern = builder.concernedNode(ITERATION).startsWith(TEXT_INPUT).endsWith(SCROLL).build();
66        this.longFormUsagePattern = builder.concernedNode(SEQUENCE).startsWith(MOUSE_CLICK).contains(fillFormPattern).endsWith(MOUSE_CLICK).build();
67    }
68
69    /* (non-Javadoc)
70     * @see de.ugoe.cs.autoquest.usability.rules.UsabilityRule#check()
71     */
72    @Override
73    public Optional<UsabilityDefect> check() {
74        Optional<UsabilityDefect> present = Optional.absent();
75        if(this.longFormUsagePattern.containedIn(taskTree)) {
76            present = Optional.of(this.defect);
77        }
78        return present;
79    }
80
81    /* (non-Javadoc)
82     * @see de.ugoe.cs.autoquest.usability.rules.UsabilityRule#callEvaluationMetho(de.ugoe.cs.autoquest.usability.EvaluationMethodCaller)
83     */
84    @Override
85    public Optional<UsabilityDefect> callEvaluationMethod(EvaluationMethodCaller evaluationMethodCaller)
86    {
87        return evaluationMethodCaller.check(this);
88    }
89}
Note: See TracBrowser for help on using the repository browser.