| OLD | NEW |
| (Empty) | |
| 1 <!doctype html> |
| 2 <!-- Copyright (c) 2014 Google Inc. All rights reserved. --> |
| 3 <html> |
| 4 <head> |
| 5 <meta name="viewport" content="width=device-width, minimum-scale=1.0, initia
l-scale=1.0, user-scalable=yes"> |
| 6 <title>google-youtube Basic Tests</title> |
| 7 <script src="../../platform/platform.js"></script> |
| 8 <link rel="import" href="../../polymer-test-tools/tools.html"> |
| 9 <script src="../../polymer-test-tools/htmltest.js"></script> |
| 10 <link rel="import" href="../google-youtube.html"> |
| 11 </head> |
| 12 <body> |
| 13 <google-youtube></google-youtube> |
| 14 |
| 15 <script> |
| 16 function testToHHMMSS(googleYouTube) { |
| 17 // Durations in seconds and the formatted string that's expected for eac
h. |
| 18 var durationsToFormattedStrings = { |
| 19 0: '0:00', |
| 20 1: '0:01', |
| 21 '5.4': '0:05', |
| 22 '5.5': '0:06', |
| 23 10: '0:10', |
| 24 60: '1:00', |
| 25 601: '10:01', |
| 26 3600: '1:00:00', |
| 27 3661: '1:01:01', |
| 28 36000: '10:00:00' |
| 29 }; |
| 30 |
| 31 Object.keys(durationsToFormattedStrings).forEach(function(seconds) { |
| 32 assert.equal(durationsToFormattedStrings[seconds], googleYouTube.toHHM
MSS(seconds)); |
| 33 }); |
| 34 } |
| 35 |
| 36 function testPlayMethodAndStateTransitions(googleYouTube) { |
| 37 // Expected state transitions: -1 (unstarted) -> 3 (buffering) -> 1 (pla
ying) |
| 38 var stateTransitions = [-1, 3, 1]; |
| 39 |
| 40 googleYouTube.addEventListener('google-youtube-state-change', function(e
) { |
| 41 // Test that the element's state property always is set to the same pr
operty in the event. |
| 42 assert.equal(e.detail.data, googleYouTube.state); |
| 43 |
| 44 // Test that the player goes through the expected sequence of state tr
ansitions. |
| 45 assert.equal(e.detail.data, stateTransitions.shift()); |
| 46 |
| 47 // Once the array of expected state transitions have been exhausted, e
nd the test. |
| 48 if (stateTransitions.length == 0) { |
| 49 done(); |
| 50 } |
| 51 }); |
| 52 |
| 53 // Kick off playback. |
| 54 googleYouTube.play(); |
| 55 } |
| 56 |
| 57 document.addEventListener('polymer-ready', function() { |
| 58 var googleYouTube = document.querySelector('google-youtube'); |
| 59 |
| 60 testToHHMMSS(googleYouTube); |
| 61 |
| 62 // Playback can't be initiated until after the google-youtube-ready even
t is fired. |
| 63 googleYouTube.addEventListener('google-youtube-ready', function() { |
| 64 testPlayMethodAndStateTransitions(googleYouTube); |
| 65 }); |
| 66 }); |
| 67 </script> |
| 68 </body> |
| 69 </html> |
| OLD | NEW |