Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/file_manager_browsertest/cast_extension_mock/load.js |
| diff --git a/chrome/test/data/extensions/api_test/file_manager_browsertest/cast_extension_mock/load.js b/chrome/test/data/extensions/api_test/file_manager_browsertest/cast_extension_mock/load.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0890d1933c186040be5298635bfd2c48bb8535dd |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/file_manager_browsertest/cast_extension_mock/load.js |
| @@ -0,0 +1,58 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +'use strict'; |
| + |
| +chrome.cast = {}; |
| + |
| +/** |
| + * @const |
|
hirono
2014/08/26 00:56:57
nit: @enum {string}
yoshiki
2014/08/26 05:31:24
Done.
|
| + */ |
| +chrome.cast.ReceiverAvailability = { |
|
hirono
2014/08/26 00:56:57
Please freeze it.
yoshiki
2014/08/26 05:31:24
Done.
|
| + UNAVAILABLE: 'unavailable', |
| + AVAILABLE: 'available', |
| +}; |
| + |
| +/** |
| + * @constructor |
| + */ |
| +chrome.cast.SessionRequest = function() { |
| +}; |
| + |
| +/** |
| + * @constructor |
| + */ |
| +chrome.cast.ApiConfig = function(sessionRequest, onSession, onReceiver) { |
| + this.onReceiver = onReceiver; |
| + |
| + Object.seal(this); |
| +}; |
| + |
| +/** |
| + * @param {chrome.cast.ApiConfig} apiConfig |
| + * @param {function} onInitSuccess |
|
hirono
2014/08/26 00:56:57
Could you add arguments and return types to the an
yoshiki
2014/08/26 05:31:24
Done.
|
| + * @param {function} onError |
| + */ |
| +chrome.cast.initialize = function(apiConfig, onInitSuccess, onError) { |
| + this.apiConfig = apiConfig; |
| + |
| + var receiver1 = {friendlyName: 'test cast', label: 'testcast'}; |
| + var receivers = [receiver1]; |
| + setTimeout(this.apiConfig.onReceiver.bind( |
| + null, chrome.cast.ReceiverAvailability.UNAVAILABLE, [])); |
| + setTimeout(this.apiConfig.onReceiver.bind( |
| + null, chrome.cast.ReceiverAvailability.AVAILABLE, receivers), 1000); |
| + |
| + onInitSuccess(); |
| +}; |
| + |
| +/** |
| + * @const |
| + */ |
| +chrome.cast.isAvailable = true; |
| + |
| +// Invokes the handler. |
| +if (window['__onGCastApiAvailable']) { |
| + window['__onGCastApiAvailable'](true, null); |
| +} |