source: trunk/autoquest-plugin-html-test/src/test/java/de/ugoe/cs/autoquest/plugin/html/HTMLLogParserTest.java @ 960

Last change on this file since 960 was 960, checked in by pharms, 12 years ago
  • made event final, so that it can't be derived of
  • added support for adding further event parameters
File size: 3.1 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.html;
16
17import static org.junit.Assert.*;
18
19import java.io.File;
20import java.util.Collection;
21import java.util.List;
22
23import org.junit.After;
24import org.junit.Before;
25import org.junit.Test;
26
27import de.ugoe.cs.autoquest.eventcore.Event;
28import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel;
29import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement;
30import de.ugoe.cs.autoquest.plugin.html.guimodel.HTMLGUIElement;
31import de.ugoe.cs.util.console.TextConsole;
32
33/**
34 *
35 * @author Patrick Harms
36 */
37public class HTMLLogParserTest {
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        HTMLLogParser parser = new HTMLLogParser();
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}
Note: See TracBrowser for help on using the repository browser.