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