OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/test/base/chrome_render_view_test.h" | 5 #include "chrome/test/base/chrome_render_view_test.h" |
6 | 6 |
7 #include "base/debug/leak_annotations.h" | 7 #include "base/debug/leak_annotations.h" |
8 #include "chrome/browser/chrome_content_browser_client.h" | 8 #include "chrome/browser/chrome_content_browser_client.h" |
9 #include "chrome/common/chrome_content_client.h" | 9 #include "chrome/common/chrome_content_client.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 using blink::WebInputEvent; | 34 using blink::WebInputEvent; |
35 using blink::WebMouseEvent; | 35 using blink::WebMouseEvent; |
36 using blink::WebScriptController; | 36 using blink::WebScriptController; |
37 using blink::WebScriptSource; | 37 using blink::WebScriptSource; |
38 using blink::WebString; | 38 using blink::WebString; |
39 using blink::WebURLRequest; | 39 using blink::WebURLRequest; |
40 using autofill::AutofillAgent; | 40 using autofill::AutofillAgent; |
41 using autofill::PasswordAutofillAgent; | 41 using autofill::PasswordAutofillAgent; |
42 using autofill::PasswordGenerationAgent; | 42 using autofill::PasswordGenerationAgent; |
43 | 43 |
44 ChromeRenderViewTest::ChromeRenderViewTest() : extension_dispatcher_(NULL) { | 44 ChromeRenderViewTest::ChromeRenderViewTest() |
| 45 : password_autofill_(NULL), |
| 46 password_generation_(NULL), |
| 47 autofill_agent_(NULL), |
| 48 chrome_render_thread_(NULL) { |
45 } | 49 } |
46 | 50 |
47 ChromeRenderViewTest::~ChromeRenderViewTest() { | 51 ChromeRenderViewTest::~ChromeRenderViewTest() { |
48 } | 52 } |
49 | 53 |
50 void ChromeRenderViewTest::SetUp() { | 54 void ChromeRenderViewTest::SetUp() { |
51 ChromeUnitTestSuite::InitializeProviders(); | 55 ChromeUnitTestSuite::InitializeProviders(); |
52 ChromeUnitTestSuite::InitializeResourceBundle(); | 56 ChromeUnitTestSuite::InitializeResourceBundle(); |
53 | 57 |
54 chrome_render_thread_ = new ChromeMockRenderThread(); | 58 chrome_render_thread_ = new ChromeMockRenderThread(); |
55 render_thread_.reset(chrome_render_thread_); | 59 render_thread_.reset(chrome_render_thread_); |
56 | 60 |
57 extension_dispatcher_ = new extensions::Dispatcher(); | |
58 | |
59 content::RenderViewTest::SetUp(); | 61 content::RenderViewTest::SetUp(); |
60 | 62 |
61 // RenderView doesn't expose its Agent objects, because it has no need to | 63 // RenderView doesn't expose its Agent objects, because it has no need to |
62 // store them directly (they're stored as RenderViewObserver*). So just | 64 // store them directly (they're stored as RenderViewObserver*). So just |
63 // create another set. | 65 // create another set. |
64 password_autofill_ = new autofill::TestPasswordAutofillAgent(view_); | 66 password_autofill_ = new autofill::TestPasswordAutofillAgent(view_); |
65 password_generation_ = new autofill::TestPasswordGenerationAgent(view_); | 67 password_generation_ = new autofill::TestPasswordGenerationAgent(view_); |
66 autofill_agent_ = | 68 autofill_agent_ = |
67 new AutofillAgent(view_, password_autofill_, password_generation_); | 69 new AutofillAgent(view_, password_autofill_, password_generation_); |
68 } | 70 } |
69 | 71 |
70 void ChromeRenderViewTest::TearDown() { | 72 void ChromeRenderViewTest::TearDown() { |
71 extension_dispatcher_->OnRenderProcessShutdown(); | 73 ChromeContentRendererClient* client = |
72 extension_dispatcher_ = NULL; | 74 static_cast<ChromeContentRendererClient*>(content_renderer_client_.get()); |
| 75 client->GetExtensionDispatcherForTest()->OnRenderProcessShutdown(); |
73 | 76 |
74 #if defined(LEAK_SANITIZER) | 77 #if defined(LEAK_SANITIZER) |
75 // Do this before shutting down V8 in RenderViewTest::TearDown(). | 78 // Do this before shutting down V8 in RenderViewTest::TearDown(). |
76 // http://crbug.com/328552 | 79 // http://crbug.com/328552 |
77 __lsan_do_leak_check(); | 80 __lsan_do_leak_check(); |
78 #endif | 81 #endif |
79 content::RenderViewTest::TearDown(); | 82 content::RenderViewTest::TearDown(); |
80 } | 83 } |
81 | 84 |
82 content::ContentClient* ChromeRenderViewTest::CreateContentClient() { | 85 content::ContentClient* ChromeRenderViewTest::CreateContentClient() { |
83 return new ChromeContentClient(); | 86 return new ChromeContentClient(); |
84 } | 87 } |
85 | 88 |
86 content::ContentBrowserClient* | 89 content::ContentBrowserClient* |
87 ChromeRenderViewTest::CreateContentBrowserClient() { | 90 ChromeRenderViewTest::CreateContentBrowserClient() { |
88 return new chrome::ChromeContentBrowserClient(); | 91 return new chrome::ChromeContentBrowserClient(); |
89 } | 92 } |
90 | 93 |
91 content::ContentRendererClient* | 94 content::ContentRendererClient* |
92 ChromeRenderViewTest::CreateContentRendererClient() { | 95 ChromeRenderViewTest::CreateContentRendererClient() { |
93 ChromeContentRendererClient* client = new ChromeContentRendererClient(); | 96 ChromeContentRendererClient* client = new ChromeContentRendererClient(); |
94 client->SetExtensionDispatcher(extension_dispatcher_); | 97 client->SetExtensionDispatcherForTest(new extensions::Dispatcher); |
95 #if defined(ENABLE_SPELLCHECK) | 98 #if defined(ENABLE_SPELLCHECK) |
96 client->SetSpellcheck(new SpellCheck()); | 99 client->SetSpellcheck(new SpellCheck()); |
97 #endif | 100 #endif |
98 return client; | 101 return client; |
99 } | 102 } |
OLD | NEW |