Home | History | Annotate | Download | only in browser_test
      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 /**
      6  * @fileoverview
      7  * Mock implementation of ClientPlugin for testing.
      8  * @suppress {checkTypes}
      9  */
     10 
     11 'use strict';
     12 
     13 /** @suppress {duplicate} */
     14 var remoting = remoting || {};
     15 
     16 /**
     17  * @constructor
     18  * @implements {remoting.ClientPlugin}
     19  */
     20 remoting.MockClientPlugin = function(container) {
     21   this.container_ = container;
     22   this.element_ = document.createElement('div');
     23   this.element_.style.backgroundImage = 'linear-gradient(45deg, blue, red)';
     24   this.width_ = 640;
     25   this.height_ = 480;
     26   this.connectionStatusUpdateHandler_ = null;
     27   this.desktopSizeUpdateHandler_ = null;
     28   this.container_.appendChild(this.element_);
     29 };
     30 
     31 remoting.MockClientPlugin.prototype.dispose = function() {
     32   this.container_.removeChild(this.element_);
     33   this.element_ = null;
     34   this.connectionStatusUpdateHandler_ = null;
     35 };
     36 
     37 remoting.MockClientPlugin.prototype.getDesktopWidth = function() {
     38   return this.width_;
     39 };
     40 
     41 remoting.MockClientPlugin.prototype.getDesktopHeight = function() {
     42   return this.height_;
     43 };
     44 
     45 remoting.MockClientPlugin.prototype.getDesktopXDpi = function() {
     46   return 96;
     47 };
     48 
     49 remoting.MockClientPlugin.prototype.getDesktopYDpi = function() {
     50   return 96;
     51 };
     52 
     53 remoting.MockClientPlugin.prototype.element = function() {
     54   return this.element_;
     55 };
     56 
     57 remoting.MockClientPlugin.prototype.initialize = function(onDone) {
     58   window.setTimeout(onDone.bind(null, true), 0);
     59 };
     60 
     61 remoting.MockClientPlugin.prototype.connect = function(
     62     hostJid, hostPublicKey, localJid, sharedSecret,
     63     authenticationMethods, authenticationTag,
     64     clientPairingId, clientPairedSecret) {
     65   base.debug.assert(this.connectionStatusUpdateHandler_ != null);
     66   window.setTimeout(
     67       this.connectionStatusUpdateHandler_.bind(
     68           this,
     69           remoting.ClientSession.State.CONNECTED,
     70           remoting.ClientSession.ConnectionError.NONE),
     71       0);
     72 };
     73 
     74 remoting.MockClientPlugin.prototype.injectKeyEvent =
     75     function(key, down) {};
     76 
     77 remoting.MockClientPlugin.prototype.remapKey = function(from, to) {};
     78 
     79 remoting.MockClientPlugin.prototype.releaseAllKeys = function() {};
     80 
     81 remoting.MockClientPlugin.prototype.notifyClientResolution =
     82     function(width, height, dpi) {
     83   this.width_ = width;
     84   this.height_ = height;
     85   if (this.desktopSizeUpdateHandler_) {
     86     window.setTimeout(this.desktopSizeUpdateHandler_, 0);
     87   }
     88 };
     89 
     90 remoting.MockClientPlugin.prototype.onIncomingIq = function(iq) {};
     91 
     92 remoting.MockClientPlugin.prototype.isSupportedVersion = function() {
     93   return true;
     94 };
     95 
     96 remoting.MockClientPlugin.prototype.hasFeature = function(feature) {
     97   return false;
     98 };
     99 
    100 remoting.MockClientPlugin.prototype.enableMediaSourceRendering =
    101     function(mediaSourceRenderer) {};
    102 
    103 remoting.MockClientPlugin.prototype.sendClipboardItem =
    104     function(mimeType, item) {};
    105 
    106 remoting.MockClientPlugin.prototype.useAsyncPinDialog = function() {};
    107 
    108 remoting.MockClientPlugin.prototype.requestPairing =
    109     function(clientName, onDone) {};
    110 
    111 remoting.MockClientPlugin.prototype.onPinFetched = function(pin) {};
    112 
    113 remoting.MockClientPlugin.prototype.onThirdPartyTokenFetched =
    114     function(token, sharedSecret) {};
    115 
    116 remoting.MockClientPlugin.prototype.pauseAudio = function(pause) {};
    117 
    118 remoting.MockClientPlugin.prototype.pauseVideo = function(pause) {};
    119 
    120 remoting.MockClientPlugin.prototype.getPerfStats = function() {
    121   var result = new remoting.ClientSession.PerfStats;
    122   result.videoBandwidth = 999;
    123   result.videoFrameRate = 60;
    124   result.captureLatency = 10;
    125   result.encodeLatency = 10;
    126   result.decodeLatency = 10;
    127   result.renderLatency = 10;
    128   result.roundtripLatency = 10;
    129   return result;
    130 };
    131 
    132 remoting.MockClientPlugin.prototype.sendClientMessage =
    133     function(name, data) {};
    134 
    135 remoting.MockClientPlugin.prototype.setOnOutgoingIqHandler =
    136     function(handler) {};
    137 
    138 remoting.MockClientPlugin.prototype.setOnDebugMessageHandler =
    139     function(handler) {};
    140 
    141 remoting.MockClientPlugin.prototype.setConnectionStatusUpdateHandler =
    142     function(handler) {
    143   this.connectionStatusUpdateHandler_ = handler;
    144 };
    145 
    146 remoting.MockClientPlugin.prototype.setConnectionReadyHandler =
    147     function(handler) {};
    148 
    149 remoting.MockClientPlugin.prototype.setDesktopSizeUpdateHandler =
    150     function(handler) {
    151   this.desktopSizeUpdateHandler_ = handler;
    152 };
    153 
    154 remoting.MockClientPlugin.prototype.setCapabilitiesHandler =
    155     function(handler) {};
    156 
    157 remoting.MockClientPlugin.prototype.setGnubbyAuthHandler =
    158     function(handler) {};
    159 
    160 remoting.MockClientPlugin.prototype.setCastExtensionHandler =
    161     function(handler) {};
    162 
    163 remoting.MockClientPlugin.prototype.setMouseCursorHandler =
    164     function(handler) {};
    165 
    166 remoting.MockClientPlugin.prototype.setFetchThirdPartyTokenHandler =
    167     function(handler) {};
    168 
    169 remoting.MockClientPlugin.prototype.setFetchPinHandler =
    170     function(handler) {};
    171 
    172 
    173 /**
    174  * @constructor
    175  * @extends {remoting.ClientPluginFactory}
    176  */
    177 remoting.MockClientPluginFactory = function() {};
    178 
    179 remoting.MockClientPluginFactory.prototype.createPlugin =
    180     function(container, onExtensionMessage) {
    181   return new remoting.MockClientPlugin(container);
    182 };
    183 
    184 remoting.MockClientPluginFactory.prototype.preloadPlugin = function() {};
    185