| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/test/base/module_system_test.h" | 5 #include "chrome/test/base/module_system_test.h" |
| 6 | 6 |
| 7 #include "grit/renderer_resources.h" | 7 #include "grit/renderer_resources.h" |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 | 10 |
| 11 class EventUnittest : public ModuleSystemTest { | 11 class EventUnittest : public ModuleSystemTest { |
| 12 virtual void SetUp() OVERRIDE { | 12 virtual void SetUp() OVERRIDE { |
| 13 ModuleSystemTest::SetUp(); | 13 ModuleSystemTest::SetUp(); |
| 14 module_system_->RunString("chrome = {};", "setup-chrome"); | 14 module_system_->RunString("chrome = {};", "setup-chrome"); |
| 15 | 15 |
| 16 RegisterModule("event", IDR_EVENT_BINDINGS_JS); | 16 RegisterModule("event", IDR_EVENT_BINDINGS_JS); |
| 17 RegisterModule("schemaUtils", IDR_SCHEMA_UTILS_JS); |
| 17 RegisterModule("utils", IDR_UTILS_JS); | 18 RegisterModule("utils", IDR_UTILS_JS); |
| 18 | 19 |
| 19 // Mock out the native handler for event_bindings. These mocks will fail if | 20 // Mock out the native handler for event_bindings. These mocks will fail if |
| 20 // any invariants maintained by the real event_bindings are broken. | 21 // any invariants maintained by the real event_bindings are broken. |
| 21 OverrideNativeHandler("event_bindings", | 22 OverrideNativeHandler("event_bindings", |
| 22 "var assert = requireNative('assert');" | 23 "var assert = requireNative('assert');" |
| 23 "var attachedListeners = exports.attachedListeners = {};" | 24 "var attachedListeners = exports.attachedListeners = {};" |
| 24 "exports.AttachEvent = function(eventName) {" | 25 "exports.AttachEvent = function(eventName) {" |
| 25 " assert.AssertFalse(!!attachedListeners[eventName]);" | 26 " assert.AssertFalse(!!attachedListeners[eventName]);" |
| 26 " attachedListeners[eventName] = 1;" | 27 " attachedListeners[eventName] = 1;" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 "var assert = requireNative('assert');" | 86 "var assert = requireNative('assert');" |
| 86 "var e = new event.Event('myevent');" | 87 "var e = new event.Event('myevent');" |
| 87 "var called = false;" | 88 "var called = false;" |
| 88 "e.addListener(function() { called = true; });" | 89 "e.addListener(function() { called = true; });" |
| 89 "chromeHidden.Event.dispatch('myevent', []);" | 90 "chromeHidden.Event.dispatch('myevent', []);" |
| 90 "assert.AssertTrue(called);"); | 91 "assert.AssertTrue(called);"); |
| 91 module_system_->Require("test"); | 92 module_system_->Require("test"); |
| 92 } | 93 } |
| 93 | 94 |
| 94 } // namespace | 95 } // namespace |
| OLD | NEW |