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/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/system_monitor/system_monitor.h" | |
9 #include "chrome/browser/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
10 #include "chrome/test/testing_browser_process_test.h" | 9 #include "chrome/test/testing_browser_process_test.h" |
11 #include "chrome/test/testing_profile.h" | 10 #include "chrome/test/testing_profile.h" |
12 #include "chrome/test/thread_test_helper.h" | 11 #include "chrome/test/thread_test_helper.h" |
13 #include "content/browser/browser_thread.h" | 12 #include "content/browser/browser_thread.h" |
14 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "ui/base/system_monitor/system_monitor.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 const char kEventName[] = "event_name"; | 20 const char kEventName[] = "event_name"; |
21 const char kEventArgs[] = "event_args"; | 21 const char kEventArgs[] = "event_args"; |
22 const char kExt[] = "extension"; | 22 const char kExt[] = "extension"; |
23 | 23 |
24 class MockExtensionEventRouterForwarder : public ExtensionEventRouterForwarder { | 24 class MockExtensionEventRouterForwarder : public ExtensionEventRouterForwarder { |
25 public: | 25 public: |
26 virtual ~MockExtensionEventRouterForwarder() {} | 26 virtual ~MockExtensionEventRouterForwarder() {} |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 TestingProfile* CreateIncognitoProfile(TestingProfile* base) { | 59 TestingProfile* CreateIncognitoProfile(TestingProfile* base) { |
60 TestingProfile* incognito = new TestingProfile(); | 60 TestingProfile* incognito = new TestingProfile(); |
61 incognito->set_incognito(true); | 61 incognito->set_incognito(true); |
62 base->SetOffTheRecordProfile(incognito); | 62 base->SetOffTheRecordProfile(incognito); |
63 return incognito; | 63 return incognito; |
64 } | 64 } |
65 | 65 |
66 MessageLoopForUI message_loop_; | 66 MessageLoopForUI message_loop_; |
67 BrowserThread ui_thread_; | 67 BrowserThread ui_thread_; |
68 BrowserThread io_thread_; | 68 BrowserThread io_thread_; |
69 base::SystemMonitor dummy; | 69 ui::SystemMonitor dummy; |
70 // Profiles are weak pointers, owned by ProfileManager in |browser_process_|. | 70 // Profiles are weak pointers, owned by ProfileManager in |browser_process_|. |
71 TestingProfile* profile1_; | 71 TestingProfile* profile1_; |
72 TestingProfile* profile2_; | 72 TestingProfile* profile2_; |
73 }; | 73 }; |
74 | 74 |
75 TEST_F(ExtensionEventRouterForwarderTest, BroadcastRendererUI) { | 75 TEST_F(ExtensionEventRouterForwarderTest, BroadcastRendererUI) { |
76 scoped_refptr<MockExtensionEventRouterForwarder> event_router( | 76 scoped_refptr<MockExtensionEventRouterForwarder> event_router( |
77 new MockExtensionEventRouterForwarder); | 77 new MockExtensionEventRouterForwarder); |
78 GURL url; | 78 GURL url; |
79 EXPECT_CALL(*event_router, | 79 EXPECT_CALL(*event_router, |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 GURL url; | 251 GURL url; |
252 EXPECT_CALL(*event_router, | 252 EXPECT_CALL(*event_router, |
253 CallExtensionEventRouter( | 253 CallExtensionEventRouter( |
254 profile1_, kExt, kEventName, kEventArgs, NULL, url)); | 254 profile1_, kExt, kEventName, kEventArgs, NULL, url)); |
255 EXPECT_CALL(*event_router, | 255 EXPECT_CALL(*event_router, |
256 CallExtensionEventRouter(profile2_, _, _, _, _, _)).Times(0); | 256 CallExtensionEventRouter(profile2_, _, _, _, _, _)).Times(0); |
257 event_router->DispatchEventToExtension(kExt, kEventName, kEventArgs, | 257 event_router->DispatchEventToExtension(kExt, kEventName, kEventArgs, |
258 profile1_->GetRuntimeId(), | 258 profile1_->GetRuntimeId(), |
259 false, url); | 259 false, url); |
260 } | 260 } |
OLD | NEW |