| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/renderer_host/test_render_view_host.h" | 5 #include "chrome/browser/renderer_host/test_render_view_host.h" |
| 6 | 6 |
| 7 #include "chrome/browser/renderer_host/backing_store.h" | 7 #include "chrome/browser/renderer_host/backing_store.h" |
| 8 #include "chrome/browser/tab_contents/test_web_contents.h" | 8 #include "chrome/browser/tab_contents/test_web_contents.h" |
| 9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
| 10 | 10 |
| 11 TestRenderViewHost::TestRenderViewHost(SiteInstance* instance, | 11 TestRenderViewHost::TestRenderViewHost(SiteInstance* instance, |
| 12 RenderViewHostDelegate* delegate, | 12 RenderViewHostDelegate* delegate, |
| 13 int routing_id, | 13 int routing_id, |
| 14 base::WaitableEvent* modal_dialog_event) | 14 base::WaitableEvent* modal_dialog_event) |
| 15 : RenderViewHost(instance, delegate, routing_id, modal_dialog_event), | 15 : RenderViewHost(instance, delegate, routing_id, modal_dialog_event), |
| 16 render_view_created_(false), | 16 render_view_created_(false), |
| 17 delete_counter_(NULL) { | 17 delete_counter_(NULL) { |
| 18 set_view(new TestRenderWidgetHostView()); | 18 set_view(new TestRenderWidgetHostView(this)); |
| 19 } | 19 } |
| 20 | 20 |
| 21 TestRenderViewHost::~TestRenderViewHost() { | 21 TestRenderViewHost::~TestRenderViewHost() { |
| 22 if (delete_counter_) | 22 if (delete_counter_) |
| 23 ++*delete_counter_; | 23 ++*delete_counter_; |
| 24 | 24 |
| 25 // Since this isn't a traditional view, we have to delete it. | 25 // Since this isn't a traditional view, we have to delete it. |
| 26 delete view(); | 26 delete view(); |
| 27 } | 27 } |
| 28 | 28 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 57 params.gesture = NavigationGestureUser; | 57 params.gesture = NavigationGestureUser; |
| 58 params.contents_mime_type = std::string(); | 58 params.contents_mime_type = std::string(); |
| 59 params.is_post = false; | 59 params.is_post = false; |
| 60 params.is_content_filtered = false; | 60 params.is_content_filtered = false; |
| 61 params.http_status_code = 0; | 61 params.http_status_code = 0; |
| 62 | 62 |
| 63 ViewHostMsg_FrameNavigate msg(1, params); | 63 ViewHostMsg_FrameNavigate msg(1, params); |
| 64 OnMsgNavigate(msg); | 64 OnMsgNavigate(msg); |
| 65 } | 65 } |
| 66 | 66 |
| 67 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh) |
| 68 : rwh_(rwh), |
| 69 is_showing_(false) { |
| 70 } |
| 71 |
| 67 BackingStore* TestRenderWidgetHostView::AllocBackingStore( | 72 BackingStore* TestRenderWidgetHostView::AllocBackingStore( |
| 68 const gfx::Size& size) { | 73 const gfx::Size& size) { |
| 69 return new BackingStore(size); | 74 return new BackingStore(rwh_, size); |
| 70 } | 75 } |
| 71 | 76 |
| 72 void RenderViewHostTestHarness::NavigateAndCommit(const GURL& url) { | 77 void RenderViewHostTestHarness::NavigateAndCommit(const GURL& url) { |
| 73 controller().LoadURL(url, GURL(), 0); | 78 controller().LoadURL(url, GURL(), 0); |
| 74 rvh()->SendNavigate(process()->max_page_id() + 1, url); | 79 rvh()->SendNavigate(process()->max_page_id() + 1, url); |
| 75 } | 80 } |
| 76 | 81 |
| 77 void RenderViewHostTestHarness::SetUp() { | 82 void RenderViewHostTestHarness::SetUp() { |
| 78 // See comment above profile_ decl for why we check for NULL here. | 83 // See comment above profile_ decl for why we check for NULL here. |
| 79 if (!profile_.get()) | 84 if (!profile_.get()) |
| 80 profile_.reset(new TestingProfile()); | 85 profile_.reset(new TestingProfile()); |
| 81 | 86 |
| 82 // This will be deleted when the TabContents goes away. | 87 // This will be deleted when the TabContents goes away. |
| 83 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); | 88 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); |
| 84 | 89 |
| 85 contents_.reset(new TestTabContents(profile_.get(), instance)); | 90 contents_.reset(new TestTabContents(profile_.get(), instance)); |
| 86 } | 91 } |
| 87 | 92 |
| 88 void RenderViewHostTestHarness::TearDown() { | 93 void RenderViewHostTestHarness::TearDown() { |
| 89 contents_.reset(); | 94 contents_.reset(); |
| 90 | 95 |
| 91 // Make sure that we flush any messages related to TabContents destruction | 96 // Make sure that we flush any messages related to TabContents destruction |
| 92 // before we destroy the profile. | 97 // before we destroy the profile. |
| 93 MessageLoop::current()->RunAllPending(); | 98 MessageLoop::current()->RunAllPending(); |
| 94 } | 99 } |
| OLD | NEW |