Changeset 1429


Ignore:
Timestamp:
03/04/14 10:57:55 (10 years ago)
Author:
pharms
Message:
  • adapted logging of GUI elements to ensure that all GUI elements on the same page are logged at least once
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-htmlmonitor-test/src/test/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlMonitorTest.java

    r1342 r1429  
    423423        assertNotNull(nodes); 
    424424         
    425         // wait for only 9 nodes. The directly used GUI elements are 10, but one (the body) is the 
    426         // parent of the others. input9 is unused and must, therefore, not be logged. 
    427         assertEquals(9, nodes.size()); 
     425        // wait for all 10 GUI elements on the same page to be logged although only 9 are used 
     426        assertEquals(10, nodes.size()); 
    428427         
    429428        // get input nodes 
     
    433432            assertTrue(node instanceof HTMLPageElement); 
    434433            assertEquals("HTML", node.getPlatform()); 
    435             assertTrue(node.isUsed()); 
     434             
     435            if (!"input9".equals(((HTMLPageElement) node).getHtmlId())) { 
     436                assertTrue(node.isUsed()); 
     437            } 
     438            else { 
     439                assertFalse(node.isUsed()); 
     440            } 
    436441 
    437442            assertNotNull(guiModel.getChildren(node)); 
     
    462467        assertEvent(sequence.get(7), 8, MouseClick.class, nodes.get(7), 255, 4); 
    463468        assertEvent(sequence.get(8), 9, Scroll.class, body, 0, 0); 
    464         assertEvent(sequence.get(9), 10, MouseClick.class, nodes.get(8), 516, 154); 
     469        assertEvent(sequence.get(9), 10, MouseClick.class, nodes.get(9), 516, 154); 
    465470 
    466471    } 
  • trunk/autoquest-htmlmonitor/src/main/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlMonitorOutputWriter.java

    r1315 r1429  
    265265    /** 
    266266     * <p> 
    267      * dumps a GUI element starting with its parent GUI elements into the log file. Calls itself 
    268      * recursively to traverse for dumping the parents first. 
     267     * ensures that a GUI element, its parents as well as all other GUI elements on the same page 
     268     * are dumped 
    269269     * </p> 
    270270     * 
     
    274274        if (!loggedGUIElements.contains(guiElement)) { 
    275275             
    276             HtmlGUIElement parent = guiElement.getParent(); 
    277             String parentId = null; 
    278              
    279             if (parent != null) { 
    280                 ensureGuiElementDumped(parent); 
    281                 parentId = parent.getId(); 
    282             } 
    283              
     276            // determine the document as the whole document needs to be dumped. Ensure also that 
     277            // the server is dumped 
     278             
     279            HtmlGUIElement parent = guiElement; 
     280            HtmlDocument document = null; 
     281            HtmlServer server = null; 
     282             
     283            while (parent != null) { 
     284                if (parent instanceof HtmlDocument) { 
     285                    document = (HtmlDocument) parent; 
     286                } 
     287                else if (parent instanceof HtmlServer) { 
     288                    server = (HtmlServer) parent; 
     289                } 
     290                 
     291                parent = parent.getParent(); 
     292            } 
     293             
     294            if (server != null) { 
     295                dumpGuiElement(server); 
     296            } 
     297             
     298            if (document != null) { 
     299                dumpGuiStructure(document); 
     300            } 
     301        } 
     302    } 
     303 
     304    /** 
     305     * <p> 
     306     * dumps the GUI structure provided by the parameter into the log file. Calls itself 
     307     * recursively to traverse the GUI structure. 
     308     * </p> 
     309     * 
     310     * @param guiStructure the GUI structure to be logged 
     311     */ 
     312    private void dumpGuiStructure(HtmlGUIElement guiStructure) { 
     313        dumpGuiElement(guiStructure); 
     314         
     315        if (guiStructure.getChildren() != null) { 
     316            for (HtmlGUIElement child : guiStructure.getChildren()) { 
     317                dumpGuiStructure(child); 
     318            } 
     319        } 
     320    } 
     321 
     322    /** 
     323     * <p> 
     324     * dumps the GUI element provided by the parameter into the log file. 
     325     * </p> 
     326     * 
     327     * @param guiElement the GUI element to be logged 
     328     */ 
     329    private void dumpGuiElement(HtmlGUIElement guiElement) { 
     330        if (!loggedGUIElements.contains(guiElement)) { 
    284331            outputWriter.print("<component id=\""); 
    285332            outputWriter.print(guiElement.getId()); 
     
    301348            } 
    302349             
    303             dumpParam("parent", parentId); 
     350            if (guiElement.getParent() != null) { 
     351                dumpParam("parent", guiElement.getParent().getId()); 
     352            } 
    304353         
    305354            outputWriter.println("</component>"); 
Note: See TracChangeset for help on using the changeset viewer.