| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package com.dom_distiller.client; | 5 package com.dom_distiller.client; |
| 6 | 6 |
| 7 import com.google.gwt.junit.client.GWTTestCase; | 7 import com.google.gwt.junit.client.GWTTestCase; |
| 8 | 8 |
| 9 import com.google.gwt.core.client.JsArray; | 9 import com.google.gwt.core.client.JsArray; |
| 10 import com.google.gwt.dom.client.Document; | 10 import com.google.gwt.dom.client.Document; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 e.setInnerHTML("<div style=\"width:50px; height:100px\" id=\"f\" class=\
"sdf\"></div>"); | 24 e.setInnerHTML("<div style=\"width:50px; height:100px\" id=\"f\" class=\
"sdf\"></div>"); |
| 25 e = Element.as(e.getChildNodes().getItem(0)); | 25 e = Element.as(e.getChildNodes().getItem(0)); |
| 26 JsArray<Node> jsAttrs = DomUtil.getAttributes(e); | 26 JsArray<Node> jsAttrs = DomUtil.getAttributes(e); |
| 27 assertEquals(3, jsAttrs.length()); | 27 assertEquals(3, jsAttrs.length()); |
| 28 } | 28 } |
| 29 | 29 |
| 30 public void testGetSaxAttributes() { | 30 public void testGetSaxAttributes() { |
| 31 Element e = Document.get().createDivElement(); | 31 Element e = Document.get().createDivElement(); |
| 32 e.setInnerHTML("<div style=\"width:50px; height:100px\" id=\"f\" class=\
"sdf\"></div>"); | 32 e.setInnerHTML("<div style=\"width:50px; height:100px\" id=\"f\" class=\
"sdf\"></div>"); |
| 33 e = Element.as(e.getChildNodes().getItem(0)); | 33 e = Element.as(e.getChildNodes().getItem(0)); |
| 34 Attributes attrs = DomToSaxVisitor.getSaxAttributes(e); | 34 Attributes attrs = DomToSaxVisitor.getAttributes(e); |
| 35 assertEquals(3, attrs.getLength()); | 35 assertEquals(3, attrs.getLength()); |
| 36 assertEquals("f", attrs.getValue("id")); | 36 assertEquals("f", attrs.getValue("id")); |
| 37 assertEquals("sdf", attrs.getValue("class")); | 37 assertEquals("sdf", attrs.getValue("class")); |
| 38 } | 38 } |
| 39 | 39 |
| 40 private void runDomVisitorTest(String innerHtml) throws Throwable { | 40 private void runDomVisitorTest(String innerHtml) throws Throwable { |
| 41 Element container = Document.get().createDivElement(); | 41 Element container = Document.get().createDivElement(); |
| 42 container.setInnerHTML(innerHtml); | 42 container.setInnerHTML(innerHtml); |
| 43 SimpleContentHandler contentHandler = new SimpleContentHandler(); | 43 SimpleContentHandler contentHandler = new SimpleContentHandler(); |
| 44 DomToSaxVisitor visitor = new DomToSaxVisitor(contentHandler); | 44 DomToSaxVisitor visitor = new DomToSaxVisitor(contentHandler); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 63 runDomVisitorTest("<div style=\"width:50px; height:100px\" id=\"f\" clas
s=\"sdf\"></div>"); | 63 runDomVisitorTest("<div style=\"width:50px; height:100px\" id=\"f\" clas
s=\"sdf\"></div>"); |
| 64 } | 64 } |
| 65 | 65 |
| 66 public void testDomVisitorSimplePage() throws Throwable { | 66 public void testDomVisitorSimplePage() throws Throwable { |
| 67 String simpleHtml = | 67 String simpleHtml = |
| 68 "<div id=\"a\" class=\"foo\">foo<a href=\"x.com/#1\">x.com</a>ba
r</div>" + | 68 "<div id=\"a\" class=\"foo\">foo<a href=\"x.com/#1\">x.com</a>ba
r</div>" + |
| 69 "<div>baz</div>"; | 69 "<div>baz</div>"; |
| 70 runDomVisitorTest(simpleHtml); | 70 runDomVisitorTest(simpleHtml); |
| 71 } | 71 } |
| 72 } | 72 } |
| OLD | NEW |