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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 final String article = "<p>" + CONTENT_TEXT + "</p><p>" + CONTENT_TEXT +
"</p>"; | 597 final String article = "<p>" + CONTENT_TEXT + "</p><p>" + CONTENT_TEXT +
"</p>"; |
598 | 598 |
599 final String htmlArticle = | 599 final String htmlArticle = |
600 "<h1>" + CONTENT_TEXT + "</h1>" + | 600 "<h1>" + CONTENT_TEXT + "</h1>" + |
601 "<div itemscope itemtype=\"http://schema.org/Movie\">" + article + "
</div>"; | 601 "<div itemscope itemtype=\"http://schema.org/Movie\">" + article + "
</div>"; |
602 final String expected = "<h1>" + CONTENT_TEXT + "</h1>" + article; | 602 final String expected = "<h1>" + CONTENT_TEXT + "</h1>" + article; |
603 | 603 |
604 // Non-article schema.org types should not use the fast path. | 604 // Non-article schema.org types should not use the fast path. |
605 assertExtractor(expected, htmlArticle); | 605 assertExtractor(expected, htmlArticle); |
606 } | 606 } |
| 607 |
| 608 public void testDropCap() { |
| 609 String html = |
| 610 "<h1>" + |
| 611 CONTENT_TEXT + |
| 612 "</h1>" + |
| 613 "<p>" + |
| 614 "<strong><span style=\"float: left\">T</span>est</strong>" + |
| 615 CONTENT_TEXT + |
| 616 "</p>"; |
| 617 |
| 618 final String expected = |
| 619 "<h1>" + |
| 620 CONTENT_TEXT + |
| 621 "</h1>" + |
| 622 "<p>" + |
| 623 "<strong><span>T</span>est</strong>" + |
| 624 CONTENT_TEXT + |
| 625 "</p>"; |
| 626 |
| 627 mBody.setInnerHTML(html); |
| 628 |
| 629 ContentExtractor extractor = new ContentExtractor(mRoot); |
| 630 String extractedContent = extractor.extractContent(); |
| 631 assertEquals(expected, |
| 632 TestUtil.removeAllDirAttributes(extractedContent)); |
| 633 } |
607 } | 634 } |
OLD | NEW |