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" |
(...skipping 27 matching lines...) Expand all Loading... |
38 autofill::FormFieldData, | 38 autofill::FormFieldData, |
39 gfx::RectF, | 39 gfx::RectF, |
40 bool> AutofillQueryParam; | 40 bool> AutofillQueryParam; |
41 | 41 |
42 class AutofillRendererTest : public ChromeRenderViewTest { | 42 class AutofillRendererTest : public ChromeRenderViewTest { |
43 public: | 43 public: |
44 AutofillRendererTest() {} | 44 AutofillRendererTest() {} |
45 virtual ~AutofillRendererTest() {} | 45 virtual ~AutofillRendererTest() {} |
46 | 46 |
47 protected: | 47 protected: |
48 virtual void SetUp() OVERRIDE { | 48 virtual void SetUp() override { |
49 ChromeRenderViewTest::SetUp(); | 49 ChromeRenderViewTest::SetUp(); |
50 | 50 |
51 // Don't want any delay for form state sync changes. This will still post a | 51 // Don't want any delay for form state sync changes. This will still post a |
52 // message so updates will get coalesced, but as soon as we spin the message | 52 // message so updates will get coalesced, but as soon as we spin the message |
53 // loop, it will generate an update. | 53 // loop, it will generate an update. |
54 SendContentStateImmediately(); | 54 SendContentStateImmediately(); |
55 } | 55 } |
56 | 56 |
57 void SimulateRequestAutocompleteResult( | 57 void SimulateRequestAutocompleteResult( |
58 const blink::WebFormElement::AutocompleteResult& result, | 58 const blink::WebFormElement::AutocompleteResult& result, |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 // Shouldn't crash. | 247 // Shouldn't crash. |
248 } | 248 } |
249 | 249 |
250 class RequestAutocompleteRendererTest : public AutofillRendererTest { | 250 class RequestAutocompleteRendererTest : public AutofillRendererTest { |
251 public: | 251 public: |
252 RequestAutocompleteRendererTest() | 252 RequestAutocompleteRendererTest() |
253 : invoking_frame_(NULL), sibling_frame_(NULL) {} | 253 : invoking_frame_(NULL), sibling_frame_(NULL) {} |
254 virtual ~RequestAutocompleteRendererTest() {} | 254 virtual ~RequestAutocompleteRendererTest() {} |
255 | 255 |
256 protected: | 256 protected: |
257 virtual void SetUp() OVERRIDE { | 257 virtual void SetUp() override { |
258 AutofillRendererTest::SetUp(); | 258 AutofillRendererTest::SetUp(); |
259 | 259 |
260 // Bypass the HTTPS-only restriction to show requestAutocomplete. | 260 // Bypass the HTTPS-only restriction to show requestAutocomplete. |
261 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 261 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
262 command_line->AppendSwitch(::switches::kReduceSecurityForTesting); | 262 command_line->AppendSwitch(::switches::kReduceSecurityForTesting); |
263 | 263 |
264 GURL url("data:text/html;charset=utf-8," | 264 GURL url("data:text/html;charset=utf-8," |
265 "<form><input autocomplete=cc-number></form>"); | 265 "<form><input autocomplete=cc-number></form>"); |
266 const char kDoubleIframeHtml[] = "<iframe id=subframe src='%s'></iframe>" | 266 const char kDoubleIframeHtml[] = "<iframe id=subframe src='%s'></iframe>" |
267 "<iframe id=sibling></iframe>"; | 267 "<iframe id=sibling></iframe>"; |
(...skipping 20 matching lines...) Expand all Loading... |
288 | 288 |
289 // Invoke requestAutocomplete to show the dialog. | 289 // Invoke requestAutocomplete to show the dialog. |
290 static_cast<blink::WebAutofillClient*>(autofill_agent_) | 290 static_cast<blink::WebAutofillClient*>(autofill_agent_) |
291 ->didRequestAutocomplete(invoking_form()); | 291 ->didRequestAutocomplete(invoking_form()); |
292 ASSERT_TRUE(render_thread_->sink().GetFirstMessageMatching( | 292 ASSERT_TRUE(render_thread_->sink().GetFirstMessageMatching( |
293 AutofillHostMsg_RequestAutocomplete::ID)); | 293 AutofillHostMsg_RequestAutocomplete::ID)); |
294 | 294 |
295 render_thread_->sink().ClearMessages(); | 295 render_thread_->sink().ClearMessages(); |
296 } | 296 } |
297 | 297 |
298 virtual void TearDown() OVERRIDE { | 298 virtual void TearDown() override { |
299 invoking_form_.reset(); | 299 invoking_form_.reset(); |
300 AutofillRendererTest::TearDown(); | 300 AutofillRendererTest::TearDown(); |
301 } | 301 } |
302 | 302 |
303 void NavigateFrame(WebFrame* frame) { | 303 void NavigateFrame(WebFrame* frame) { |
304 frame->loadRequest(WebURLRequest(GURL("about:blank"))); | 304 frame->loadRequest(WebURLRequest(GURL("about:blank"))); |
305 ProcessPendingMessages(); | 305 ProcessPendingMessages(); |
306 } | 306 } |
307 | 307 |
308 const WebFormElement& invoking_form() const { return invoking_form_; } | 308 const WebFormElement& invoking_form() const { return invoking_form_; } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 364 |
365 TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) { | 365 TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) { |
366 // Attempting to show the requestAutocomplete dialog again should be ignored. | 366 // Attempting to show the requestAutocomplete dialog again should be ignored. |
367 static_cast<blink::WebAutofillClient*>(autofill_agent_) | 367 static_cast<blink::WebAutofillClient*>(autofill_agent_) |
368 ->didRequestAutocomplete(invoking_form()); | 368 ->didRequestAutocomplete(invoking_form()); |
369 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( | 369 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
370 AutofillHostMsg_RequestAutocomplete::ID)); | 370 AutofillHostMsg_RequestAutocomplete::ID)); |
371 } | 371 } |
372 | 372 |
373 } // namespace autofill | 373 } // namespace autofill |
OLD | NEW |