Changeset 1315
- Timestamp:
- 10/07/13 16:10:45 (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-htmlmonitor-test/src/test/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlMonitorServerTest.java
r1245 r1315 614 614 615 615 if (parent != null) { 616 assertEquals(parent.getId(), element.getParentId()); 616 assertNotNull(element.getParent()); 617 assertEquals(parent.getId(), element.getParent().getId()); 617 618 } 618 619 else { 619 assertNull(element.getParent Id());620 assertNull(element.getParent()); 620 621 } 621 622 -
trunk/autoquest-htmlmonitor-test/src/test/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlMonitorTest.java
r1245 r1315 421 421 nodes = guiModel.getChildren(body); 422 422 assertNotNull(nodes); 423 assertEquals(10, nodes.size()); 423 424 // wait for only 9 nodes. The directly used GUI elements are 10, but one (the body) is the 425 // parent of the others. input9 is unused and must, therefore, not be logged. 426 assertEquals(9, nodes.size()); 424 427 425 428 // get input nodes … … 429 432 assertTrue(node instanceof HTMLPageElement); 430 433 assertEquals("HTML", node.getPlatform()); 431 432 if (i != 8) { 433 assertTrue(node.isUsed()); 434 } 435 else { 436 assertFalse(node.isUsed()); 437 } 434 assertTrue(node.isUsed()); 438 435 439 436 assertNotNull(guiModel.getChildren(node)); … … 464 461 assertEvent(sequence.get(7), 8, MouseClick.class, nodes.get(7), 255, 4); 465 462 assertEvent(sequence.get(8), 9, Scroll.class, body, 0, 0); 466 assertEvent(sequence.get(9), 10, MouseClick.class, nodes.get( 9), 516, 154);463 assertEvent(sequence.get(9), 10, MouseClick.class, nodes.get(8), 516, 154); 467 464 468 465 } -
trunk/autoquest-htmlmonitor/src/main/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlGUIElement.java
r1075 r1315 113 113 /** 114 114 * <p> 115 * returns the id of theparent GUI element, if any115 * returns the parent GUI element, if any 116 116 * </p> 117 117 * 118 * @return the id of theparent GUI element, or null, if this element does not have a parent118 * @return the parent GUI element, or null, if this element does not have a parent 119 119 */ 120 String getParentId() { 121 if (parent == null) { 122 return null; 123 } 124 else { 125 return parent.getId(); 126 } 120 HtmlGUIElement getParent() { 121 return parent; 127 122 } 128 123 -
trunk/autoquest-htmlmonitor/src/main/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlMonitorOutputWriter.java
r1268 r1315 204 204 } 205 205 206 if (guiStructure != null) {207 dumpGuiStructure(guiStructure);208 }209 210 206 for (HtmlEvent event : events) { 211 207 dumpEvent(event); … … 226 222 /** 227 223 * <p> 228 * dumps the GUI structure provided by the parameter into the log file. Calls itself229 * recursively to traverse the GUI structure.230 * </p>231 *232 * @param guiStructure the GUI structure to be logged233 */234 private void dumpGuiStructure(HtmlGUIElement guiStructure) {235 if (!loggedGUIElements.contains(guiStructure)) {236 outputWriter.print("<component id=\"");237 outputWriter.print(guiStructure.getId());238 outputWriter.println("\">");239 240 if (guiStructure instanceof HtmlServer) {241 dumpParam("host", ((HtmlServer) guiStructure).getName());242 dumpParam("port", ((HtmlServer) guiStructure).getPort());243 }244 else if (guiStructure instanceof HtmlDocument) {245 dumpParam("path", ((HtmlDocument) guiStructure).getPath());246 dumpParam("query", ((HtmlDocument) guiStructure).getQuery());247 dumpParam("title", ((HtmlDocument) guiStructure).getTitle());248 }249 else if (guiStructure instanceof HtmlPageElement) {250 dumpParam("tagname", ((HtmlPageElement) guiStructure).getTagName());251 dumpParam("htmlid", ((HtmlPageElement) guiStructure).getHtmlId());252 dumpParam("index", ((HtmlPageElement) guiStructure).getIndex());253 }254 255 dumpParam("parent", guiStructure.getParentId());256 257 outputWriter.println("</component>");258 259 loggedGUIElements.add(guiStructure);260 }261 262 if (guiStructure.getChildren() != null) {263 for (HtmlGUIElement child : guiStructure.getChildren()) {264 dumpGuiStructure(child);265 }266 }267 }268 269 /**270 * <p>271 224 * formats a received event and writes it to the log file. One event results in one line 272 225 * in the log file containing all infos of the event. … … 276 229 */ 277 230 private void dumpEvent(HtmlEvent event) { 231 if (event.getTarget() != null) { 232 ensureGuiElementDumped(event.getTarget()); 233 } 234 278 235 outputWriter.print("<event type=\""); 279 236 outputWriter.print(event.getEventType()); … … 304 261 305 262 outputWriter.println("</event>"); 263 } 264 265 /** 266 * <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. 269 * </p> 270 * 271 * @param guiStructure the GUI structure to be logged 272 */ 273 private void ensureGuiElementDumped(HtmlGUIElement guiElement) { 274 if (!loggedGUIElements.contains(guiElement)) { 275 276 HtmlGUIElement parent = guiElement.getParent(); 277 String parentId = null; 278 279 if (parent != null) { 280 ensureGuiElementDumped(parent); 281 parentId = parent.getId(); 282 } 283 284 outputWriter.print("<component id=\""); 285 outputWriter.print(guiElement.getId()); 286 outputWriter.println("\">"); 287 288 if (guiElement instanceof HtmlServer) { 289 dumpParam("host", ((HtmlServer) guiElement).getName()); 290 dumpParam("port", ((HtmlServer) guiElement).getPort()); 291 } 292 else if (guiElement instanceof HtmlDocument) { 293 dumpParam("path", ((HtmlDocument) guiElement).getPath()); 294 dumpParam("query", ((HtmlDocument) guiElement).getQuery()); 295 dumpParam("title", ((HtmlDocument) guiElement).getTitle()); 296 } 297 else if (guiElement instanceof HtmlPageElement) { 298 dumpParam("tagname", ((HtmlPageElement) guiElement).getTagName()); 299 dumpParam("htmlid", ((HtmlPageElement) guiElement).getHtmlId()); 300 dumpParam("index", ((HtmlPageElement) guiElement).getIndex()); 301 } 302 303 dumpParam("parent", parentId); 304 305 outputWriter.println("</component>"); 306 307 loggedGUIElements.add(guiElement); 308 } 306 309 } 307 310
Note: See TracChangeset
for help on using the changeset viewer.