[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 |
|
---|
[1165] | 17 | import java.util.List;
|
---|
[1030] | 18 | import java.util.logging.Level;
|
---|
| 19 |
|
---|
[1165] | 20 | import com.google.common.collect.Lists;
|
---|
| 21 |
|
---|
[1030] | 22 | import de.ugoe.cs.autoquest.commands.sequences.CMDcondenseGuiModel;
|
---|
| 23 | import de.ugoe.cs.autoquest.commands.sequences.CMDcondenseMouseClicks;
|
---|
| 24 | import de.ugoe.cs.autoquest.commands.sequences.CMDcorrectKeyInteractionTargets;
|
---|
| 25 | import de.ugoe.cs.autoquest.commands.sequences.CMDdetectTextInputEvents;
|
---|
| 26 | import de.ugoe.cs.autoquest.commands.sequences.CMDsortKeyInteractions;
|
---|
| 27 | import de.ugoe.cs.autoquest.commands.usability.CMDgenerateTaskTree;
|
---|
| 28 | import de.ugoe.cs.autoquest.plugin.jfc.commands.CMDparseJFC;
|
---|
[1152] | 29 | import de.ugoe.cs.autoquest.tasktrees.TaskTreeDecoder;
|
---|
[1165] | 30 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory;
|
---|
| 31 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList;
|
---|
| 32 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
|
---|
| 33 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession;
|
---|
| 34 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder;
|
---|
| 35 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory;
|
---|
[1030] | 36 | import de.ugoe.cs.autoquest.test.CommandRunner;
|
---|
| 37 | import de.ugoe.cs.util.console.GlobalDataContainer;
|
---|
| 38 | import de.ugoe.cs.util.console.TextConsole;
|
---|
| 39 |
|
---|
[1040] | 40 | /**
|
---|
| 41 | * <p>
|
---|
| 42 | * TODO comment
|
---|
| 43 | * </p>
|
---|
| 44 | *
|
---|
| 45 | * @author Alexander Deicke
|
---|
| 46 | */
|
---|
[1165] | 47 | public class GenerateTaskModelUtil {
|
---|
[1040] | 48 |
|
---|
[1030] | 49 | private static final String seqName = "sequences";
|
---|
| 50 |
|
---|
| 51 | private static final String taskTreeName = "taskTree";
|
---|
[1141] | 52 |
|
---|
[1165] | 53 | public static ITaskModel getTaskModelFromSpec(String spec) {
|
---|
| 54 | ITaskFactory factory = new TaskFactory();
|
---|
| 55 | ITaskInstanceList taskInstances = new TaskTreeDecoder(factory, new TaskBuilder()).decode(spec);
|
---|
| 56 | List<IUserSession> userSessions = Lists.newArrayList();
|
---|
| 57 | userSessions.add((IUserSession) taskInstances);
|
---|
| 58 | return factory.createTaskModel(userSessions);
|
---|
[1141] | 59 | }
|
---|
| 60 |
|
---|
[1165] | 61 | public static ITaskModel getTaskTreeFromFile(String filename) {
|
---|
[1141] | 62 | new TextConsole(Level.OFF);
|
---|
[1030] | 63 | parseTraceFile(filename);
|
---|
| 64 | condenseGuiModel();
|
---|
| 65 | sortKeyInteractions();
|
---|
| 66 | correctKeyInteractionTargets();
|
---|
| 67 | detectTextInputEvents();
|
---|
| 68 | condenseMouseClicks();
|
---|
[1165] | 69 | return generateTaskModel();
|
---|
[1030] | 70 | }
|
---|
| 71 |
|
---|
| 72 | static private void parseTraceFile(String filetoparse) {
|
---|
| 73 | CommandRunner.runCommand(CMDparseJFC.class, ClassLoader.getSystemResource(filetoparse)
|
---|
| 74 | .getFile(), seqName);
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | private static void condenseGuiModel() {
|
---|
| 78 | CommandRunner.runCommand(CMDcondenseGuiModel.class, seqName);
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | private static void sortKeyInteractions() {
|
---|
| 82 | CommandRunner.runCommand(CMDsortKeyInteractions.class, seqName);
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | private static void correctKeyInteractionTargets() {
|
---|
| 86 | CommandRunner.runCommand(CMDcorrectKeyInteractionTargets.class, seqName);
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | private static void detectTextInputEvents() {
|
---|
| 90 | CommandRunner.runCommand(CMDdetectTextInputEvents.class, seqName);
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | private static void condenseMouseClicks() {
|
---|
| 94 | CommandRunner.runCommand(CMDcondenseMouseClicks.class, seqName);
|
---|
| 95 | }
|
---|
| 96 |
|
---|
[1165] | 97 | private static ITaskModel generateTaskModel() {
|
---|
[1030] | 98 | CommandRunner.runCommand(CMDgenerateTaskTree.class, seqName, taskTreeName);
|
---|
| 99 | GlobalDataContainer dataContainer = GlobalDataContainer.getInstance();
|
---|
[1165] | 100 | return (ITaskModel) dataContainer.getData(taskTreeName);
|
---|
[1030] | 101 | }
|
---|
| 102 |
|
---|
| 103 | }
|
---|