Index: chrome/test/base/chrome_render_view_test.cc |
diff --git a/chrome/test/base/chrome_render_view_test.cc b/chrome/test/base/chrome_render_view_test.cc |
index 4f47f69eb007c99a4b791220cd01c23e595b2ae5..d968e0c644af3aa89a7405290de1442a3f733607 100644 |
--- a/chrome/test/base/chrome_render_view_test.cc |
+++ b/chrome/test/base/chrome_render_view_test.cc |
@@ -18,6 +18,7 @@ |
#include "content/public/browser/native_web_keyboard_event.h" |
#include "content/public/common/renderer_preferences.h" |
#include "content/public/renderer/render_view.h" |
+#include "testing/gmock/include/gmock/gmock.h" |
#include "third_party/WebKit/public/platform/WebURLRequest.h" |
#include "third_party/WebKit/public/web/WebFrame.h" |
#include "third_party/WebKit/public/web/WebInputEvent.h" |
@@ -44,6 +45,34 @@ using blink::WebScriptController; |
using blink::WebScriptSource; |
using blink::WebString; |
using blink::WebURLRequest; |
+using content::RenderFrame; |
+using testing::NiceMock; |
+using testing::Return; |
+using testing::_; |
+ |
+namespace { |
+ |
+// An autofill agent that treats all typing as user gesture. |
+class MockAutofillAgent : public AutofillAgent { |
+ public: |
+ MockAutofillAgent(RenderFrame* render_frame, |
+ PasswordAutofillAgent* password_autofill_agent, |
+ PasswordGenerationAgent* password_generation_agent) |
+ : AutofillAgent(render_frame, |
+ password_autofill_agent, |
+ password_generation_agent) { |
+ ON_CALL(*this, IsUserGesture()).WillByDefault(Return(true)); |
+ } |
+ |
+ ~MockAutofillAgent() override {} |
+ |
+ MOCK_CONST_METHOD0(IsUserGesture, bool()); |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(MockAutofillAgent); |
+}; |
+ |
+} // namespace |
ChromeRenderViewTest::ChromeRenderViewTest() |
: password_autofill_agent_(NULL), |
@@ -71,9 +100,9 @@ void ChromeRenderViewTest::SetUp() { |
new autofill::TestPasswordAutofillAgent(view_->GetMainRenderFrame()); |
password_generation_ = |
new autofill::TestPasswordGenerationAgent(view_->GetMainRenderFrame()); |
- autofill_agent_ = |
- new AutofillAgent(view_->GetMainRenderFrame(), password_autofill_agent_, |
- password_generation_); |
+ autofill_agent_ = new NiceMock<MockAutofillAgent>(view_->GetMainRenderFrame(), |
+ password_autofill_agent_, |
+ password_generation_); |
} |
void ChromeRenderViewTest::TearDown() { |
@@ -96,12 +125,12 @@ content::ContentClient* ChromeRenderViewTest::CreateContentClient() { |
} |
content::ContentBrowserClient* |
- ChromeRenderViewTest::CreateContentBrowserClient() { |
+ChromeRenderViewTest::CreateContentBrowserClient() { |
return new chrome::ChromeContentBrowserClient(); |
} |
content::ContentRendererClient* |
- ChromeRenderViewTest::CreateContentRendererClient() { |
+ChromeRenderViewTest::CreateContentRendererClient() { |
ChromeContentRendererClient* client = new ChromeContentRendererClient(); |
#if defined(ENABLE_EXTENSIONS) |
extension_dispatcher_delegate_.reset( |
@@ -114,3 +143,13 @@ content::ContentRendererClient* |
#endif |
return client; |
} |
+ |
+void ChromeRenderViewTest::EnableUserGestureSimulationForAutofill() { |
+ EXPECT_CALL(*(static_cast<MockAutofillAgent*>(autofill_agent_)), |
+ IsUserGesture()).WillRepeatedly(Return(true)); |
+} |
+ |
+void ChromeRenderViewTest::DisableUserGestureSimulationForAutofill() { |
+ EXPECT_CALL(*(static_cast<MockAutofillAgent*>(autofill_agent_)), |
+ IsUserGesture()).WillRepeatedly(Return(false)); |
+} |