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