source: trunk/autoquest-plugin-android/src/main/java/de/ugoe/cs/autoquest/plugin/android/commands/CMDparseAndroid.java @ 1783

Last change on this file since 1783 was 1783, checked in by funger, 10 years ago

Parser for onClick events only. Using MouseClick? to simulate onClick events.

  • Property svn:mime-type set to text/plain
File size: 2.6 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.plugin.android.commands;
16
17import java.util.Collection;
18import java.util.List;
19
20import de.ugoe.cs.autoquest.CommandHelpers;
21import de.ugoe.cs.autoquest.eventcore.Event;
22import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel;
23import de.ugoe.cs.autoquest.plugin.android.AndroidLogParser;
24import de.ugoe.cs.util.console.Command;
25import de.ugoe.cs.util.console.Console;
26import de.ugoe.cs.util.console.GlobalDataContainer;
27
28/**
29 * <p>
30 * Command to parse an XML file with sessions monitored by the Androidmonitor.
31 * </p>
32 *
33 * @author Florian Unger
34 * @version 1.0
35 */
36public class CMDparseAndroid implements Command {
37
38        /*
39     * (non-Javadoc)
40     *
41     * @see de.ugoe.cs.util.console.Command#run(java.util.List)
42     */
43        @Override
44        public void run(List<Object> parameters) {
45                String filename;
46                String sequencesName = "sequences";
47
48                try {
49                        filename = (String) parameters.get(0);
50                        if (parameters.size() >= 2) {
51                                sequencesName = (String) parameters.get(1);
52                        }
53                } catch (Exception e) {
54                        throw new IllegalArgumentException();
55                }
56
57                AndroidLogParser parser = new AndroidLogParser();
58
59                try {
60                        parser.parseFile(filename);
61                } catch (Exception e) {
62                        Console.printerrln("Could not parse " + filename + ": "
63                                        + e.getMessage());
64                        return;
65                }
66
67                Collection<List<Event>> sequences = parser.getSequences();
68
69                GUIModel targets = parser.getGuiModel();
70
71                if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
72                        CommandHelpers.dataOverwritten(sequencesName);
73                }
74
75                if (GlobalDataContainer.getInstance().addData(
76                                sequencesName + "_targets", targets)) {
77                        CommandHelpers.dataOverwritten(sequencesName + "_targets");
78                }
79        }
80
81        /*
82     * (non-Javadoc)
83     *
84     * @see de.ugoe.cs.util.console.Command#help()
85     */
86        @Override
87        public String help() {
88               
89                return "parseAndroid <filename> {<sequencesName>}";
90        }
91
92}
Note: See TracBrowser for help on using the repository browser.