1 | package de.ugoe.cs.autoquest.plugin.jfc;
|
---|
2 |
|
---|
3 | import static org.junit.Assert.assertNotNull;
|
---|
4 | import static org.junit.Assert.assertTrue;
|
---|
5 |
|
---|
6 | import java.io.File;
|
---|
7 | import java.util.Collection;
|
---|
8 | import java.util.List;
|
---|
9 | import java.util.logging.Level;
|
---|
10 |
|
---|
11 | import org.junit.Before;
|
---|
12 | import org.junit.Test;
|
---|
13 |
|
---|
14 | import de.ugoe.cs.autoquest.eventcore.Event;
|
---|
15 | import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel;
|
---|
16 | import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement;
|
---|
17 | import de.ugoe.cs.autoquest.plugin.jfc.JFCLogParser;
|
---|
18 | import de.ugoe.cs.autoquest.plugin.jfc.guimodel.JFCGUIElement;
|
---|
19 | import de.ugoe.cs.util.console.TextConsole;
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * TODO comment
|
---|
23 | *
|
---|
24 | * @version $Revision: $ $Date: $
|
---|
25 | * @author 2011, last modified by $Author: $
|
---|
26 | */
|
---|
27 | public class JFCSimplifiedLogParserTest {
|
---|
28 |
|
---|
29 | /**
|
---|
30 | *
|
---|
31 | */
|
---|
32 | @Before
|
---|
33 | public void setUp() {
|
---|
34 | new TextConsole(Level.FINEST);
|
---|
35 | }
|
---|
36 |
|
---|
37 | /**
|
---|
38 | *
|
---|
39 | */
|
---|
40 | @Test
|
---|
41 | public void test() throws Exception {
|
---|
42 | JFCSimplifiedLogParser parser = new JFCSimplifiedLogParser(null);
|
---|
43 | parser.parseFile(new File(ClassLoader.getSystemResource("newtrace.xml").getFile()));
|
---|
44 | Collection<List<Event>> events = parser.getSequences();
|
---|
45 |
|
---|
46 | assertNotNull(events);
|
---|
47 | assertTrue(events.size() > 0);
|
---|
48 |
|
---|
49 | System.err.println("{");
|
---|
50 | for (List<Event> session : events) {
|
---|
51 | System.err.println(" {");
|
---|
52 | for (Event event : session) {
|
---|
53 | System.err.print(" ");
|
---|
54 | System.err.print(event);
|
---|
55 | System.err.println(",");
|
---|
56 | }
|
---|
57 | System.err.println(" }");
|
---|
58 | }
|
---|
59 | System.err.println("}");
|
---|
60 | System.err.println("\n\n");
|
---|
61 |
|
---|
62 | GUIModel guiModel = parser.getGuiModel();
|
---|
63 | assertNotNull(guiModel);
|
---|
64 |
|
---|
65 | for (IGUIElement root : guiModel.getRootElements()) {
|
---|
66 | dumpGUIElement(root, guiModel, "");
|
---|
67 | }
|
---|
68 | }
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * TODO: comment
|
---|
72 | *
|
---|
73 | * @param root
|
---|
74 | * @param guiModel
|
---|
75 | */
|
---|
76 | private void dumpGUIElement(IGUIElement guiElement, GUIModel guiModel, String indent) {
|
---|
77 | assertTrue(guiElement instanceof JFCGUIElement);
|
---|
78 |
|
---|
79 | System.err.print(indent);
|
---|
80 | System.err.print(guiElement);
|
---|
81 |
|
---|
82 | List<IGUIElement> children = guiModel.getChildren(guiElement);
|
---|
83 |
|
---|
84 | if ((children != null) && (children.size() > 0)) {
|
---|
85 | System.err.println(" {");
|
---|
86 |
|
---|
87 | for (IGUIElement child : children) {
|
---|
88 | dumpGUIElement(child, guiModel, indent + " ");
|
---|
89 | }
|
---|
90 |
|
---|
91 | System.err.print(indent);
|
---|
92 | System.err.print("}");
|
---|
93 | }
|
---|
94 |
|
---|
95 | System.err.println();
|
---|
96 | }
|
---|
97 |
|
---|
98 | }
|
---|