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.AnchorElement; | 7 import com.google.gwt.dom.client.AnchorElement; |
8 import com.google.gwt.dom.client.Style; | 8 import com.google.gwt.dom.client.Style; |
9 import org.chromium.distiller.webdocument.WebElement; | 9 import org.chromium.distiller.webdocument.WebElement; |
10 import org.chromium.distiller.webdocument.WebEmbed; | 10 import org.chromium.distiller.webdocument.WebEmbed; |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 image.setAttribute("height", "100"); | 511 image.setAttribute("height", "100"); |
512 | 512 |
513 Element figure = Document.get().createElement("FIGURE"); | 513 Element figure = Document.get().createElement("FIGURE"); |
514 figure.appendChild(image); | 514 figure.appendChild(image); |
515 figure.setAttribute("class", "test"); | 515 figure.setAttribute("class", "test"); |
516 figure.setAttribute("attribute", "value"); | 516 figure.setAttribute("attribute", "value"); |
517 | 517 |
518 Element figcaption = Document.get().createElement("FIGCAPTION"); | 518 Element figcaption = Document.get().createElement("FIGCAPTION"); |
519 AnchorElement anchor = Document.get().createAnchorElement(); | 519 AnchorElement anchor = Document.get().createAnchorElement(); |
520 anchor.setHref("link_page.html"); | 520 anchor.setHref("link_page.html"); |
521 anchor.setInnerHTML("caption link"); | 521 anchor.setInnerHTML("caption<br>link"); |
522 figcaption.appendChild(TestUtil.createText("This is a ")); | 522 figcaption.appendChild(TestUtil.createText("This is a ")); |
523 figcaption.appendChild(anchor); | 523 figcaption.appendChild(anchor); |
524 figure.appendChild(figcaption); | 524 figure.appendChild(figcaption); |
525 mBody.appendChild(figure); | 525 mBody.appendChild(figure); |
526 String expected = | 526 String expected = |
527 "<figure>" + | 527 "<figure>" + |
528 "<img src=\"http://wwww.example.com/image.jpeg\"" + | 528 "<img src=\"http://wwww.example.com/image.jpeg\"" + |
529 " width=\"100\" height=\"100\">" + | 529 " width=\"100\" height=\"100\">" + |
530 "<figcaption>This is a " + | 530 "<figcaption>This is a " + |
531 "<a href=\"http://example.com/link_page.html\">caption link<
/a>" + | 531 "<a href=\"http://example.com/link_page.html\">caption<br>li
nk</a>" + |
532 "</figcaption>" + | 532 "</figcaption>" + |
533 "</figure>"; | 533 "</figure>"; |
534 EmbedExtractor extractor = new ImageExtractor(); | 534 EmbedExtractor extractor = new ImageExtractor(); |
535 WebElement result = extractor.extract(figure); | 535 WebElement result = extractor.extract(figure); |
536 assertEquals(expected, TestUtil.removeAllDirAttributes( | 536 assertEquals(expected, TestUtil.removeAllDirAttributes( |
537 result.generateOutput(false))); | 537 result.generateOutput(false))); |
| 538 assertEquals("This is a caption\nlink", result.generateOutput(true)); |
538 } | 539 } |
539 | 540 |
540 public void testFigureWithCaptionWithoutAnchor() { | 541 public void testFigureWithCaptionWithoutAnchor() { |
541 ImageElement image = TestUtil.createImage(); | 542 ImageElement image = TestUtil.createImage(); |
542 image.setSrc("http://wwww.example.com/image.jpeg"); | 543 image.setSrc("http://wwww.example.com/image.jpeg"); |
543 image.setAttribute("width", "100"); | 544 image.setAttribute("width", "100"); |
544 image.setAttribute("height", "100"); | 545 image.setAttribute("height", "100"); |
545 Element figure = Document.get().createElement("FIGURE"); | 546 Element figure = Document.get().createElement("FIGURE"); |
546 figure.appendChild(image); | 547 figure.appendChild(image); |
547 Element figcaption = Document.get().createElement("FIGCAPTION"); | 548 Element figcaption = Document.get().createElement("FIGCAPTION"); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 "<img src=\"http://wwww.example.com/image.jpeg\"" + | 582 "<img src=\"http://wwww.example.com/image.jpeg\"" + |
582 " width=\"100\" height=\"100\">" + | 583 " width=\"100\" height=\"100\">" + |
583 "<figcaption>\nThis is a caption</figcaption>" + | 584 "<figcaption>\nThis is a caption</figcaption>" + |
584 "</figure>"; | 585 "</figure>"; |
585 EmbedExtractor extractor = new ImageExtractor(); | 586 EmbedExtractor extractor = new ImageExtractor(); |
586 WebElement result = extractor.extract(figure); | 587 WebElement result = extractor.extract(figure); |
587 assertEquals(expected, TestUtil.removeAllDirAttributes( | 588 assertEquals(expected, TestUtil.removeAllDirAttributes( |
588 result.generateOutput(false))); | 589 result.generateOutput(false))); |
589 } | 590 } |
590 } | 591 } |
OLD | NEW |