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.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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 ContentExtractor extractor = new ContentExtractor(mRoot); | 478 ContentExtractor extractor = new ContentExtractor(mRoot); |
479 String extractedContent = extractor.extractContent(); | 479 String extractedContent = extractor.extractContent(); |
480 assertEquals("<BLOCKQUOTE>" + | 480 assertEquals("<BLOCKQUOTE>" + |
481 "<p>" + CONTENT_TEXT + "</p>" + | 481 "<p>" + CONTENT_TEXT + "</p>" + |
482 "<p>" + CONTENT_TEXT + "</p>" + | 482 "<p>" + CONTENT_TEXT + "</p>" + |
483 "<p>" + CONTENT_TEXT + "</p>" + | 483 "<p>" + CONTENT_TEXT + "</p>" + |
484 "</BLOCKQUOTE>", | 484 "</BLOCKQUOTE>", |
485 TestUtil.removeAllDirAttributes(extractedContent)); | 485 TestUtil.removeAllDirAttributes(extractedContent)); |
486 } | 486 } |
487 | 487 |
| 488 public void testDiscardBlockquoteWithoutContent() { |
| 489 assertExtractor("", "<BLOCKQUOTE></BLOCKQUOTE>"); |
| 490 } |
| 491 |
| 492 public void testPreservePre() { |
| 493 final String article = CONTENT_TEXT + CONTENT_TEXT + CONTENT_TEXT; |
| 494 final String html = "<h1>" + CONTENT_TEXT + "</h1><PRE><kbd>" + article
+ "</kbd></PRE>"; |
| 495 |
| 496 assertExtractor(html, html); |
| 497 } |
| 498 |
488 private void assertExtractor(String expected, String html) { | 499 private void assertExtractor(String expected, String html) { |
489 mBody.setInnerHTML(""); | 500 mBody.setInnerHTML(""); |
490 Element div = TestUtil.createDiv(0); | 501 Element div = TestUtil.createDiv(0); |
491 mBody.appendChild(div); | 502 mBody.appendChild(div); |
492 | 503 |
493 div.setInnerHTML(html); | 504 div.setInnerHTML(html); |
494 ContentExtractor extractor = new ContentExtractor(mRoot); | 505 ContentExtractor extractor = new ContentExtractor(mRoot); |
495 String extractedContent = extractor.extractContent(); | 506 String extractedContent = extractor.extractContent(); |
496 assertEquals(expected, TestUtil.removeAllDirAttributes(extractedContent)
); | 507 assertEquals(expected, TestUtil.removeAllDirAttributes(extractedContent)
); |
497 } | 508 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 | 585 |
575 final String htmlArticle = | 586 final String htmlArticle = |
576 "<h1>" + CONTENT_TEXT + "</h1>" + | 587 "<h1>" + CONTENT_TEXT + "</h1>" + |
577 "<div itemscope itemtype=\"http://schema.org/Movie\">" + article + "
</div>"; | 588 "<div itemscope itemtype=\"http://schema.org/Movie\">" + article + "
</div>"; |
578 final String expected = "<h1>" + CONTENT_TEXT + "</h1>" + article; | 589 final String expected = "<h1>" + CONTENT_TEXT + "</h1>" + article; |
579 | 590 |
580 // Non-article schema.org types should not use the fast path. | 591 // Non-article schema.org types should not use the fast path. |
581 assertExtractor(expected, htmlArticle); | 592 assertExtractor(expected, htmlArticle); |
582 } | 593 } |
583 } | 594 } |
OLD | NEW |