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 org.chromium.distiller; | 5 package org.chromium.distiller; |
6 | 6 |
| 7 import com.google.gwt.dom.client.NodeList; |
7 import org.chromium.distiller.webdocument.WebTable; | 8 import org.chromium.distiller.webdocument.WebTable; |
8 | 9 |
9 import com.google.gwt.core.client.JsArray; | 10 import com.google.gwt.core.client.JsArray; |
10 import com.google.gwt.dom.client.Document; | 11 import com.google.gwt.dom.client.Document; |
11 import com.google.gwt.dom.client.Element; | 12 import com.google.gwt.dom.client.Element; |
12 import com.google.gwt.dom.client.Node; | 13 import com.google.gwt.dom.client.Node; |
13 | 14 |
14 import java.util.Map; | 15 import java.util.Map; |
15 import java.util.List; | 16 import java.util.List; |
16 | 17 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 104 |
104 Element currDiv = TestUtil.createDiv(3); | 105 Element currDiv = TestUtil.createDiv(3); |
105 div2.appendChild(currDiv); | 106 div2.appendChild(currDiv); |
106 Element finalDiv1 = currDiv; | 107 Element finalDiv1 = currDiv; |
107 | 108 |
108 currDiv = TestUtil.createDiv(4); | 109 currDiv = TestUtil.createDiv(4); |
109 div2.appendChild(currDiv); | 110 div2.appendChild(currDiv); |
110 currDiv.appendChild(TestUtil.createDiv(5)); | 111 currDiv.appendChild(TestUtil.createDiv(5)); |
111 | 112 |
112 assertEquals(div2, DomUtil.getNearestCommonAncestor(finalDiv1, currDiv.g
etChild(0))); | 113 assertEquals(div2, DomUtil.getNearestCommonAncestor(finalDiv1, currDiv.g
etChild(0))); |
113 assertEquals(div2, DomUtil.getNearestCommonAncestor( | 114 NodeList<Element> elementNodeList = DomUtil.querySelectorAll(mRoot, "[id
=\"3\"],[id=\"5\"]"); |
114 DomUtil.querySelectorAll(mRoot, "[id=\"3\"],[id=\"5\"]"))); | 115 assertEquals(div2, DomUtil.getNearestCommonAncestor(elementNodeList)); |
| 116 assertEquals(div2, DomUtil.getNearestCommonAncestor(TestUtil.nodeListToL
ist(elementNodeList))); |
| 117 |
115 } | 118 } |
116 | 119 |
117 /** | 120 /** |
118 * The tree graph is: | 121 * The tree graph is: |
119 * 1 - 2 - 3 | 122 * 1 - 2 - 3 |
120 */ | 123 */ |
121 public void testNearestCommonAncestorIsRoot() { | 124 public void testNearestCommonAncestorIsRoot() { |
122 Element div = TestUtil.createDiv(1); | 125 Element div = TestUtil.createDiv(1); |
123 mBody.appendChild(div); | 126 mBody.appendChild(div); |
124 | 127 |
125 Element div2 = TestUtil.createDiv(2); | 128 Element div2 = TestUtil.createDiv(2); |
126 div.appendChild(div2); | 129 div.appendChild(div2); |
127 | 130 |
128 Element div3 = TestUtil.createDiv(3); | 131 Element div3 = TestUtil.createDiv(3); |
129 div2.appendChild(div3); | 132 div2.appendChild(div3); |
130 | 133 |
131 assertEquals(div, DomUtil.getNearestCommonAncestor(div, div3)); | 134 assertEquals(div, DomUtil.getNearestCommonAncestor(div, div3)); |
132 assertEquals(div, DomUtil.getNearestCommonAncestor( | 135 NodeList<Element> elementNodeList = DomUtil.querySelectorAll(mRoot, "[id
=\"1\"],[id=\"3\"]"); |
133 DomUtil.querySelectorAll(mRoot, "[id=\"1\"],[id=\"3\"]"))); | 136 assertEquals(div, DomUtil.getNearestCommonAncestor(elementNodeList)); |
| 137 assertEquals(div, DomUtil.getNearestCommonAncestor(TestUtil.nodeListToLi
st(elementNodeList))); |
134 } | 138 } |
135 | 139 |
136 public void testNodeDepth() { | 140 public void testNodeDepth() { |
137 Element div = TestUtil.createDiv(1); | 141 Element div = TestUtil.createDiv(1); |
138 | 142 |
139 Element div2 = TestUtil.createDiv(2); | 143 Element div2 = TestUtil.createDiv(2); |
140 div.appendChild(div2); | 144 div.appendChild(div2); |
141 | 145 |
142 Element div3 = TestUtil.createDiv(3); | 146 Element div3 = TestUtil.createDiv(3); |
143 div2.appendChild(div3); | 147 div2.appendChild(div3); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 "<td>text</td>" + | 343 "<td>text</td>" + |
340 "</tr>" + | 344 "</tr>" + |
341 "</tbody>" + | 345 "</tbody>" + |
342 "</table>"; | 346 "</table>"; |
343 | 347 |
344 mBody.setInnerHTML(html); | 348 mBody.setInnerHTML(html); |
345 DomUtil.stripStyleAttributes(mBody); | 349 DomUtil.stripStyleAttributes(mBody); |
346 assertEquals(expected, mBody.getInnerHTML()); | 350 assertEquals(expected, mBody.getInnerHTML()); |
347 } | 351 } |
348 } | 352 } |
OLD | NEW |