| 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" |
| 11 #include "chrome/renderer/chrome_content_renderer_client.h" | 11 #include "chrome/renderer/chrome_content_renderer_client.h" |
| 12 #include "chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.h" | |
| 13 #include "chrome/renderer/spellchecker/spellcheck.h" | 12 #include "chrome/renderer/spellchecker/spellcheck.h" |
| 14 #include "chrome/test/base/chrome_unit_test_suite.h" | 13 #include "chrome/test/base/chrome_unit_test_suite.h" |
| 15 #include "components/autofill/content/renderer/autofill_agent.h" | 14 #include "components/autofill/content/renderer/autofill_agent.h" |
| 16 #include "components/autofill/content/renderer/password_autofill_agent.h" | 15 #include "components/autofill/content/renderer/password_autofill_agent.h" |
| 17 #include "components/autofill/content/renderer/test_password_autofill_agent.h" | 16 #include "components/autofill/content/renderer/test_password_autofill_agent.h" |
| 18 #include "components/autofill/content/renderer/test_password_generation_agent.h" | 17 #include "components/autofill/content/renderer/test_password_generation_agent.h" |
| 19 #include "content/public/browser/native_web_keyboard_event.h" | 18 #include "content/public/browser/native_web_keyboard_event.h" |
| 20 #include "content/public/common/renderer_preferences.h" | 19 #include "content/public/common/renderer_preferences.h" |
| 21 #include "content/public/renderer/render_view.h" | 20 #include "content/public/renderer/render_view.h" |
| 22 #include "extensions/browser/extension_function_dispatcher.h" | |
| 23 #include "extensions/common/extension.h" | |
| 24 #include "extensions/renderer/dispatcher.h" | |
| 25 #include "extensions/renderer/event_bindings.h" | |
| 26 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 21 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 27 #include "third_party/WebKit/public/web/WebFrame.h" | 22 #include "third_party/WebKit/public/web/WebFrame.h" |
| 28 #include "third_party/WebKit/public/web/WebInputEvent.h" | 23 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 29 #include "third_party/WebKit/public/web/WebKit.h" | 24 #include "third_party/WebKit/public/web/WebKit.h" |
| 30 #include "third_party/WebKit/public/web/WebScriptController.h" | 25 #include "third_party/WebKit/public/web/WebScriptController.h" |
| 31 #include "third_party/WebKit/public/web/WebScriptSource.h" | 26 #include "third_party/WebKit/public/web/WebScriptSource.h" |
| 32 #include "third_party/WebKit/public/web/WebView.h" | 27 #include "third_party/WebKit/public/web/WebView.h" |
| 33 | 28 |
| 29 #if defined(ENABLE_EXTENSIONS) |
| 30 #include "chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.h" |
| 31 #include "extensions/browser/extension_function_dispatcher.h" |
| 32 #include "extensions/common/extension.h" |
| 33 #include "extensions/renderer/dispatcher.h" |
| 34 #include "extensions/renderer/event_bindings.h" |
| 35 #endif |
| 36 |
| 37 using autofill::AutofillAgent; |
| 38 using autofill::PasswordAutofillAgent; |
| 39 using autofill::PasswordGenerationAgent; |
| 34 using blink::WebFrame; | 40 using blink::WebFrame; |
| 35 using blink::WebInputEvent; | 41 using blink::WebInputEvent; |
| 36 using blink::WebMouseEvent; | 42 using blink::WebMouseEvent; |
| 37 using blink::WebScriptController; | 43 using blink::WebScriptController; |
| 38 using blink::WebScriptSource; | 44 using blink::WebScriptSource; |
| 39 using blink::WebString; | 45 using blink::WebString; |
| 40 using blink::WebURLRequest; | 46 using blink::WebURLRequest; |
| 41 using autofill::AutofillAgent; | |
| 42 using autofill::PasswordAutofillAgent; | |
| 43 using autofill::PasswordGenerationAgent; | |
| 44 | 47 |
| 45 ChromeRenderViewTest::ChromeRenderViewTest() | 48 ChromeRenderViewTest::ChromeRenderViewTest() |
| 46 : password_autofill_(NULL), | 49 : password_autofill_(NULL), |
| 47 password_generation_(NULL), | 50 password_generation_(NULL), |
| 48 autofill_agent_(NULL), | 51 autofill_agent_(NULL), |
| 49 chrome_render_thread_(NULL) { | 52 chrome_render_thread_(NULL) { |
| 50 } | 53 } |
| 51 | 54 |
| 52 ChromeRenderViewTest::~ChromeRenderViewTest() { | 55 ChromeRenderViewTest::~ChromeRenderViewTest() { |
| 53 } | 56 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 64 // RenderView doesn't expose its Agent objects, because it has no need to | 67 // RenderView doesn't expose its Agent objects, because it has no need to |
| 65 // store them directly (they're stored as RenderViewObserver*). So just | 68 // store them directly (they're stored as RenderViewObserver*). So just |
| 66 // create another set. | 69 // create another set. |
| 67 password_autofill_ = new autofill::TestPasswordAutofillAgent(view_); | 70 password_autofill_ = new autofill::TestPasswordAutofillAgent(view_); |
| 68 password_generation_ = new autofill::TestPasswordGenerationAgent(view_); | 71 password_generation_ = new autofill::TestPasswordGenerationAgent(view_); |
| 69 autofill_agent_ = | 72 autofill_agent_ = |
| 70 new AutofillAgent(view_, password_autofill_, password_generation_); | 73 new AutofillAgent(view_, password_autofill_, password_generation_); |
| 71 } | 74 } |
| 72 | 75 |
| 73 void ChromeRenderViewTest::TearDown() { | 76 void ChromeRenderViewTest::TearDown() { |
| 77 #if defined(ENABLE_EXTENSIONS) |
| 74 ChromeContentRendererClient* client = | 78 ChromeContentRendererClient* client = |
| 75 static_cast<ChromeContentRendererClient*>(content_renderer_client_.get()); | 79 static_cast<ChromeContentRendererClient*>(content_renderer_client_.get()); |
| 76 client->GetExtensionDispatcherForTest()->OnRenderProcessShutdown(); | 80 client->GetExtensionDispatcherForTest()->OnRenderProcessShutdown(); |
| 81 #endif |
| 77 | 82 |
| 78 #if defined(LEAK_SANITIZER) | 83 #if defined(LEAK_SANITIZER) |
| 79 // Do this before shutting down V8 in RenderViewTest::TearDown(). | 84 // Do this before shutting down V8 in RenderViewTest::TearDown(). |
| 80 // http://crbug.com/328552 | 85 // http://crbug.com/328552 |
| 81 __lsan_do_leak_check(); | 86 __lsan_do_leak_check(); |
| 82 #endif | 87 #endif |
| 83 content::RenderViewTest::TearDown(); | 88 content::RenderViewTest::TearDown(); |
| 84 } | 89 } |
| 85 | 90 |
| 86 content::ContentClient* ChromeRenderViewTest::CreateContentClient() { | 91 content::ContentClient* ChromeRenderViewTest::CreateContentClient() { |
| 87 return new ChromeContentClient(); | 92 return new ChromeContentClient(); |
| 88 } | 93 } |
| 89 | 94 |
| 90 content::ContentBrowserClient* | 95 content::ContentBrowserClient* |
| 91 ChromeRenderViewTest::CreateContentBrowserClient() { | 96 ChromeRenderViewTest::CreateContentBrowserClient() { |
| 92 return new chrome::ChromeContentBrowserClient(); | 97 return new chrome::ChromeContentBrowserClient(); |
| 93 } | 98 } |
| 94 | 99 |
| 95 content::ContentRendererClient* | 100 content::ContentRendererClient* |
| 96 ChromeRenderViewTest::CreateContentRendererClient() { | 101 ChromeRenderViewTest::CreateContentRendererClient() { |
| 102 ChromeContentRendererClient* client = new ChromeContentRendererClient(); |
| 103 #if defined(ENABLE_EXTENSIONS) |
| 97 extension_dispatcher_delegate_.reset( | 104 extension_dispatcher_delegate_.reset( |
| 98 new ChromeExtensionsDispatcherDelegate()); | 105 new ChromeExtensionsDispatcherDelegate()); |
| 99 ChromeContentRendererClient* client = new ChromeContentRendererClient(); | |
| 100 client->SetExtensionDispatcherForTest( | 106 client->SetExtensionDispatcherForTest( |
| 101 new extensions::Dispatcher(extension_dispatcher_delegate_.get())); | 107 new extensions::Dispatcher(extension_dispatcher_delegate_.get())); |
| 108 #endif |
| 102 #if defined(ENABLE_SPELLCHECK) | 109 #if defined(ENABLE_SPELLCHECK) |
| 103 client->SetSpellcheck(new SpellCheck()); | 110 client->SetSpellcheck(new SpellCheck()); |
| 104 #endif | 111 #endif |
| 105 return client; | 112 return client; |
| 106 } | 113 } |
| OLD | NEW |