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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/test/base/chrome_render_view_test.h" | 9 #include "chrome/test/base/chrome_render_view_test.h" |
10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 " <input type='text' id='full_name'/>" | 251 " <input type='text' id='full_name'/>" |
252 "</form>"); | 252 "</form>"); |
253 | 253 |
254 blink::WebInputElement full_name = | 254 blink::WebInputElement full_name = |
255 GetMainFrame()->document().getElementById("full_name") | 255 GetMainFrame()->document().getElementById("full_name") |
256 .to<blink::WebInputElement>(); | 256 .to<blink::WebInputElement>(); |
257 while (!full_name.focused()) | 257 while (!full_name.focused()) |
258 GetMainFrame()->view()->advanceFocus(false); | 258 GetMainFrame()->view()->advanceFocus(false); |
259 | 259 |
260 // Not a user gesture, so no IPC message to browser. | 260 // Not a user gesture, so no IPC message to browser. |
| 261 DisableUserGestureSimulationForAutofill(); |
261 full_name.setValue("Alice", true); | 262 full_name.setValue("Alice", true); |
262 GetMainFrame()->toWebLocalFrame()->autofillClient()->textFieldDidChange( | 263 GetMainFrame()->toWebLocalFrame()->autofillClient()->textFieldDidChange( |
263 full_name); | 264 full_name); |
264 base::MessageLoop::current()->RunUntilIdle(); | 265 base::MessageLoop::current()->RunUntilIdle(); |
265 ASSERT_EQ(nullptr, render_thread_->sink().GetFirstMessageMatching( | 266 ASSERT_EQ(nullptr, render_thread_->sink().GetFirstMessageMatching( |
266 AutofillHostMsg_TextFieldDidChange::ID)); | 267 AutofillHostMsg_TextFieldDidChange::ID)); |
267 | 268 |
268 // A user gesture will send a message to the browser. | 269 // A user gesture will send a message to the browser. |
| 270 EnableUserGestureSimulationForAutofill(); |
269 SimulateUserInputChangeForElement(&full_name, "Alice"); | 271 SimulateUserInputChangeForElement(&full_name, "Alice"); |
270 ASSERT_NE(nullptr, render_thread_->sink().GetFirstMessageMatching( | 272 ASSERT_NE(nullptr, render_thread_->sink().GetFirstMessageMatching( |
271 AutofillHostMsg_TextFieldDidChange::ID)); | 273 AutofillHostMsg_TextFieldDidChange::ID)); |
272 } | 274 } |
273 | 275 |
274 class RequestAutocompleteRendererTest : public AutofillRendererTest { | 276 class RequestAutocompleteRendererTest : public AutofillRendererTest { |
275 public: | 277 public: |
276 RequestAutocompleteRendererTest() | 278 RequestAutocompleteRendererTest() |
277 : invoking_frame_(NULL), sibling_frame_(NULL) {} | 279 : invoking_frame_(NULL), sibling_frame_(NULL) {} |
278 ~RequestAutocompleteRendererTest() override {} | 280 ~RequestAutocompleteRendererTest() override {} |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 }; | 344 }; |
343 | 345 |
344 TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) { | 346 TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) { |
345 // Attempting to show the requestAutocomplete dialog again should be ignored. | 347 // Attempting to show the requestAutocomplete dialog again should be ignored. |
346 invoking_frame_->autofillClient()->didRequestAutocomplete(invoking_form()); | 348 invoking_frame_->autofillClient()->didRequestAutocomplete(invoking_form()); |
347 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( | 349 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
348 AutofillHostMsg_RequestAutocomplete::ID)); | 350 AutofillHostMsg_RequestAutocomplete::ID)); |
349 } | 351 } |
350 | 352 |
351 } // namespace autofill | 353 } // namespace autofill |
OLD | NEW |