OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // File IO test player is used to test File IO CDM functionality. |
| 6 function FileIOTestPlayer(video, testConfig) { |
| 7 this.video = video; |
| 8 this.testConfig = testConfig; |
| 9 } |
| 10 |
| 11 FileIOTestPlayer.prototype.init = function() { |
| 12 // Returns a promise. |
| 13 return PlayerUtils.initEMEPlayer(this); |
| 14 }; |
| 15 |
| 16 FileIOTestPlayer.prototype.registerEventListeners = function() { |
| 17 // Returns a promise. |
| 18 return PlayerUtils.registerEMEEventListeners(this); |
| 19 }; |
| 20 |
| 21 handleMessage = function(message) { |
| 22 // The test result is either '0' or '1' appended to the header. |
| 23 var msg = Utils.convertToUint8Array(message.message); |
| 24 if (Utils.hasPrefix(msg, FILE_IO_TEST_RESULT_HEADER)) { |
| 25 if (msg.length != FILE_IO_TEST_RESULT_HEADER.length + 1) { |
| 26 Utils.failTest('Unexpected FileIOTest CDM message' + msg); |
| 27 return; |
| 28 } |
| 29 var result_index = FILE_IO_TEST_RESULT_HEADER.length; |
| 30 var success = String.fromCharCode(msg[result_index]) == 1; |
| 31 Utils.timeLog('CDM file IO test: ' + (success ? 'Success' : 'Fail')); |
| 32 if (success) |
| 33 Utils.setResultInTitle(FILE_IO_TEST_SUCCESS); |
| 34 else |
| 35 Utils.failTest('File IO CDM message fail status.'); |
| 36 } |
| 37 }; |
| 38 |
| 39 FileIOTestPlayer.prototype.onMessage = handleMessage; |
OLD | NEW |