[927] | 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 |
|
---|
[922] | 15 | package de.ugoe.cs.autoquest.plugin.jfc;
|
---|
[575] | 16 |
|
---|
| 17 | import static org.junit.Assert.assertNotNull;
|
---|
| 18 | import static org.junit.Assert.assertTrue;
|
---|
| 19 |
|
---|
| 20 | import java.io.File;
|
---|
| 21 | import java.util.Collection;
|
---|
| 22 | import java.util.List;
|
---|
[725] | 23 | import java.util.logging.Level;
|
---|
[575] | 24 |
|
---|
| 25 | import org.junit.Before;
|
---|
| 26 | import org.junit.Test;
|
---|
| 27 |
|
---|
[922] | 28 | import de.ugoe.cs.autoquest.eventcore.Event;
|
---|
| 29 | import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel;
|
---|
| 30 | import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement;
|
---|
| 31 | import de.ugoe.cs.autoquest.plugin.jfc.JFCLogParser;
|
---|
| 32 | import de.ugoe.cs.autoquest.plugin.jfc.guimodel.JFCGUIElement;
|
---|
[725] | 33 | import de.ugoe.cs.util.console.TextConsole;
|
---|
[575] | 34 |
|
---|
| 35 | /**
|
---|
| 36 | * TODO comment
|
---|
| 37 | *
|
---|
| 38 | * @version $Revision: $ $Date: $
|
---|
| 39 | * @author 2011, last modified by $Author: $
|
---|
| 40 | */
|
---|
[601] | 41 | public class JFCLogParserTest {
|
---|
[575] | 42 |
|
---|
| 43 | /**
|
---|
[601] | 44 | *
|
---|
| 45 | */
|
---|
[575] | 46 | @Before
|
---|
[601] | 47 | public void setUp() {
|
---|
[725] | 48 | new TextConsole(Level.FINEST);
|
---|
[575] | 49 | }
|
---|
| 50 |
|
---|
| 51 | /**
|
---|
[601] | 52 | *
|
---|
| 53 | */
|
---|
[575] | 54 | @Test
|
---|
[601] | 55 | public void test() throws Exception {
|
---|
[575] | 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");
|
---|
[601] | 75 |
|
---|
[575] | 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
|
---|
[601] | 86 | *
|
---|
[575] | 87 | * @param root
|
---|
| 88 | * @param guiModel
|
---|
| 89 | */
|
---|
[601] | 90 | private void dumpGUIElement(IGUIElement guiElement, GUIModel guiModel, String indent) {
|
---|
[575] | 91 | assertTrue(guiElement instanceof JFCGUIElement);
|
---|
[601] | 92 |
|
---|
[575] | 93 | System.err.print(indent);
|
---|
| 94 | System.err.print(guiElement);
|
---|
[601] | 95 |
|
---|
[575] | 96 | List<IGUIElement> children = guiModel.getChildren(guiElement);
|
---|
[601] | 97 |
|
---|
| 98 | if ((children != null) && (children.size() > 0)) {
|
---|
[575] | 99 | System.err.println(" {");
|
---|
[601] | 100 |
|
---|
| 101 | for (IGUIElement child : children) {
|
---|
[575] | 102 | dumpGUIElement(child, guiModel, indent + " ");
|
---|
| 103 | }
|
---|
[601] | 104 |
|
---|
[575] | 105 | System.err.print(indent);
|
---|
| 106 | System.err.print("}");
|
---|
| 107 | }
|
---|
[601] | 108 |
|
---|
[575] | 109 | System.err.println();
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | }
|
---|