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

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: Rebase. 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
252 chromeMocks.MetricsPrivate.prototype.recordValue = function() {};
253
254 /** @type {chromeMocks.MetricsPrivate} */
255 chromeMocks.metricsPrivate;
249 256
250 /** @constructor */ 257 /** @constructor */
251 chromeMocks.I18n = function() {}; 258 chromeMocks.I18n = function() {};
252 259
253 /** 260 /**
254 * @param {string} messageName 261 * @param {string} messageName
255 * @param {(string|Array<string>)=} opt_args 262 * @param {(string|Array<string>)=} opt_args
256 * @return {string} 263 * @return {string}
257 */ 264 */
258 chromeMocks.I18n.prototype.getMessage = function(messageName, opt_args) {}; 265 chromeMocks.I18n.prototype.getMessage = function(messageName, opt_args) {};
(...skipping 22 matching lines...) Expand all
281 */ 288 */
282 chromeMocks.activate = function() { 289 chromeMocks.activate = function() {
283 if (originals_) { 290 if (originals_) {
284 throw new Error('chromeMocks.activate() can only be called once.'); 291 throw new Error('chromeMocks.activate() can only be called once.');
285 } 292 }
286 originals_ = {}; 293 originals_ = {};
287 nativePorts = {}; 294 nativePorts = {};
288 295
289 chromeMocks.i18n = new chromeMocks.I18n(); 296 chromeMocks.i18n = new chromeMocks.I18n();
290 chromeMocks.identity = new chromeMocks.Identity(); 297 chromeMocks.identity = new chromeMocks.Identity();
298 chromeMocks.metricsPrivate = new chromeMocks.MetricsPrivate();
291 299
292 ['identity', 'i18n', 'runtime', 'storage'].forEach( 300 ['identity', 'i18n', 'runtime', 'storage', 'metricsPrivate'].forEach(
293 function(/** string */ component) { 301 function(/** string */ component) {
294 if (!chromeMocks[component]) { 302 if (!chromeMocks[component]) {
295 throw new Error('No mocks defined for chrome.' + component); 303 throw new Error('No mocks defined for chrome.' + component);
296 } 304 }
297 originals_[component] = chrome[component]; 305 originals_[component] = chrome[component];
298 chrome[component] = chromeMocks[component]; 306 chrome[component] = chromeMocks[component];
299 }); 307 });
300 308
301 chrome.app['window'] = new chromeMocks.WindowManager(); 309 chrome.app['window'] = new chromeMocks.WindowManager();
302 }; 310 };
303 311
304 chromeMocks.restore = function() { 312 chromeMocks.restore = function() {
305 if (!originals_) { 313 if (!originals_) {
306 throw new Error('You must call activate() before restore().'); 314 throw new Error('You must call activate() before restore().');
307 } 315 }
308 for (var components in originals_) { 316 for (var components in originals_) {
309 chrome[components] = originals_[components]; 317 chrome[components] = originals_[components];
310 } 318 }
311 originals_ = null; 319 originals_ = null;
312 nativePorts = null; 320 nativePorts = null;
313 }; 321 };
314 322
315 })(); 323 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698