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