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/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/test/base/chrome_render_view_test.h" | 8 #include "chrome/test/base/chrome_render_view_test.h" |
9 #include "components/autofill/content/common/autofill_messages.h" | 9 #include "components/autofill/content/common/autofill_messages.h" |
10 #include "components/autofill/content/renderer/autofill_agent.h" | 10 #include "components/autofill/content/renderer/autofill_agent.h" |
11 #include "components/autofill/core/common/form_data.h" | 11 #include "components/autofill/core/common/form_data.h" |
12 #include "components/autofill/core/common/form_field_data.h" | 12 #include "components/autofill/core/common/form_field_data.h" |
13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "third_party/WebKit/public/platform/WebString.h" | 15 #include "third_party/WebKit/public/platform/WebString.h" |
16 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 16 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
17 #include "third_party/WebKit/public/platform/WebVector.h" | 17 #include "third_party/WebKit/public/platform/WebVector.h" |
18 #include "third_party/WebKit/public/web/WebAutocompleteParams.h" | |
19 #include "third_party/WebKit/public/web/WebDocument.h" | 18 #include "third_party/WebKit/public/web/WebDocument.h" |
20 #include "third_party/WebKit/public/web/WebFormElement.h" | 19 #include "third_party/WebKit/public/web/WebFormElement.h" |
21 #include "third_party/WebKit/public/web/WebInputElement.h" | 20 #include "third_party/WebKit/public/web/WebInputElement.h" |
22 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 21 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
23 | 22 |
24 using base::ASCIIToUTF16; | 23 using base::ASCIIToUTF16; |
25 using blink::WebAutocompleteParams; | |
26 using blink::WebDocument; | 24 using blink::WebDocument; |
27 using blink::WebElement; | 25 using blink::WebElement; |
28 using blink::WebFormElement; | 26 using blink::WebFormElement; |
29 using blink::WebFrame; | 27 using blink::WebFrame; |
30 using blink::WebLocalFrame; | 28 using blink::WebLocalFrame; |
31 using blink::WebInputElement; | 29 using blink::WebInputElement; |
32 using blink::WebString; | 30 using blink::WebString; |
33 using blink::WebURLRequest; | 31 using blink::WebURLRequest; |
34 using blink::WebVector; | 32 using blink::WebVector; |
35 | 33 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 270 |
273 WebVector<WebFormElement> forms; | 271 WebVector<WebFormElement> forms; |
274 invoking_frame()->document().forms(forms); | 272 invoking_frame()->document().forms(forms); |
275 ASSERT_EQ(1U, forms.size()); | 273 ASSERT_EQ(1U, forms.size()); |
276 invoking_form_ = forms[0]; | 274 invoking_form_ = forms[0]; |
277 ASSERT_FALSE(invoking_form().isNull()); | 275 ASSERT_FALSE(invoking_form().isNull()); |
278 | 276 |
279 render_thread_->sink().ClearMessages(); | 277 render_thread_->sink().ClearMessages(); |
280 | 278 |
281 // Invoke requestAutocomplete to show the dialog. | 279 // Invoke requestAutocomplete to show the dialog. |
282 autofill_agent_->didRequestAutocomplete(invoking_form(), | 280 autofill_agent_->didRequestAutocomplete(invoking_form()); |
283 blink::WebAutocompleteParams()); | |
284 ASSERT_TRUE(render_thread_->sink().GetFirstMessageMatching( | 281 ASSERT_TRUE(render_thread_->sink().GetFirstMessageMatching( |
285 AutofillHostMsg_RequestAutocomplete::ID)); | 282 AutofillHostMsg_RequestAutocomplete::ID)); |
286 | 283 |
287 render_thread_->sink().ClearMessages(); | 284 render_thread_->sink().ClearMessages(); |
288 } | 285 } |
289 | 286 |
290 virtual void TearDown() OVERRIDE { | 287 virtual void TearDown() OVERRIDE { |
291 invoking_form_.reset(); | 288 invoking_form_.reset(); |
292 AutofillRendererTest::TearDown(); | 289 AutofillRendererTest::TearDown(); |
293 } | 290 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 FormData()); | 348 FormData()); |
352 | 349 |
353 // Additional navigations should not crash nor send cancels. | 350 // Additional navigations should not crash nor send cancels. |
354 NavigateFrame(GetMainFrame()); | 351 NavigateFrame(GetMainFrame()); |
355 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( | 352 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
356 AutofillHostMsg_CancelRequestAutocomplete::ID)); | 353 AutofillHostMsg_CancelRequestAutocomplete::ID)); |
357 } | 354 } |
358 | 355 |
359 TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) { | 356 TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) { |
360 // Attempting to show the requestAutocomplete dialog again should be ignored. | 357 // Attempting to show the requestAutocomplete dialog again should be ignored. |
361 autofill_agent_->didRequestAutocomplete(invoking_form(), | 358 autofill_agent_->didRequestAutocomplete(invoking_form()); |
362 blink::WebAutocompleteParams()); | |
363 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( | 359 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
364 AutofillHostMsg_RequestAutocomplete::ID)); | 360 AutofillHostMsg_RequestAutocomplete::ID)); |
365 } | 361 } |
366 | 362 |
367 } // namespace autofill | 363 } // namespace autofill |
OLD | NEW |