| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.webdocument; | 5 package org.chromium.distiller.webdocument; |
| 6 | 6 |
| 7 import org.chromium.distiller.DomDistillerJsTestCase; | 7 import org.chromium.distiller.DomDistillerJsTestCase; |
| 8 import org.chromium.distiller.TestUtil; | 8 import org.chromium.distiller.TestUtil; |
| 9 | 9 |
| 10 import com.google.gwt.dom.client.Document; | 10 import com.google.gwt.dom.client.Document; |
| 11 import com.google.gwt.dom.client.Element; | 11 import com.google.gwt.dom.client.Element; |
| 12 import com.google.gwt.dom.client.Node; | 12 import com.google.gwt.dom.client.Node; |
| 13 | 13 |
| 14 import java.util.List; | 14 import java.util.List; |
| 15 | 15 |
| 16 public class WebVideoTest extends DomDistillerJsTestCase { | 16 public class WebVideoTest extends DomDistillerJsTestCase { |
| 17 public void testGenerateOutput() { | 17 public void testGenerateOutput() { |
| 18 Element video = Document.get().createVideoElement(); | 18 Element video = Document.get().createVideoElement(); |
| 19 Element child = Document.get().createElement("source"); | 19 Element child = Document.get().createElement("source"); |
| 20 child.setAttribute("src", "http://example.com/foo.ogg"); | 20 child.setAttribute("src", "http://example.com/foo.ogg"); |
| 21 video.appendChild(child); | 21 video.appendChild(child); |
| 22 | 22 |
| 23 child = Document.get().createElement("track"); | 23 child = Document.get().createElement("track"); |
| 24 child.setAttribute("src", "http://example.com/foo.vtt"); | 24 child.setAttribute("src", "http://example.com/foo.vtt"); |
| 25 video.appendChild(child); | 25 video.appendChild(child); |
| 26 | 26 |
| 27 | 27 |
| 28 String want = "<video>" + | 28 String want = "<video>" + |
| 29 "<source src=\"http://example.com/foo.ogg\">" + | 29 "<source src=\"http://example.com/foo.ogg\">" + |
| 30 "<track src=\"http://example.com/foo.vtt\"></track>" + | 30 "<track src=\"http://example.com/foo.vtt\">" + |
| 31 "</video>"; | 31 "</video>"; |
| 32 WebVideo webVideo = new WebVideo(video, 400, 300); | 32 WebVideo webVideo = new WebVideo(video, 400, 300); |
| 33 | 33 |
| 34 String got = webVideo.generateOutput(false); | 34 String got = webVideo.generateOutput(false); |
| 35 | 35 |
| 36 // Output should be the same as the input in this case. | 36 // Output should be the same as the input in this case. |
| 37 assertEquals(want, got); | 37 assertEquals(want, got); |
| 38 } | 38 } |
| 39 | 39 |
| 40 public void testGenerateOutputInvalidChildren() { | 40 public void testGenerateOutputInvalidChildren() { |
| 41 Element video = Document.get().createVideoElement(); | 41 Element video = Document.get().createVideoElement(); |
| 42 Element child = Document.get().createElement("source"); | 42 Element child = Document.get().createElement("source"); |
| 43 child.setAttribute("src", "http://example.com/foo.ogg"); | 43 child.setAttribute("src", "http://example.com/foo.ogg"); |
| 44 video.appendChild(child); | 44 video.appendChild(child); |
| 45 | 45 |
| 46 child = Document.get().createElement("track"); | 46 child = Document.get().createElement("track"); |
| 47 child.setAttribute("src", "http://example.com/foo.vtt"); | 47 child.setAttribute("src", "http://example.com/foo.vtt"); |
| 48 video.appendChild(child); | 48 video.appendChild(child); |
| 49 | 49 |
| 50 child = Document.get().createDivElement(); | 50 child = Document.get().createDivElement(); |
| 51 child.setInnerText("We do not use custom error messages!"); | 51 child.setInnerText("We do not use custom error messages!"); |
| 52 video.appendChild(child); | 52 video.appendChild(child); |
| 53 | 53 |
| 54 String want = "<video>" + | 54 String want = "<video>" + |
| 55 "<source src=\"http://example.com/foo.ogg\">" + | 55 "<source src=\"http://example.com/foo.ogg\">" + |
| 56 "<track src=\"http://example.com/foo.vtt\"></track>" + | 56 "<track src=\"http://example.com/foo.vtt\">" + |
| 57 "</video>"; | 57 "</video>"; |
| 58 WebVideo webVideo = new WebVideo(video, 400, 300); | 58 WebVideo webVideo = new WebVideo(video, 400, 300); |
| 59 | 59 |
| 60 String got = webVideo.generateOutput(false); | 60 String got = webVideo.generateOutput(false); |
| 61 | 61 |
| 62 // Output should ignore anything other than "track" and "source" tags. | 62 // Output should ignore anything other than "track" and "source" tags. |
| 63 assertEquals(want, got); | 63 assertEquals(want, got); |
| 64 } | 64 } |
| 65 | 65 |
| 66 public void testPosterEmpty() { | 66 public void testPosterEmpty() { |
| 67 Element video = Document.get().createVideoElement(); | 67 Element video = Document.get().createVideoElement(); |
| 68 | 68 |
| 69 String want = "<video></video>"; | 69 String want = "<video></video>"; |
| 70 WebVideo webVideo = new WebVideo(video, 400, 300); | 70 WebVideo webVideo = new WebVideo(video, 400, 300); |
| 71 | 71 |
| 72 | 72 |
| 73 String got = webVideo.generateOutput(false); | 73 String got = webVideo.generateOutput(false); |
| 74 | 74 |
| 75 assertEquals(want, got); | 75 assertEquals(want, got); |
| 76 } | 76 } |
| 77 | 77 |
| 78 } | 78 } |
| OLD | NEW |