Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Unified Diff: test/com/dom_distiller/client/DomToSaxVisitorTest.java

Issue 275493007: filter out invisible elements (Closed) Base URL: https://code.google.com/p/dom-distiller/@master
Patch Set: addressed comments Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/com/dom_distiller/client/DomToSaxVisitorTest.java
diff --git a/test/com/dom_distiller/client/DomToSaxParserTest.java b/test/com/dom_distiller/client/DomToSaxVisitorTest.java
similarity index 69%
rename from test/com/dom_distiller/client/DomToSaxParserTest.java
rename to test/com/dom_distiller/client/DomToSaxVisitorTest.java
index 8a9b60fd82eaf9294a191140c3d6e3f7c53e9d08..4e915b3d70ebc396a68043f580b34765e942c964 100644
--- a/test/com/dom_distiller/client/DomToSaxParserTest.java
+++ b/test/com/dom_distiller/client/DomToSaxVisitorTest.java
@@ -19,7 +19,7 @@ import com.google.gwt.user.client.DOM;
import org.xml.sax.Attributes;
-public class DomToSaxParserTest extends GWTTestCase {
+public class DomToSaxVisitorTest extends GWTTestCase {
@Override
public String getModuleName() {
return "com.dom_distiller.DomDistillerJUnit";
@@ -37,41 +37,42 @@ public class DomToSaxParserTest extends GWTTestCase {
Element e = Document.get().createDivElement();
e.setInnerHTML("<div style=\"width:50px; height:100px\" id=\"f\" class=\"sdf\"></div>");
e = Element.as(e.getChildNodes().getItem(0));
- Attributes attrs = DomToSaxParser.getSaxAttributes(e);
+ Attributes attrs = DomToSaxVisitor.getSaxAttributes(e);
assertEquals(3, attrs.getLength());
assertEquals("f", attrs.getValue("id"));
assertEquals("sdf", attrs.getValue("class"));
}
- private void runDomParserTest(String innerHtml) throws Throwable {
+ private void runDomVisitorTest(String innerHtml) throws Throwable {
Element container = Document.get().createDivElement();
container.setInnerHTML(innerHtml);
SimpleContentHandler contentHandler = new SimpleContentHandler();
- DomToSaxParser.parse(container, contentHandler);
+ DomToSaxVisitor visitor = new DomToSaxVisitor(contentHandler);
+ new DomWalker(visitor).walk(container);
String expectedDocument = "<div>" + innerHtml + "</div>";
assertEquals(expectedDocument, contentHandler.getDocumentString().toLowerCase());
}
- public void testDomParserText() throws Throwable {
- runDomParserTest("foo");
+ public void testDomVisitorText() throws Throwable {
+ runDomVisitorTest("foo");
}
- public void testDomParserElement() throws Throwable {
- runDomParserTest("<div></div>");
+ public void testDomVisitorElement() throws Throwable {
+ runDomVisitorTest("<div></div>");
}
- public void testDomParserSiblings() throws Throwable {
- runDomParserTest("<div></div><div></div>");
+ public void testDomVisitorSiblings() throws Throwable {
+ runDomVisitorTest("<div></div><div></div>");
}
- public void testDomParserAttribute() throws Throwable {
- runDomParserTest("<div style=\"width:50px; height:100px\" id=\"f\" class=\"sdf\"></div>");
+ public void testDomVisitorAttribute() throws Throwable {
+ runDomVisitorTest("<div style=\"width:50px; height:100px\" id=\"f\" class=\"sdf\"></div>");
}
- public void testDomParserSimplePage() throws Throwable {
+ public void testDomVisitorSimplePage() throws Throwable {
String simpleHtml =
"<div id=\"a\" class=\"foo\">foo<a href=\"x.com/#1\">x.com</a>bar</div>" +
"<div>baz</div>";
- runDomParserTest(simpleHtml);
+ runDomVisitorTest(simpleHtml);
}
}
« no previous file with comments | « test/com/dom_distiller/client/DomToSaxParserTest.java ('k') | test/com/dom_distiller/client/FilteringDomVisitorTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698