source: trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/testutil/GenerateTaskTreeUtil.java @ 1141

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

Adapted test project to refactoring of evaluation project.

  • Property svn:mime-type set to text/plain
File size: 3.7 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.testutil;
16
17import java.util.logging.Level;
18
19import de.ugoe.cs.autoquest.commands.sequences.CMDcondenseGuiModel;
20import de.ugoe.cs.autoquest.commands.sequences.CMDcondenseMouseClicks;
21import de.ugoe.cs.autoquest.commands.sequences.CMDcorrectKeyInteractionTargets;
22import de.ugoe.cs.autoquest.commands.sequences.CMDdetectTextInputEvents;
23import de.ugoe.cs.autoquest.commands.sequences.CMDsortKeyInteractions;
24import de.ugoe.cs.autoquest.commands.usability.CMDgenerateTaskTree;
25import de.ugoe.cs.autoquest.plugin.jfc.commands.CMDparseJFC;
26import de.ugoe.cs.autoquest.tasktrees.TaskTreeInstantiator;
27import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree;
28import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode;
29import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeBuilder;
30import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory;
31import de.ugoe.cs.autoquest.test.CommandRunner;
32import de.ugoe.cs.util.console.GlobalDataContainer;
33import de.ugoe.cs.util.console.TextConsole;
34
35/**
36 * <p>
37 * TODO comment
38 * </p>
39 *
40 * @author Alexander Deicke
41 */
42public class GenerateTaskTreeUtil {
43
44    private static final String seqName = "sequences";
45
46    private static final String taskTreeName = "taskTree";
47   
48    public static ITaskTree getTaskTreeFromSpec(String spec) {
49        TaskTreeNodeFactory factory = new TaskTreeNodeFactory();
50        ITaskTreeNode taskTree = new TaskTreeInstantiator(new TaskTreeNodeFactory(), new TaskTreeBuilder()).instantiateTaskTree(spec);
51        return factory.createTaskTree(taskTree);
52    }
53   
54    public static ITaskTree getTaskTreeFromFile(String filename) {
55        new TextConsole(Level.OFF);
56        parseTraceFile(filename);
57        condenseGuiModel();
58        sortKeyInteractions();
59        correctKeyInteractionTargets();
60        detectTextInputEvents();
61        condenseMouseClicks();
62        return generateTaskTree();
63    }
64
65    static private void parseTraceFile(String filetoparse) {
66        CommandRunner.runCommand(CMDparseJFC.class, ClassLoader.getSystemResource(filetoparse)
67            .getFile(), seqName);
68    }
69
70    private static void condenseGuiModel() {
71        CommandRunner.runCommand(CMDcondenseGuiModel.class, seqName);
72    }
73
74    private static void sortKeyInteractions() {
75        CommandRunner.runCommand(CMDsortKeyInteractions.class, seqName);
76    }
77
78    private static void correctKeyInteractionTargets() {
79        CommandRunner.runCommand(CMDcorrectKeyInteractionTargets.class, seqName);
80    }
81
82    private static void detectTextInputEvents() {
83        CommandRunner.runCommand(CMDdetectTextInputEvents.class, seqName);
84    }
85
86    private static void condenseMouseClicks() {
87        CommandRunner.runCommand(CMDcondenseMouseClicks.class, seqName);
88    }
89
90    private static ITaskTree generateTaskTree() {
91        CommandRunner.runCommand(CMDgenerateTaskTree.class, seqName, taskTreeName);
92        GlobalDataContainer dataContainer = GlobalDataContainer.getInstance();
93        return (ITaskTree) dataContainer.getData(taskTreeName);
94    }
95
96}
Note: See TracBrowser for help on using the repository browser.