Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: remoting/webapp/js_proto/chrome_mocks.js

Issue 1305453002: Add UMA stats for Chromoting connection details. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Include all SessionState enums in UMA enumerated-histogram. Cleanup plugin code. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file contains various mock objects for the chrome platform to make 5 // This file contains various mock objects for the chrome platform to make
6 // unit testing easier. 6 // unit testing easier.
7 7
8 var chromeMocks = {}; 8 var chromeMocks = {};
9 9
10 (function(){ 10 (function(){
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 this.token_ = token; 239 this.token_ = token;
240 }; 240 };
241 241
242 chromeMocks.Identity.prototype.mock$clearToken = function() { 242 chromeMocks.Identity.prototype.mock$clearToken = function() {
243 this.token_ = undefined; 243 this.token_ = undefined;
244 }; 244 };
245 245
246 /** @type {chromeMocks.Identity} */ 246 /** @type {chromeMocks.Identity} */
247 chromeMocks.identity; 247 chromeMocks.identity;
248 248
249 /** @constructor */
250 chromeMocks.MetricsPrivate = function() {
251 };
kelvinp 2015/08/21 21:32:09 Nit: put }; on the same line with { Same below
anandc 2015/08/21 21:56:10 Done.
252
253 chromeMocks.MetricsPrivate.prototype.recordValue = function() {
254 };
255
256 /** @type {chromeMocks.MetricsPrivate} */
257 chromeMocks.metricsPrivate;
249 258
250 /** @constructor */ 259 /** @constructor */
251 chromeMocks.I18n = function() {}; 260 chromeMocks.I18n = function() {};
252 261
253 /** 262 /**
254 * @param {string} messageName 263 * @param {string} messageName
255 * @param {(string|Array<string>)=} opt_args 264 * @param {(string|Array<string>)=} opt_args
256 * @return {string} 265 * @return {string}
257 */ 266 */
258 chromeMocks.I18n.prototype.getMessage = function(messageName, opt_args) {}; 267 chromeMocks.I18n.prototype.getMessage = function(messageName, opt_args) {};
(...skipping 22 matching lines...) Expand all
281 */ 290 */
282 chromeMocks.activate = function() { 291 chromeMocks.activate = function() {
283 if (originals_) { 292 if (originals_) {
284 throw new Error('chromeMocks.activate() can only be called once.'); 293 throw new Error('chromeMocks.activate() can only be called once.');
285 } 294 }
286 originals_ = {}; 295 originals_ = {};
287 nativePorts = {}; 296 nativePorts = {};
288 297
289 chromeMocks.i18n = new chromeMocks.I18n(); 298 chromeMocks.i18n = new chromeMocks.I18n();
290 chromeMocks.identity = new chromeMocks.Identity(); 299 chromeMocks.identity = new chromeMocks.Identity();
300 chromeMocks.metricsPrivate = new chromeMocks.MetricsPrivate();
291 301
292 ['identity', 'i18n', 'runtime', 'storage'].forEach( 302 ['identity', 'i18n', 'runtime', 'storage', 'metricsPrivate'].forEach(
293 function(/** string */ component) { 303 function(/** string */ component) {
294 if (!chromeMocks[component]) { 304 if (!chromeMocks[component]) {
295 throw new Error('No mocks defined for chrome.' + component); 305 throw new Error('No mocks defined for chrome.' + component);
296 } 306 }
297 originals_[component] = chrome[component]; 307 originals_[component] = chrome[component];
298 chrome[component] = chromeMocks[component]; 308 chrome[component] = chromeMocks[component];
299 }); 309 });
300 310
301 chrome.app['window'] = new chromeMocks.WindowManager(); 311 chrome.app['window'] = new chromeMocks.WindowManager();
302 }; 312 };
303 313
304 chromeMocks.restore = function() { 314 chromeMocks.restore = function() {
305 if (!originals_) { 315 if (!originals_) {
306 throw new Error('You must call activate() before restore().'); 316 throw new Error('You must call activate() before restore().');
307 } 317 }
308 for (var components in originals_) { 318 for (var components in originals_) {
309 chrome[components] = originals_[components]; 319 chrome[components] = originals_[components];
310 } 320 }
311 originals_ = null; 321 originals_ = null;
312 nativePorts = null; 322 nativePorts = null;
313 }; 323 };
314 324
315 })(); 325 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698