Changeset 649


Ignore:
Timestamp:
08/27/12 17:54:07 (12 years ago)
Author:
pharms
Message:
  • implemented dumping a GUI model to a stream
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/quest-plugin-mfc-test/src/test/java/de/ugoe/cs/quest/plugin/mfc/MFCLogParserTest.java

    r622 r649  
    1414import java.io.File; 
    1515import java.io.FileInputStream; 
     16import java.io.FileOutputStream; 
    1617import java.io.InputStreamReader; 
     18import java.io.PrintStream; 
    1719import java.util.Collection; 
    1820import java.util.List; 
     
    2527import de.ugoe.cs.quest.eventcore.Event; 
    2628import de.ugoe.cs.quest.eventcore.guimodel.GUIModel; 
    27 import de.ugoe.cs.quest.eventcore.guimodel.IGUIElement; 
    28 import de.ugoe.cs.quest.plugin.mfc.guimodel.MFCGUIElement; 
     29import de.ugoe.cs.util.console.Console; 
     30import de.ugoe.cs.util.console.listener.IOutputListener; 
    2931 
    3032/** 
     
    3436 * @author 2011, last modified by $Author: $ 
    3537 */ 
    36 public class MFCLogParserTest { 
     38public class MFCLogParserTest implements IOutputListener { 
    3739 
    3840    /** */ 
    3941    private File tmpFile; 
    4042     
     43    /** */ 
     44    private PrintStream outputStream; 
     45 
    4146    /** 
    4247     *  
     
    4449    @Before 
    4550    public void setUp() throws Exception { 
     51        outputStream = new PrintStream(new FileOutputStream("blub.log")); 
     52        Console.getInstance().registerOutputListener(this); 
     53         
    4654        tmpFile = new File("tmp.xml"); 
    4755         
     
    5664    @After 
    5765    public void tearDown() throws Exception { 
     66        if (!System.out.equals(outputStream) && !System.err.equals(outputStream)) { 
     67            outputStream.close(); 
     68        } 
     69         
    5870        if (tmpFile.exists()) { 
    5971            assertTrue(tmpFile.delete()); 
     
    96108        assertNotSame(0, guiModel.getRootElements().size()); 
    97109 
    98         for (IGUIElement root : guiModel.getRootElements()) { 
    99             dumpGUIElement(root, guiModel, ""); 
    100         } 
     110        guiModel.dump(System.err); 
    101111    } 
    102112 
     
    131141        assertNotNull(guiModel); 
    132142 
    133         for (IGUIElement root : guiModel.getRootElements()) { 
    134             dumpGUIElement(root, guiModel, ""); 
    135         } 
     143        guiModel.dump(System.err); 
    136144 
    137145        ReplayGenerator generator = new ReplayGenerator(); 
     
    157165    } 
    158166 
    159     /** 
    160      * TODO: comment 
    161      *  
    162      * @param root 
    163      * @param guiModel 
     167    /* (non-Javadoc) 
     168     * @see de.ugoe.cs.util.console.listener.IOutputListener#outputMsg(java.lang.String) 
    164169     */ 
    165     private void dumpGUIElement(IGUIElement guiElement, GUIModel guiModel, String indent) { 
    166         assertTrue(guiElement instanceof MFCGUIElement); 
    167  
    168         System.err.print(indent); 
    169         System.err.print(guiElement); 
    170  
    171         List<IGUIElement> children = guiModel.getChildren(guiElement); 
    172  
    173         if ((children != null) && (children.size() > 0)) { 
    174             System.err.println(" {"); 
    175  
    176             for (IGUIElement child : children) { 
    177                 dumpGUIElement(child, guiModel, indent + "  "); 
    178             } 
    179  
    180             System.err.print(indent); 
    181             System.err.print("}"); 
    182         } 
    183  
    184         System.err.println(); 
     170    @Override 
     171    public void outputMsg(String newMessage) { 
     172        outputStream.println(newMessage); 
    185173    } 
    186174 
Note: See TracChangeset for help on using the changeset viewer.