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

Unified Diff: remoting/webapp/unittests/chrome_mocks.js

Issue 468693002: Hangouts remote desktop part III - It2MeService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/unittests/chrome_mocks.js
diff --git a/remoting/webapp/unittests/chrome_mocks.js b/remoting/webapp/unittests/chrome_mocks.js
new file mode 100644
index 0000000000000000000000000000000000000000..e10f081fbecf682a2900f855a4d7f4bd61547934
--- /dev/null
+++ b/remoting/webapp/unittests/chrome_mocks.js
@@ -0,0 +1,50 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file contains various mock objects for the chrome platform to make
+// unit testing easier.
+
+(function(scope){
+
+var chromeMocks = {};
+
+chromeMocks.Event = function() {
+ this.listeners_ = [];
+};
+
+chromeMocks.Event.prototype.addListener = function(callback) {
+ this.listeners_.push(callback);
+};
+
+chromeMocks.Event.prototype.removeListener = function(callback) {
+ for (var i = 0; i < this.listeners_.length; i++) {
+ if (this.listeners_[i] === callback) {
+ this.listeners_.splice(i, 1);
+ break;
+ }
+ }
+};
+
+chromeMocks.Event.prototype.mock$fire = function(data) {
+ this.listeners_.forEach(function(listener){
+ listener(data);
+ });
+};
+
+chromeMocks.runtime = {};
+
+chromeMocks.runtime.Port = function() {
+ this.onMessage = new chromeMocks.Event();
+ this.onDisconnect = new chromeMocks.Event();
+
+ this.name = '';
+ this.sender = null;
+};
+
+chromeMocks.runtime.Port.prototype.disconnect = function() {};
+chromeMocks.runtime.Port.prototype.postMessage = function() {};
+
+scope.chromeMocks = chromeMocks;
+
+})(window);

Powered by Google App Engine
This is Rietveld 408576698