| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/extensions/extension_event_router_forwarder.h" | 5 #include "chrome/browser/extensions/extension_event_router_forwarder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/system_monitor/system_monitor.h" | 9 #include "base/system_monitor/system_monitor.h" |
| 10 #include "base/test/thread_test_helper.h" | 10 #include "base/test/thread_test_helper.h" |
| 11 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "chrome/test/base/testing_browser_process.h" | 12 #include "chrome/test/base/testing_browser_process.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 14 #include "chrome/test/base/testing_profile_manager.h" | 14 #include "chrome/test/base/testing_profile_manager.h" |
| 15 #include "content/test/test_browser_thread.h" | 15 #include "content/test/test_browser_thread.h" |
| 16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 using content::BrowserThread; | 20 using content::BrowserThread; |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 const char kEventName[] = "event_name"; | 24 const char kEventName[] = "event_name"; |
| 25 const char kEventArgs[] = "event_args"; | 25 const char kEventArgs[] = "event_args"; |
| 26 const char kExt[] = "extension"; | 26 const char kExt[] = "extension"; |
| 27 | 27 |
| 28 class MockExtensionEventRouterForwarder : public ExtensionEventRouterForwarder { | 28 class MockExtensionEventRouterForwarder : public ExtensionEventRouterForwarder { |
| 29 public: | 29 public: |
| 30 virtual ~MockExtensionEventRouterForwarder() {} | |
| 31 | |
| 32 MOCK_METHOD6(CallExtensionEventRouter, | 30 MOCK_METHOD6(CallExtensionEventRouter, |
| 33 void(Profile*, const std::string&, const std::string&, const std::string&, | 31 void(Profile*, const std::string&, const std::string&, const std::string&, |
| 34 Profile*, const GURL&)); | 32 Profile*, const GURL&)); |
| 33 |
| 34 protected: |
| 35 virtual ~MockExtensionEventRouterForwarder() {} |
| 35 }; | 36 }; |
| 36 | 37 |
| 37 } // namespace | 38 } // namespace |
| 38 | 39 |
| 39 class ExtensionEventRouterForwarderTest : public testing::Test { | 40 class ExtensionEventRouterForwarderTest : public testing::Test { |
| 40 protected: | 41 protected: |
| 41 ExtensionEventRouterForwarderTest() | 42 ExtensionEventRouterForwarderTest() |
| 42 : ui_thread_(BrowserThread::UI, &message_loop_), | 43 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 43 io_thread_(BrowserThread::IO), | 44 io_thread_(BrowserThread::IO), |
| 44 profile_manager_( | 45 profile_manager_( |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 using ::testing::_; | 250 using ::testing::_; |
| 250 GURL url; | 251 GURL url; |
| 251 EXPECT_CALL(*event_router, | 252 EXPECT_CALL(*event_router, |
| 252 CallExtensionEventRouter( | 253 CallExtensionEventRouter( |
| 253 profile1_, kExt, kEventName, kEventArgs, NULL, url)); | 254 profile1_, kExt, kEventName, kEventArgs, NULL, url)); |
| 254 EXPECT_CALL(*event_router, | 255 EXPECT_CALL(*event_router, |
| 255 CallExtensionEventRouter(profile2_, _, _, _, _, _)).Times(0); | 256 CallExtensionEventRouter(profile2_, _, _, _, _, _)).Times(0); |
| 256 event_router->DispatchEventToExtension(kExt, kEventName, kEventArgs, | 257 event_router->DispatchEventToExtension(kExt, kEventName, kEventArgs, |
| 257 profile1_, false, url); | 258 profile1_, false, url); |
| 258 } | 259 } |
| OLD | NEW |