OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // A test that hosts and excercises the webbrowser control to test | 5 // A test that hosts and excercises the webbrowser control to test |
6 // its event firing behavior. | 6 // its event firing behavior. |
7 #include <guiddef.h> | 7 #include <guiddef.h> |
8 #include <mshtml.h> | 8 #include <mshtml.h> |
9 #include <shlguid.h> | 9 #include <shlguid.h> |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 return S_OK; | 75 return S_OK; |
76 } | 76 } |
77 | 77 |
78 HRESULT CreateFrameEventHandler(IWebBrowser2* browser, | 78 HRESULT CreateFrameEventHandler(IWebBrowser2* browser, |
79 IWebBrowser2* parent_browser, | 79 IWebBrowser2* parent_browser, |
80 IFrameEventHandler** handler) { | 80 IFrameEventHandler** handler) { |
81 return TestingFrameEventHandler::CreateInitializedIID( | 81 return TestingFrameEventHandler::CreateInitializedIID( |
82 browser, parent_browser, this, IID_IFrameEventHandler, handler); | 82 browser, parent_browser, this, IID_IFrameEventHandler, handler); |
83 } | 83 } |
84 | 84 |
| 85 // Overrides original implementation to suppress calls to broker. |
| 86 WebProgressNotifier* CreateWebProgressNotifier() { |
| 87 scoped_ptr<WebProgressNotifier> web_progress_notifier( |
| 88 new TestingWebProgressNotifier()); |
| 89 HRESULT hr = web_progress_notifier->Initialize(this, tab_window_, |
| 90 web_browser_); |
| 91 return SUCCEEDED(hr) ? web_progress_notifier.release() : NULL; |
| 92 } |
| 93 |
85 virtual TabEventsFunnel& tab_events_funnel() { | 94 virtual TabEventsFunnel& tab_events_funnel() { |
86 return mock_tab_events_funnel_; | 95 return mock_tab_events_funnel_; |
87 } | 96 } |
88 | 97 |
89 virtual HRESULT GetBrokerRegistrar(ICeeeBrokerRegistrar** broker) { | 98 virtual HRESULT GetBrokerRegistrar(ICeeeBrokerRegistrar** broker) { |
90 broker_keeper_.CopyTo(broker); | 99 broker_keeper_.CopyTo(broker); |
91 return S_OK; | 100 return S_OK; |
92 } | 101 } |
93 | 102 |
94 virtual HRESULT CreateExecutor(IUnknown** executor) { | 103 virtual HRESULT CreateExecutor(IUnknown** executor) { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 216 |
208 // We should use the executor mock that supports infobar in this test because | 217 // We should use the executor mock that supports infobar in this test because |
209 // OnBeforeNavigate2 queries the executor for infobar interface. | 218 // OnBeforeNavigate2 queries the executor for infobar interface. |
210 testing::MockTabInfobarExecutor* executor_; | 219 testing::MockTabInfobarExecutor* executor_; |
211 CComPtr<ICeeeTabExecutor> executor_keeper_; | 220 CComPtr<ICeeeTabExecutor> executor_keeper_; |
212 | 221 |
213 testing::MockBroker* broker_; | 222 testing::MockBroker* broker_; |
214 CComPtr<ICeeeBrokerRegistrar> broker_keeper_; | 223 CComPtr<ICeeeBrokerRegistrar> broker_keeper_; |
215 | 224 |
216 private: | 225 private: |
| 226 class TestingWebProgressNotifier : public WebProgressNotifier { |
| 227 public: |
| 228 class TesingNavigationEventsFunne : public WebNavigationEventsFunnel { |
| 229 public: |
| 230 HRESULT SendEventToBroker(const char*, const char*) { |
| 231 return S_OK; |
| 232 } |
| 233 }; |
| 234 |
| 235 virtual WebNavigationEventsFunnel* webnavigation_events_funnel() { |
| 236 if (!webnavigation_events_funnel_.get()) |
| 237 webnavigation_events_funnel_.reset(new TesingNavigationEventsFunne()); |
| 238 |
| 239 return webnavigation_events_funnel_.get(); |
| 240 } |
| 241 }; |
| 242 |
217 MockChromeFrameHost* mock_chrome_frame_host_; | 243 MockChromeFrameHost* mock_chrome_frame_host_; |
218 StrictMock<testing::MockTabEventsFunnel> mock_tab_events_funnel_; | 244 StrictMock<testing::MockTabEventsFunnel> mock_tab_events_funnel_; |
219 }; | 245 }; |
220 | 246 |
221 class TestBrowserSite | 247 class TestBrowserSite |
222 : public CComObjectRootEx<CComSingleThreadModel>, | 248 : public CComObjectRootEx<CComSingleThreadModel>, |
223 public InstanceCountMixin<TestBrowserSite>, | 249 public InstanceCountMixin<TestBrowserSite>, |
224 public InitializingCoClass<TestBrowserSite>, | 250 public InitializingCoClass<TestBrowserSite>, |
225 public IServiceProviderImpl<TestBrowserSite> { | 251 public IServiceProviderImpl<TestBrowserSite> { |
226 public: | 252 public: |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 | 548 |
523 // We should still have the same set of frames. | 549 // We should still have the same set of frames. |
524 EXPECT_TRUE(bho_->ExpectHasFrames(orphan_page_resources)); | 550 EXPECT_TRUE(bho_->ExpectHasFrames(orphan_page_resources)); |
525 | 551 |
526 // One handler per resource. | 552 // One handler per resource. |
527 EXPECT_EQ(arraysize(orphan_page_resources), | 553 EXPECT_EQ(arraysize(orphan_page_resources), |
528 TestingFrameEventHandler::instance_count()); | 554 TestingFrameEventHandler::instance_count()); |
529 } | 555 } |
530 | 556 |
531 } // namespace | 557 } // namespace |
OLD | NEW |