Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / file_manager / integration_tests / cast_extension_mock / load.js
blob4045f0f3204f4aae55e8860d5297c555fd03dc6b
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 'use strict';
7 /**
8  * @fileOverview This file loads the MOCK cast APIs for test.
9  */
11 chrome.cast = {};
13 /**
14  * @enum {string}
15  * @const
16  */
17 chrome.cast.ReceiverAvailability = {
18   UNAVAILABLE: 'unavailable',
19   AVAILABLE: 'available',
21 Object.freeze(chrome.cast.ReceiverAvailability);
23 /**
24  * @constructor
25  */
26 chrome.cast.SessionRequest = function() {
29 /**
30  * @constructor
31  * @param {chrome.cast.SessionRequest} sessionRequest
32  * @param {function(chrome.cast.Session)} onSession
33  * @param {function(chrome.cast.ReceiverAvailability)} onReceiver
34  */
35 chrome.cast.ApiConfig = function(sessionRequest, onSession, onReceiver) {
36   this.onReceiver_ = onReceiver;
38   Object.seal(this);
41 /**
42  * @param {chrome.cast.ApiConfig} apiConfig
43  * @param {function()} onInitSuccess
44  * @param {function(chrome.cast.Error)} onError
45  */
46 chrome.cast.initialize = function(apiConfig, onInitSuccess, onError) {
47   this.apiConfig_ = apiConfig;
49   var receiver1 = {friendlyName: 'test cast', label: 'testcast'};
50   var receivers = [receiver1];
51   setTimeout(this.apiConfig_.onReceiver_.bind(
52       null, chrome.cast.ReceiverAvailability.UNAVAILABLE, []));
53   setTimeout(this.apiConfig_.onReceiver_.bind(
54       null, chrome.cast.ReceiverAvailability.AVAILABLE, receivers), 1000);
56   onInitSuccess();
59 /**
60  * Initialized apiConfig value.
61  * @type {chrome.cast.ApiConfig}
62  * @private
63  */
64 chrome.cast.apiConfig_ = null;
66 /**
67  * @const
68  */
69 chrome.cast.isAvailable = true;
71 Object.seal(chrome.cast);
73 // Invokes the handler.
74 if (window['__onGCastApiAvailable'])
75   window['__onGCastApiAvailable'](true, null);