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.
5 // File IO test player is used to test File IO CDM functionality.
6 function FileIOTestPlayer(video
, testConfig
) {
8 this.testConfig
= testConfig
;
11 FileIOTestPlayer
.prototype.init = function() {
13 return PlayerUtils
.initEMEPlayer(this);
16 FileIOTestPlayer
.prototype.registerEventListeners = function() {
18 return PlayerUtils
.registerPrefixedEMEEventListeners(this);
21 handleMessage = function(message
) {
22 // The test result is either '0' or '1' appended to the header.
23 if (Utils
.hasPrefix(message
.message
, FILE_IO_TEST_RESULT_HEADER
)) {
24 if (message
.message
.length
!= FILE_IO_TEST_RESULT_HEADER
.length
+ 1) {
25 Utils
.failTest('Unexpected FileIOTest CDM message' + message
.message
);
28 var result_index
= FILE_IO_TEST_RESULT_HEADER
.length
;
29 var success
= String
.fromCharCode(message
.message
[result_index
]) == 1;
30 Utils
.timeLog('CDM file IO test: ' + (success
? 'Success' : 'Fail'));
32 Utils
.setResultInTitle(FILE_IO_TEST_SUCCESS
);
34 Utils
.failTest('File IO CDM message fail status.');
38 // Check message for prefixed API.
39 FileIOTestPlayer
.prototype.onWebkitKeyMessage
= handleMessage
;
41 // Check message for unprefixed API.
42 FileIOTestPlayer
.prototype.onMessage
= handleMessage
;