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

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
  • Property svn:executable set to *
File size: 3.2 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 * TODO comment
37 *
38 * @version $Revision: $ $Date: $
39 * @author 2011, last modified by $Author: $
40 */
41public class JFCLogParserTest {
42
43    /**
44     *
45     */
46    @Before
47    public void setUp() {
48        new TextConsole(Level.FINEST);
49    }
50
51    /**
52     *
53     */
54    @Test
55    public void test() throws Exception {
56        JFCLogParser parser = new JFCLogParser(null);
57        parser.parseFile(new File(ClassLoader.getSystemResource("trace.xml").getFile()));
58        Collection<List<Event>> events = parser.getSequences();
59
60        assertNotNull(events);
61        assertTrue(events.size() > 0);
62
63        System.err.println("{");
64        for (List<Event> session : events) {
65            System.err.println("  {");
66            for (Event event : session) {
67                System.err.print("    ");
68                System.err.print(event);
69                System.err.println(",");
70            }
71            System.err.println("  }");
72        }
73        System.err.println("}");
74        System.err.println("\n\n");
75
76        GUIModel guiModel = parser.getGuiModel();
77        assertNotNull(guiModel);
78
79        for (IGUIElement root : guiModel.getRootElements()) {
80            dumpGUIElement(root, guiModel, "");
81        }
82    }
83
84    /**
85     * TODO: comment
86     *
87     * @param root
88     * @param guiModel
89     */
90    private void dumpGUIElement(IGUIElement guiElement, GUIModel guiModel, String indent) {
91        assertTrue(guiElement instanceof JFCGUIElement);
92
93        System.err.print(indent);
94        System.err.print(guiElement);
95
96        List<IGUIElement> children = guiModel.getChildren(guiElement);
97
98        if ((children != null) && (children.size() > 0)) {
99            System.err.println(" {");
100
101            for (IGUIElement child : children) {
102                dumpGUIElement(child, guiModel, indent + "  ");
103            }
104
105            System.err.print(indent);
106            System.err.print("}");
107        }
108
109        System.err.println();
110    }
111
112}
Note: See TracBrowser for help on using the repository browser.