source: trunk/autoquest-plugin-jfc-test/src/test/java/de/ugoe/cs/autoquest/plugin/jfc/JFCLogParserTest.java @ 1426

Last change on this file since 1426 was 1426, checked in by pharms, 10 years ago
  • removed some TODOs
  • Property svn:executable set to *
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.jfc;
16
17import static org.junit.Assert.assertNotNull;
18import static org.junit.Assert.assertTrue;
19
20import java.io.File;
21import java.util.Collection;
22import java.util.List;
23import java.util.logging.Level;
24
25import org.junit.Before;
26import org.junit.Test;
27
28import de.ugoe.cs.autoquest.eventcore.Event;
29import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel;
30import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement;
31import de.ugoe.cs.autoquest.plugin.jfc.JFCLogParser;
32import de.ugoe.cs.autoquest.plugin.jfc.guimodel.JFCGUIElement;
33import de.ugoe.cs.util.console.TextConsole;
34
35/**
36 * @author Patrick Harms
37 */
38public class JFCLogParserTest {
39
40    /**
41     *
42     */
43    @Before
44    public void setUp() {
45        new TextConsole(Level.FINEST);
46    }
47
48    /**
49     *
50     */
51    @Test
52    public void test() throws Exception {
53        JFCLogParser parser = new JFCLogParser(null);
54        parser.parseFile(new File(ClassLoader.getSystemResource("trace.xml").getFile()));
55        Collection<List<Event>> events = parser.getSequences();
56
57        assertNotNull(events);
58        assertTrue(events.size() > 0);
59
60        System.err.println("{");
61        for (List<Event> session : events) {
62            System.err.println("  {");
63            for (Event event : session) {
64                System.err.print("    ");
65                System.err.print(event);
66                System.err.println(",");
67            }
68            System.err.println("  }");
69        }
70        System.err.println("}");
71        System.err.println("\n\n");
72
73        GUIModel guiModel = parser.getGuiModel();
74        assertNotNull(guiModel);
75
76        for (IGUIElement root : guiModel.getRootElements()) {
77            dumpGUIElement(root, guiModel, "");
78        }
79    }
80
81    /**
82     *
83     */
84    private void dumpGUIElement(IGUIElement guiElement, GUIModel guiModel, String indent) {
85        assertTrue(guiElement instanceof JFCGUIElement);
86
87        System.err.print(indent);
88        System.err.print(guiElement);
89
90        List<IGUIElement> children = guiModel.getChildren(guiElement);
91
92        if ((children != null) && (children.size() > 0)) {
93            System.err.println(" {");
94
95            for (IGUIElement child : children) {
96                dumpGUIElement(child, guiModel, indent + "  ");
97            }
98
99            System.err.print(indent);
100            System.err.print("}");
101        }
102
103        System.err.println();
104    }
105
106}
Note: See TracBrowser for help on using the repository browser.