Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: chrome/test/base/chrome_render_view_test.cc

Issue 2055693002: Add delay to didAssociateFormControlsTimer so it doesn't fire too frequently (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 PasswordAutofillAgent* password_autofill_agent, 62 PasswordAutofillAgent* password_autofill_agent,
63 PasswordGenerationAgent* password_generation_agent) 63 PasswordGenerationAgent* password_generation_agent)
64 : AutofillAgent(render_frame, 64 : AutofillAgent(render_frame,
65 password_autofill_agent, 65 password_autofill_agent,
66 password_generation_agent) { 66 password_generation_agent) {
67 ON_CALL(*this, IsUserGesture()).WillByDefault(Return(true)); 67 ON_CALL(*this, IsUserGesture()).WillByDefault(Return(true));
68 } 68 }
69 69
70 ~MockAutofillAgent() override {} 70 ~MockAutofillAgent() override {}
71 71
72 void WaitForAutofillDidAssociateFormControl() {
73 DCHECK(run_loop_ == nullptr);
74 run_loop_.reset(new base::RunLoop);
75 run_loop_->Run();
76 run_loop_.reset();
77 }
78
72 MOCK_CONST_METHOD0(IsUserGesture, bool()); 79 MOCK_CONST_METHOD0(IsUserGesture, bool());
73 80
74 private: 81 private:
82 void didAssociateFormControls(
83 const blink::WebVector<blink::WebNode>& nodes) override {
84 AutofillAgent::didAssociateFormControls(nodes);
85 if (run_loop_)
86 run_loop_->Quit();
87 }
88
89 std::unique_ptr<base::RunLoop> run_loop_;
90
75 DISALLOW_COPY_AND_ASSIGN(MockAutofillAgent); 91 DISALLOW_COPY_AND_ASSIGN(MockAutofillAgent);
76 }; 92 };
77 93
78 } // namespace 94 } // namespace
79 95
80 ChromeRenderViewTest::ChromeRenderViewTest() 96 ChromeRenderViewTest::ChromeRenderViewTest()
81 : password_autofill_agent_(NULL), 97 : password_autofill_agent_(NULL),
82 password_generation_(NULL), 98 password_generation_(NULL),
83 autofill_agent_(NULL), 99 autofill_agent_(NULL),
84 chrome_render_thread_(NULL) { 100 chrome_render_thread_(NULL) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 174
159 void ChromeRenderViewTest::EnableUserGestureSimulationForAutofill() { 175 void ChromeRenderViewTest::EnableUserGestureSimulationForAutofill() {
160 EXPECT_CALL(*(static_cast<MockAutofillAgent*>(autofill_agent_)), 176 EXPECT_CALL(*(static_cast<MockAutofillAgent*>(autofill_agent_)),
161 IsUserGesture()).WillRepeatedly(Return(true)); 177 IsUserGesture()).WillRepeatedly(Return(true));
162 } 178 }
163 179
164 void ChromeRenderViewTest::DisableUserGestureSimulationForAutofill() { 180 void ChromeRenderViewTest::DisableUserGestureSimulationForAutofill() {
165 EXPECT_CALL(*(static_cast<MockAutofillAgent*>(autofill_agent_)), 181 EXPECT_CALL(*(static_cast<MockAutofillAgent*>(autofill_agent_)),
166 IsUserGesture()).WillRepeatedly(Return(false)); 182 IsUserGesture()).WillRepeatedly(Return(false));
167 } 183 }
184
185 void ChromeRenderViewTest::WaitForAutofillDidAssociateFormControl() {
186 static_cast<MockAutofillAgent*>(autofill_agent_)
187 ->WaitForAutofillDidAssociateFormControl();
188 }
OLDNEW
« no previous file with comments | « chrome/test/base/chrome_render_view_test.h ('k') | components/autofill/content/renderer/autofill_agent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698