| 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 "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "chrome/browser/chrome_content_browser_client.h" | 9 #include "chrome/browser/chrome_content_browser_client.h" |
| 10 #include "chrome/common/chrome_content_client.h" | 10 #include "chrome/common/chrome_content_client.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 22 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 23 #include "third_party/WebKit/public/web/WebFrame.h" | 23 #include "third_party/WebKit/public/web/WebFrame.h" |
| 24 #include "third_party/WebKit/public/web/WebInputEvent.h" | 24 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 25 #include "third_party/WebKit/public/web/WebKit.h" | 25 #include "third_party/WebKit/public/web/WebKit.h" |
| 26 #include "third_party/WebKit/public/web/WebScriptController.h" | 26 #include "third_party/WebKit/public/web/WebScriptController.h" |
| 27 #include "third_party/WebKit/public/web/WebScriptSource.h" | 27 #include "third_party/WebKit/public/web/WebScriptSource.h" |
| 28 #include "third_party/WebKit/public/web/WebView.h" | 28 #include "third_party/WebKit/public/web/WebView.h" |
| 29 | 29 |
| 30 #if defined(ENABLE_EXTENSIONS) | 30 #if defined(ENABLE_EXTENSIONS) |
| 31 #include "chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.h" | 31 #include "chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.h" |
| 32 #include "chrome/renderer/extensions/chrome_extensions_renderer_client.h" |
| 32 #include "extensions/browser/extension_function_dispatcher.h" | 33 #include "extensions/browser/extension_function_dispatcher.h" |
| 33 #include "extensions/common/extension.h" | 34 #include "extensions/common/extension.h" |
| 34 #include "extensions/renderer/dispatcher.h" | 35 #include "extensions/renderer/dispatcher.h" |
| 35 #include "extensions/renderer/event_bindings.h" | 36 #include "extensions/renderer/event_bindings.h" |
| 36 #endif | 37 #endif |
| 37 | 38 |
| 38 using autofill::AutofillAgent; | 39 using autofill::AutofillAgent; |
| 39 using autofill::PasswordAutofillAgent; | 40 using autofill::PasswordAutofillAgent; |
| 40 using autofill::PasswordGenerationAgent; | 41 using autofill::PasswordGenerationAgent; |
| 41 using blink::WebFrame; | 42 using blink::WebFrame; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 new autofill::TestPasswordGenerationAgent(view_->GetMainRenderFrame(), | 103 new autofill::TestPasswordGenerationAgent(view_->GetMainRenderFrame(), |
| 103 password_autofill_agent_); | 104 password_autofill_agent_); |
| 104 autofill_agent_ = new NiceMock<MockAutofillAgent>(view_->GetMainRenderFrame(), | 105 autofill_agent_ = new NiceMock<MockAutofillAgent>(view_->GetMainRenderFrame(), |
| 105 password_autofill_agent_, | 106 password_autofill_agent_, |
| 106 password_generation_); | 107 password_generation_); |
| 107 } | 108 } |
| 108 | 109 |
| 109 void ChromeRenderViewTest::TearDown() { | 110 void ChromeRenderViewTest::TearDown() { |
| 110 base::RunLoop().RunUntilIdle(); | 111 base::RunLoop().RunUntilIdle(); |
| 111 #if defined(ENABLE_EXTENSIONS) | 112 #if defined(ENABLE_EXTENSIONS) |
| 112 ChromeContentRendererClient* client = | 113 ChromeExtensionsRendererClient* ext_client = |
| 113 static_cast<ChromeContentRendererClient*>(content_renderer_client_.get()); | 114 ChromeExtensionsRendererClient::GetInstance(); |
| 114 client->GetExtensionDispatcherForTest()->OnRenderProcessShutdown(); | 115 ext_client->GetExtensionDispatcherForTest()->OnRenderProcessShutdown(); |
| 115 #endif | 116 #endif |
| 116 | 117 |
| 117 #if defined(LEAK_SANITIZER) | 118 #if defined(LEAK_SANITIZER) |
| 118 // Do this before shutting down V8 in RenderViewTest::TearDown(). | 119 // Do this before shutting down V8 in RenderViewTest::TearDown(). |
| 119 // http://crbug.com/328552 | 120 // http://crbug.com/328552 |
| 120 __lsan_do_leak_check(); | 121 __lsan_do_leak_check(); |
| 121 #endif | 122 #endif |
| 122 content::RenderViewTest::TearDown(); | 123 content::RenderViewTest::TearDown(); |
| 123 } | 124 } |
| 124 | 125 |
| 125 content::ContentClient* ChromeRenderViewTest::CreateContentClient() { | 126 content::ContentClient* ChromeRenderViewTest::CreateContentClient() { |
| 126 return new ChromeContentClient(); | 127 return new ChromeContentClient(); |
| 127 } | 128 } |
| 128 | 129 |
| 129 content::ContentBrowserClient* | 130 content::ContentBrowserClient* |
| 130 ChromeRenderViewTest::CreateContentBrowserClient() { | 131 ChromeRenderViewTest::CreateContentBrowserClient() { |
| 131 return new ChromeContentBrowserClient(); | 132 return new ChromeContentBrowserClient(); |
| 132 } | 133 } |
| 133 | 134 |
| 134 content::ContentRendererClient* | 135 content::ContentRendererClient* |
| 135 ChromeRenderViewTest::CreateContentRendererClient() { | 136 ChromeRenderViewTest::CreateContentRendererClient() { |
| 136 ChromeContentRendererClient* client = new ChromeContentRendererClient(); | 137 ChromeContentRendererClient* client = new ChromeContentRendererClient(); |
| 137 #if defined(ENABLE_EXTENSIONS) | 138 #if defined(ENABLE_EXTENSIONS) |
| 138 extension_dispatcher_delegate_.reset( | 139 extension_dispatcher_delegate_.reset( |
| 139 new ChromeExtensionsDispatcherDelegate()); | 140 new ChromeExtensionsDispatcherDelegate()); |
| 140 client->SetExtensionDispatcherForTest( | 141 ChromeExtensionsRendererClient* ext_client = |
| 141 new extensions::Dispatcher(extension_dispatcher_delegate_.get())); | 142 ChromeExtensionsRendererClient::GetInstance(); |
| 143 ext_client->SetExtensionDispatcherForTest( |
| 144 make_scoped_ptr( |
| 145 new extensions::Dispatcher(extension_dispatcher_delegate_.get()))); |
| 142 #endif | 146 #endif |
| 143 #if defined(ENABLE_SPELLCHECK) | 147 #if defined(ENABLE_SPELLCHECK) |
| 144 client->SetSpellcheck(new SpellCheck()); | 148 client->SetSpellcheck(new SpellCheck()); |
| 145 #endif | 149 #endif |
| 146 return client; | 150 return client; |
| 147 } | 151 } |
| 148 | 152 |
| 149 void ChromeRenderViewTest::EnableUserGestureSimulationForAutofill() { | 153 void ChromeRenderViewTest::EnableUserGestureSimulationForAutofill() { |
| 150 EXPECT_CALL(*(static_cast<MockAutofillAgent*>(autofill_agent_)), | 154 EXPECT_CALL(*(static_cast<MockAutofillAgent*>(autofill_agent_)), |
| 151 IsUserGesture()).WillRepeatedly(Return(true)); | 155 IsUserGesture()).WillRepeatedly(Return(true)); |
| 152 } | 156 } |
| 153 | 157 |
| 154 void ChromeRenderViewTest::DisableUserGestureSimulationForAutofill() { | 158 void ChromeRenderViewTest::DisableUserGestureSimulationForAutofill() { |
| 155 EXPECT_CALL(*(static_cast<MockAutofillAgent*>(autofill_agent_)), | 159 EXPECT_CALL(*(static_cast<MockAutofillAgent*>(autofill_agent_)), |
| 156 IsUserGesture()).WillRepeatedly(Return(false)); | 160 IsUserGesture()).WillRepeatedly(Return(false)); |
| 157 } | 161 } |
| OLD | NEW |