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

Side by Side Diff: javatests/org/chromium/distiller/ContentExtractorTest.java

Issue 1190343004: Process ordered list items as a single WebText (Closed) Base URL: https://github.com/chromium/dom-distiller.git@master
Patch Set: Created 5 years, 6 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 unified diff | Download patch
OLDNEW
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.Document; 7 import com.google.gwt.dom.client.Document;
8 import com.google.gwt.dom.client.Element; 8 import com.google.gwt.dom.client.Element;
9 9
10 public class ContentExtractorTest extends DomDistillerJsTestCase { 10 public class ContentExtractorTest extends DomDistillerJsTestCase {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 outerFontTag.appendChild(TestUtil.createText(" ")); 132 outerFontTag.appendChild(TestUtil.createText(" "));
133 133
134 ContentExtractor extractor = new ContentExtractor(mRoot); 134 ContentExtractor extractor = new ContentExtractor(mRoot);
135 String extractedContent = extractor.extractContent(); 135 String extractedContent = extractor.extractContent();
136 assertEquals("<font><span><font>" + CONTENT_TEXT + "</font></span> " + 136 assertEquals("<font><span><font>" + CONTENT_TEXT + "</font></span> " +
137 "<span><font>" + CONTENT_TEXT + "</font></span>\n" + 137 "<span><font>" + CONTENT_TEXT + "</font></span>\n" +
138 "<span><font>" + CONTENT_TEXT + "</font></span> </font>", 138 "<span><font>" + CONTENT_TEXT + "</font></span> </font>",
139 TestUtil.removeAllDirAttributes(extractedContent)); 139 TestUtil.removeAllDirAttributes(extractedContent));
140 } 140 }
141 141
142 public void testPreserveOrderedList() {
143 Element outerListTag = Document.get().createElement("OL");
144 mBody.appendChild(outerListTag);
145
146 outerListTag.appendChild(TestUtil.createListItem(CONTENT_TEXT));
147 outerListTag.appendChild(TestUtil.createListItem(CONTENT_TEXT));
148 outerListTag.appendChild(TestUtil.createListItem(CONTENT_TEXT));
149 outerListTag.appendChild(TestUtil.createListItem(CONTENT_TEXT));
150
151 ContentExtractor extractor = new ContentExtractor(mRoot);
152 String extractedContent = extractor.extractContent();
153 assertEquals("<ol>" +
154 "<li>" + CONTENT_TEXT + "</li>" +
155 "<li>" + CONTENT_TEXT + "</li>" +
156 "<li>" + CONTENT_TEXT + "</li>" +
157 "<li>" + CONTENT_TEXT + "</li>" +
158 "</ol>",
159 TestUtil.removeAllDirAttributes(extractedContent));
160 }
161
142 private void assertExtractor(String expected, String html) { 162 private void assertExtractor(String expected, String html) {
143 mBody.setInnerHTML(""); 163 mBody.setInnerHTML("");
144 Element div = TestUtil.createDiv(0); 164 Element div = TestUtil.createDiv(0);
145 mBody.appendChild(div); 165 mBody.appendChild(div);
146 166
147 div.setInnerHTML(html); 167 div.setInnerHTML(html);
148 ContentExtractor extractor = new ContentExtractor(mRoot); 168 ContentExtractor extractor = new ContentExtractor(mRoot);
149 String extractedContent = extractor.extractContent(); 169 String extractedContent = extractor.extractContent();
150 assertEquals(expected, TestUtil.removeAllDirAttributes(extractedContent) ); 170 assertEquals(expected, TestUtil.removeAllDirAttributes(extractedContent) );
151 } 171 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 248
229 final String htmlArticle = 249 final String htmlArticle =
230 "<h1>" + CONTENT_TEXT + "</h1>" + 250 "<h1>" + CONTENT_TEXT + "</h1>" +
231 "<div itemscope itemtype=\"http://schema.org/Movie\">" + article + " </div>"; 251 "<div itemscope itemtype=\"http://schema.org/Movie\">" + article + " </div>";
232 final String expected = "<h1>" + CONTENT_TEXT + "</h1>" + article; 252 final String expected = "<h1>" + CONTENT_TEXT + "</h1>" + article;
233 253
234 // Non-article schema.org types should not use the fast path. 254 // Non-article schema.org types should not use the fast path.
235 assertExtractor(expected, htmlArticle); 255 assertExtractor(expected, htmlArticle);
236 } 256 }
237 } 257 }
OLDNEW
« no previous file with comments | « java/org/chromium/distiller/webdocument/ElementAction.java ('k') | javatests/org/chromium/distiller/TestUtil.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698