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 |
|
---|
15 | package de.ugoe.cs.autoquest.plugin.android;
|
---|
16 |
|
---|
17 | import static org.junit.Assert.assertNotNull;
|
---|
18 | import static org.junit.Assert.assertTrue;
|
---|
19 |
|
---|
20 | import java.io.File;
|
---|
21 | import java.util.Collection;
|
---|
22 | import java.util.List;
|
---|
23 | import java.util.logging.Level;
|
---|
24 |
|
---|
25 | import org.junit.Before;
|
---|
26 | import org.junit.Test;
|
---|
27 |
|
---|
28 | import de.ugoe.cs.autoquest.eventcore.Event;
|
---|
29 | import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel;
|
---|
30 | import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement;
|
---|
31 | import de.ugoe.cs.autoquest.plugin.android.guimodel.ANDROIDGUIElement;
|
---|
32 | import de.ugoe.cs.util.console.TextConsole;
|
---|
33 |
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * @author Florian Unger
|
---|
37 | */
|
---|
38 | public class ANDROIDLogParserTest {
|
---|
39 |
|
---|
40 | @Before
|
---|
41 | public void setUp() throws Exception {
|
---|
42 | new TextConsole(Level.FINEST);
|
---|
43 | }
|
---|
44 |
|
---|
45 | @Test
|
---|
46 | public void test() {
|
---|
47 | AndroidLogParser parser = new AndroidLogParser();
|
---|
48 | parser.parseFile(new File(ClassLoader.getSystemResource("androidLogFile_testRes1421664934020.log").getFile()));
|
---|
49 |
|
---|
50 | Collection<List<Event>> events = parser.getSequences();
|
---|
51 |
|
---|
52 | assertNotNull(events);
|
---|
53 | assertTrue(events.size() > 0);
|
---|
54 |
|
---|
55 | System.err.println("{");
|
---|
56 | for (List<Event> session : events) {
|
---|
57 | System.err.println(" {");
|
---|
58 | for (Event event : session) {
|
---|
59 | System.err.print(" ");
|
---|
60 | System.err.print(event);
|
---|
61 | System.err.println(",");
|
---|
62 | }
|
---|
63 | System.err.println(" }");
|
---|
64 | }
|
---|
65 | System.err.println("}");
|
---|
66 | System.err.println("\n\n");
|
---|
67 |
|
---|
68 | GUIModel guiModel = parser.getGuiModel();
|
---|
69 | assertNotNull(guiModel);
|
---|
70 |
|
---|
71 | for (IGUIElement root : guiModel.getRootElements()) {
|
---|
72 | dumpGUIElement(root, guiModel, "");
|
---|
73 | }
|
---|
74 | }
|
---|
75 |
|
---|
76 | /**
|
---|
77 | *
|
---|
78 | */
|
---|
79 | private void dumpGUIElement(IGUIElement guiElement, GUIModel guiModel, String indent) {
|
---|
80 | assertTrue(guiElement instanceof ANDROIDGUIElement);
|
---|
81 |
|
---|
82 | System.err.print(indent);
|
---|
83 | System.err.print(guiElement);
|
---|
84 |
|
---|
85 | List<IGUIElement> children = guiModel.getChildren(guiElement);
|
---|
86 |
|
---|
87 | if ((children != null) && (children.size() > 0)) {
|
---|
88 | System.err.println(" {");
|
---|
89 |
|
---|
90 | for (IGUIElement child : children) {
|
---|
91 | dumpGUIElement(child, guiModel, indent + " ");
|
---|
92 | }
|
---|
93 |
|
---|
94 | System.err.print(indent);
|
---|
95 | System.err.print("}");
|
---|
96 | }
|
---|
97 |
|
---|
98 | System.err.println();
|
---|
99 | }
|
---|
100 |
|
---|
101 | }
|
---|