1 19 20 33 package org.htmlparser.tests.scannersTests; 34 35 import org.htmlparser.scanners.FrameScanner; 36 import org.htmlparser.scanners.FrameSetScanner; 37 import org.htmlparser.tags.FrameSetTag; 38 import org.htmlparser.tags.FrameTag; 39 import org.htmlparser.tests.ParserTestCase; 40 import org.htmlparser.util.ParserException; 41 42 public class FrameSetScannerTest extends ParserTestCase 43 { 44 45 public FrameSetScannerTest(String name) 46 { 47 super(name); 48 } 49 50 public void testEvaluate() 51 { 52 String line1 = 53 "frameset rows=\"115,*\" frameborder=\"NO\" border=\"0\" framespacing=\"0\""; 54 String line2 = 55 "FRAMESET rows=\"115,*\" frameborder=\"NO\" border=\"0\" framespacing=\"0\""; 56 String line3 = 57 "Frameset rows=\"115,*\" frameborder=\"NO\" border=\"0\" framespacing=\"0\""; 58 FrameSetScanner frameSetScanner = new FrameSetScanner(""); 59 assertTrue("Line 1", frameSetScanner.evaluate(line1, null)); 60 assertTrue("Line 2", frameSetScanner.evaluate(line2, null)); 61 assertTrue("Line 3", frameSetScanner.evaluate(line3, null)); 62 } 63 64 public void testScan() throws ParserException 65 { 66 createParser( 67 "<frameset rows=\"115,*\" frameborder=\"NO\" border=\"0\" framespacing=\"0\">\n" 68 + "<frame name=\"topFrame\" noresize SRC=\"demo_bc_top.html\" scrolling=\"NO\" frameborder=\"NO\">\n" 69 + "<frame name=\"mainFrame\" SRC=\"http://www.kizna.com/web_e/\" scrolling=\"AUTO\">\n" 70 + "</frameset>", 71 "http://www.google.com/test/index.html"); 72 73 parser.addScanner(new FrameSetScanner("")); 74 parser.addScanner(new FrameScanner()); 75 76 parseAndAssertNodeCount(1); 77 assertTrue("Node 0 should be End Tag", node[0] instanceof FrameSetTag); 78 FrameSetTag frameSetTag = (FrameSetTag) node[0]; 79 assertEquals("Rows", "115,*", frameSetTag.getAttribute("rows")); 81 assertEquals( 82 "FrameBorder", 83 "NO", 84 frameSetTag.getAttribute("FrameBorder")); 85 assertEquals( 86 "FrameSpacing", 87 "0", 88 frameSetTag.getAttribute("FrameSpacing")); 89 assertEquals("Border", "0", frameSetTag.getAttribute("Border")); 90 FrameTag topFrame = frameSetTag.getFrame("topFrame"); 92 FrameTag mainFrame = frameSetTag.getFrame("mainFrame"); 93 assertNotNull("Top Frame should not be null", topFrame); 94 assertNotNull("Main Frame should not be null", mainFrame); 95 assertEquals("Top Frame Name", "topFrame", topFrame.getFrameName()); 96 assertEquals( 97 "Top Frame Location", 98 "http://www.google.com/test/demo_bc_top.html", 99 topFrame.getFrameLocation()); 100 assertEquals("Main Frame Name", "mainFrame", mainFrame.getFrameName()); 101 assertEquals( 102 "Main Frame Location", 103 "http://www.kizna.com/web_e/", 104 mainFrame.getFrameLocation()); 105 assertEquals( 106 "Scrolling in Main Frame", 107 "AUTO", 108 mainFrame.getAttribute("Scrolling")); 109 } 110 } 111 | Popular Tags |