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

Side by Side Diff: chrome/browser/resources/google_now/common_test_util.js

Issue 145353010: Gate console.log output in Google Now (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR Feedback Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // Common test utilities. 5 // Common test utilities.
6 6
7 /**
8 * Allows console.log output.
9 */
10 var showConsoleLogOutput = false;
11
12 /**
13 * Conditionally allow console.log output based off of showConsoleLogOutput.
14 */
15 console.log = function() {
16 var originalConsoleLog = console.log;
17 return function() {
18 if (showConsoleLogOutput) {
19 originalConsoleLog.apply(console, arguments);
20 }
21 };
22 }();
23
7 function emptyMock() {} 24 function emptyMock() {}
8 25
9 // Container for event handlers added by mocked 'addListener' functions. 26 // Container for event handlers added by mocked 'addListener' functions.
10 var mockEventHandlers = {}; 27 var mockEventHandlers = {};
11 28
12 /** 29 /**
13 * Mocks 'addListener' function of an API event. The mocked function will keep 30 * Mocks 'addListener' function of an API event. The mocked function will keep
14 * track of handlers. 31 * track of handlers.
15 * @param {Object} topLevelContainer Top-level container of the original 32 * @param {Object} topLevelContainer Top-level container of the original
16 * function. Can be either 'chrome' or 'instrumented'. 33 * function. Can be either 'chrome' or 'instrumented'.
(...skipping 30 matching lines...) Expand all
47 */ 64 */
48 function getMockHandlerContainer(eventIdentifier) { 65 function getMockHandlerContainer(eventIdentifier) {
49 var eventIdentifierParts = eventIdentifier.split('.'); 66 var eventIdentifierParts = eventIdentifier.split('.');
50 var mockEventContainer = mockEventHandlers; 67 var mockEventContainer = mockEventHandlers;
51 eventIdentifierParts.forEach(function(fragment) { 68 eventIdentifierParts.forEach(function(fragment) {
52 mockEventContainer = mockEventContainer[fragment]; 69 mockEventContainer = mockEventContainer[fragment];
53 }); 70 });
54 71
55 return mockEventContainer; 72 return mockEventContainer;
56 } 73 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/google_now/cards_unittest.gtestjs ('k') | chrome/browser/resources/google_now/utility.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698