[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.testutil;
|
---|
| 16 |
|
---|
| 17 | import java.util.logging.Level;
|
---|
| 18 |
|
---|
| 19 | import de.ugoe.cs.autoquest.commands.sequences.CMDcondenseGuiModel;
|
---|
| 20 | import de.ugoe.cs.autoquest.commands.sequences.CMDcondenseMouseClicks;
|
---|
| 21 | import de.ugoe.cs.autoquest.commands.sequences.CMDcorrectKeyInteractionTargets;
|
---|
| 22 | import de.ugoe.cs.autoquest.commands.sequences.CMDdetectTextInputEvents;
|
---|
| 23 | import de.ugoe.cs.autoquest.commands.sequences.CMDsortKeyInteractions;
|
---|
| 24 | import de.ugoe.cs.autoquest.commands.usability.CMDgenerateTaskTree;
|
---|
| 25 | import de.ugoe.cs.autoquest.plugin.jfc.commands.CMDparseJFC;
|
---|
[1141] | 26 | import de.ugoe.cs.autoquest.tasktrees.TaskTreeInstantiator;
|
---|
[1030] | 27 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree;
|
---|
[1141] | 28 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode;
|
---|
| 29 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeBuilder;
|
---|
| 30 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory;
|
---|
[1030] | 31 | import de.ugoe.cs.autoquest.test.CommandRunner;
|
---|
| 32 | import de.ugoe.cs.util.console.GlobalDataContainer;
|
---|
| 33 | import de.ugoe.cs.util.console.TextConsole;
|
---|
| 34 |
|
---|
[1040] | 35 | /**
|
---|
| 36 | * <p>
|
---|
| 37 | * TODO comment
|
---|
| 38 | * </p>
|
---|
| 39 | *
|
---|
| 40 | * @author Alexander Deicke
|
---|
| 41 | */
|
---|
[1030] | 42 | public class GenerateTaskTreeUtil {
|
---|
[1040] | 43 |
|
---|
[1030] | 44 | private static final String seqName = "sequences";
|
---|
| 45 |
|
---|
| 46 | private static final String taskTreeName = "taskTree";
|
---|
[1141] | 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 |
|
---|
[1030] | 54 | public static ITaskTree getTaskTreeFromFile(String filename) {
|
---|
[1141] | 55 | new TextConsole(Level.OFF);
|
---|
[1030] | 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 | }
|
---|