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

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

Issue 984203003: Move mocks and unittest JS files to sit alongside production code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 9 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/event_hook_unittest.js
diff --git a/remoting/webapp/unittests/event_hook_unittest.js b/remoting/webapp/unittests/event_hook_unittest.js
deleted file mode 100644
index 15135bdee045f0577ade2fc9ae6805f352d38537..0000000000000000000000000000000000000000
--- a/remoting/webapp/unittests/event_hook_unittest.js
+++ /dev/null
@@ -1,89 +0,0 @@
-// 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.
-
-/**
- * @fileoverview
- * TODO(garykac) Remove suppression once chromeMocks has been replaced.
- * @suppress {checkTypes|checkVars|reportUnknownTypes}
- */
-
-(function() {
-
-'use strict';
-
-/** @type {base.EventSourceImpl} */
-var eventSource = null;
-
-/** @type {HTMLElement} */
-var domElement = null;
-
-/** @type {chromeMocks.Event} */
-var myChromeEvent = null;
-
-/** @type {Listener} */
-var listener = null;
-
-/**
- * @param {HTMLElement} element
- * @constructor
- */
-var Listener = function(element) {
- /** @type {(sinon.Spy|function(...?))} */
- this.onChromeEvent = sinon.spy();
- /** @type {(sinon.Spy|function(...?))} */
- this.onClickEvent = sinon.spy();
- /** @type {(sinon.Spy|function(...?))} */
- this.onCustomEvent = sinon.spy();
-
- this.eventHooks_ = new base.Disposables(
- new base.DomEventHook(element, 'click', this.onClickEvent.bind(this),
- false),
- new base.EventHook(eventSource, 'customEvent',
- this.onCustomEvent.bind(this)),
- new base.ChromeEventHook(myChromeEvent, this.onChromeEvent.bind(this)));
-};
-
-Listener.prototype.dispose = function() {
- this.eventHooks_.dispose();
-};
-
-function raiseAllEvents() {
- domElement.click();
- myChromeEvent.mock$fire();
- eventSource.raiseEvent('customEvent');
-}
-
-module('base.EventHook', {
- setup: function() {
- domElement = /** @type {HTMLElement} */ (document.createElement('div'));
- eventSource = new base.EventSourceImpl();
- eventSource.defineEvents(['customEvent']);
- myChromeEvent = new chromeMocks.Event();
- listener = new Listener(domElement);
- },
- tearDown: function() {
- domElement = null;
- eventSource = null;
- myChromeEvent = null;
- listener = null;
- }
-});
-
-test('EventHook should hook events when constructed', function() {
- raiseAllEvents();
- sinon.assert.calledOnce(listener.onClickEvent);
- sinon.assert.calledOnce(listener.onChromeEvent);
- sinon.assert.calledOnce(listener.onCustomEvent);
- listener.dispose();
-});
-
-test('EventHook should unhook events when disposed', function() {
- listener.dispose();
- raiseAllEvents();
- sinon.assert.notCalled(listener.onClickEvent);
- sinon.assert.notCalled(listener.onChromeEvent);
- sinon.assert.notCalled(listener.onCustomEvent);
-});
-
-})();

Powered by Google App Engine
This is Rietveld 408576698