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.
8 * @fileOverview This file loads the MOCK cast APIs for test.
17 chrome.cast.ReceiverAvailability = {
18 UNAVAILABLE: 'unavailable',
19 AVAILABLE: 'available',
21 Object.freeze(chrome.cast.ReceiverAvailability);
26 chrome.cast.SessionRequest = function() {
31 * @param {chrome.cast.SessionRequest} sessionRequest
32 * @param {function(chrome.cast.Session)} onSession
33 * @param {function(chrome.cast.ReceiverAvailability)} onReceiver
35 chrome.cast.ApiConfig = function(sessionRequest, onSession, onReceiver) {
36 this.onReceiver_ = onReceiver;
42 * @param {chrome.cast.ApiConfig} apiConfig
43 * @param {function()} onInitSuccess
44 * @param {function(chrome.cast.Error)} onError
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);
60 * Initialized apiConfig value.
61 * @type {chrome.cast.ApiConfig}
64 chrome.cast.apiConfig_ = null;
69 chrome.cast.isAvailable = true;
71 Object.seal(chrome.cast);
73 // Invokes the handler.
74 if (window['__onGCastApiAvailable'])
75 window['__onGCastApiAvailable'](true, null);