| 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/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 void ChromeRenderViewTest::SetUp() { | 105 void ChromeRenderViewTest::SetUp() { |
| 106 ChromeUnitTestSuite::InitializeProviders(); | 106 ChromeUnitTestSuite::InitializeProviders(); |
| 107 ChromeUnitTestSuite::InitializeResourceBundle(); | 107 ChromeUnitTestSuite::InitializeResourceBundle(); |
| 108 | 108 |
| 109 chrome_render_thread_ = new ChromeMockRenderThread(); | 109 chrome_render_thread_ = new ChromeMockRenderThread(); |
| 110 render_thread_.reset(chrome_render_thread_); | 110 render_thread_.reset(chrome_render_thread_); |
| 111 | 111 |
| 112 content::RenderViewTest::SetUp(); | 112 content::RenderViewTest::SetUp(); |
| 113 | 113 |
| 114 RegisterMainFrameRemoteInterfaces(); |
| 115 |
| 114 // RenderFrame doesn't expose its Agent objects, because it has no need to | 116 // RenderFrame doesn't expose its Agent objects, because it has no need to |
| 115 // store them directly (they're stored as RenderFrameObserver*). So just | 117 // store them directly (they're stored as RenderFrameObserver*). So just |
| 116 // create another set. | 118 // create another set. |
| 117 password_autofill_agent_ = | 119 password_autofill_agent_ = |
| 118 new autofill::TestPasswordAutofillAgent(view_->GetMainRenderFrame()); | 120 new autofill::TestPasswordAutofillAgent(view_->GetMainRenderFrame()); |
| 119 password_generation_ = | 121 password_generation_ = |
| 120 new autofill::TestPasswordGenerationAgent(view_->GetMainRenderFrame(), | 122 new autofill::TestPasswordGenerationAgent(view_->GetMainRenderFrame(), |
| 121 password_autofill_agent_); | 123 password_autofill_agent_); |
| 122 autofill_agent_ = new NiceMock<MockAutofillAgent>(view_->GetMainRenderFrame(), | 124 autofill_agent_ = new NiceMock<MockAutofillAgent>(view_->GetMainRenderFrame(), |
| 123 password_autofill_agent_, | 125 password_autofill_agent_, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 149 return new ChromeContentBrowserClient(); | 151 return new ChromeContentBrowserClient(); |
| 150 } | 152 } |
| 151 | 153 |
| 152 content::ContentRendererClient* | 154 content::ContentRendererClient* |
| 153 ChromeRenderViewTest::CreateContentRendererClient() { | 155 ChromeRenderViewTest::CreateContentRendererClient() { |
| 154 ChromeContentRendererClient* client = new ChromeContentRendererClient(); | 156 ChromeContentRendererClient* client = new ChromeContentRendererClient(); |
| 155 InitChromeContentRendererClient(client); | 157 InitChromeContentRendererClient(client); |
| 156 return client; | 158 return client; |
| 157 } | 159 } |
| 158 | 160 |
| 161 void ChromeRenderViewTest::RegisterMainFrameRemoteInterfaces() {} |
| 162 |
| 159 void ChromeRenderViewTest::InitChromeContentRendererClient( | 163 void ChromeRenderViewTest::InitChromeContentRendererClient( |
| 160 ChromeContentRendererClient* client) { | 164 ChromeContentRendererClient* client) { |
| 161 #if defined(ENABLE_EXTENSIONS) | 165 #if defined(ENABLE_EXTENSIONS) |
| 162 extension_dispatcher_delegate_.reset( | 166 extension_dispatcher_delegate_.reset( |
| 163 new ChromeExtensionsDispatcherDelegate()); | 167 new ChromeExtensionsDispatcherDelegate()); |
| 164 ChromeExtensionsRendererClient* ext_client = | 168 ChromeExtensionsRendererClient* ext_client = |
| 165 ChromeExtensionsRendererClient::GetInstance(); | 169 ChromeExtensionsRendererClient::GetInstance(); |
| 166 ext_client->SetExtensionDispatcherForTest(base::WrapUnique( | 170 ext_client->SetExtensionDispatcherForTest(base::WrapUnique( |
| 167 new extensions::Dispatcher(extension_dispatcher_delegate_.get()))); | 171 new extensions::Dispatcher(extension_dispatcher_delegate_.get()))); |
| 168 #endif | 172 #endif |
| 169 #if defined(ENABLE_SPELLCHECK) | 173 #if defined(ENABLE_SPELLCHECK) |
| 170 client->SetSpellcheck(new SpellCheck()); | 174 client->SetSpellcheck(new SpellCheck()); |
| 171 #endif | 175 #endif |
| 172 } | 176 } |
| 173 | 177 |
| 174 void ChromeRenderViewTest::EnableUserGestureSimulationForAutofill() { | 178 void ChromeRenderViewTest::EnableUserGestureSimulationForAutofill() { |
| 175 EXPECT_CALL(*(static_cast<MockAutofillAgent*>(autofill_agent_)), | 179 EXPECT_CALL(*(static_cast<MockAutofillAgent*>(autofill_agent_)), |
| 176 IsUserGesture()).WillRepeatedly(Return(true)); | 180 IsUserGesture()).WillRepeatedly(Return(true)); |
| 177 } | 181 } |
| 178 | 182 |
| 179 void ChromeRenderViewTest::DisableUserGestureSimulationForAutofill() { | 183 void ChromeRenderViewTest::DisableUserGestureSimulationForAutofill() { |
| 180 EXPECT_CALL(*(static_cast<MockAutofillAgent*>(autofill_agent_)), | 184 EXPECT_CALL(*(static_cast<MockAutofillAgent*>(autofill_agent_)), |
| 181 IsUserGesture()).WillRepeatedly(Return(false)); | 185 IsUserGesture()).WillRepeatedly(Return(false)); |
| 182 } | 186 } |
| 183 | 187 |
| 184 void ChromeRenderViewTest::WaitForAutofillDidAssociateFormControl() { | 188 void ChromeRenderViewTest::WaitForAutofillDidAssociateFormControl() { |
| 185 static_cast<MockAutofillAgent*>(autofill_agent_) | 189 static_cast<MockAutofillAgent*>(autofill_agent_) |
| 186 ->WaitForAutofillDidAssociateFormControl(); | 190 ->WaitForAutofillDidAssociateFormControl(); |
| 187 } | 191 } |
| OLD | NEW |