chrome_render_view_test.cc revision 23730a6e56a168d1879203e4b3819bb36e3d8f1f
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 3// found in the LICENSE file. 4 5#include "chrome/test/base/chrome_render_view_test.h" 6 7#include "base/debug/leak_annotations.h" 8#include "chrome/browser/chrome_content_browser_client.h" 9#include "chrome/common/chrome_content_client.h" 10#include "chrome/common/render_messages.h" 11#include "chrome/renderer/chrome_content_renderer_client.h" 12#include "chrome/renderer/extensions/chrome_v8_context_set.h" 13#include "chrome/renderer/extensions/chrome_v8_extension.h" 14#include "chrome/renderer/extensions/dispatcher.h" 15#include "chrome/renderer/extensions/event_bindings.h" 16#include "chrome/renderer/spellchecker/spellcheck.h" 17#include "chrome/test/base/chrome_unit_test_suite.h" 18#include "components/autofill/content/renderer/autofill_agent.h" 19#include "components/autofill/content/renderer/password_autofill_agent.h" 20#include "components/autofill/content/renderer/test_password_autofill_agent.h" 21#include "components/autofill/content/renderer/test_password_generation_agent.h" 22#include "content/public/browser/native_web_keyboard_event.h" 23#include "content/public/common/renderer_preferences.h" 24#include "content/public/renderer/render_view.h" 25#include "extensions/browser/extension_function_dispatcher.h" 26#include "extensions/common/extension.h" 27#include "grit/renderer_resources.h" 28#include "third_party/WebKit/public/platform/WebURLRequest.h" 29#include "third_party/WebKit/public/web/WebFrame.h" 30#include "third_party/WebKit/public/web/WebInputEvent.h" 31#include "third_party/WebKit/public/web/WebKit.h" 32#include "third_party/WebKit/public/web/WebScriptController.h" 33#include "third_party/WebKit/public/web/WebScriptSource.h" 34#include "third_party/WebKit/public/web/WebView.h" 35 36#if defined(OS_LINUX) && !defined(USE_AURA) 37#include "ui/base/gtk/event_synthesis_gtk.h" 38#endif 39 40using blink::WebFrame; 41using blink::WebInputEvent; 42using blink::WebMouseEvent; 43using blink::WebScriptController; 44using blink::WebScriptSource; 45using blink::WebString; 46using blink::WebURLRequest; 47using autofill::AutofillAgent; 48using autofill::PasswordAutofillAgent; 49using autofill::PasswordGenerationAgent; 50 51ChromeRenderViewTest::ChromeRenderViewTest() : extension_dispatcher_(NULL) { 52} 53 54ChromeRenderViewTest::~ChromeRenderViewTest() { 55} 56 57void ChromeRenderViewTest::SetUp() { 58 ChromeUnitTestSuite::InitializeProviders(); 59 ChromeUnitTestSuite::InitializeResourceBundle(); 60 61 chrome_render_thread_ = new ChromeMockRenderThread(); 62 render_thread_.reset(chrome_render_thread_); 63 64 extension_dispatcher_ = new extensions::Dispatcher(); 65 66 content::RenderViewTest::SetUp(); 67 68 // RenderView doesn't expose its Agent objects, because it has no need to 69 // store them directly (they're stored as RenderViewObserver*). So just 70 // create another set. 71 password_autofill_ = new autofill::TestPasswordAutofillAgent(view_); 72 password_generation_ = new autofill::TestPasswordGenerationAgent(view_); 73 autofill_agent_ = 74 new AutofillAgent(view_, password_autofill_, password_generation_); 75} 76 77void ChromeRenderViewTest::TearDown() { 78 extension_dispatcher_->OnRenderProcessShutdown(); 79 extension_dispatcher_ = NULL; 80 81#if defined(LEAK_SANITIZER) 82 // Do this before shutting down V8 in RenderViewTest::TearDown(). 83 // http://crbug.com/328552 84 __lsan_do_leak_check(); 85#endif 86 content::RenderViewTest::TearDown(); 87} 88 89content::ContentClient* ChromeRenderViewTest::CreateContentClient() { 90 return new ChromeContentClient(); 91} 92 93content::ContentBrowserClient* 94 ChromeRenderViewTest::CreateContentBrowserClient() { 95 return new chrome::ChromeContentBrowserClient(); 96} 97 98content::ContentRendererClient* 99 ChromeRenderViewTest::CreateContentRendererClient() { 100 ChromeContentRendererClient* client = new ChromeContentRendererClient(); 101 client->SetExtensionDispatcher(extension_dispatcher_); 102#if defined(ENABLE_SPELLCHECK) 103 client->SetSpellcheck(new SpellCheck()); 104#endif 105 return client; 106} 107