| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "components/autofill/core/common/form_data.h" | 41 #include "components/autofill/core/common/form_data.h" |
| 42 #include "components/autofill/core/common/form_field_data.h" | 42 #include "components/autofill/core/common/form_field_data.h" |
| 43 #include "components/autofill/core/common/forms_seen_state.h" | 43 #include "components/autofill/core/common/forms_seen_state.h" |
| 44 #include "components/user_prefs/user_prefs.h" | 44 #include "components/user_prefs/user_prefs.h" |
| 45 #include "content/public/test/mock_render_process_host.h" | 45 #include "content/public/test/mock_render_process_host.h" |
| 46 #include "content/public/test/test_utils.h" | 46 #include "content/public/test/test_utils.h" |
| 47 #include "grit/component_strings.h" | 47 #include "grit/component_strings.h" |
| 48 #include "testing/gmock/include/gmock/gmock.h" | 48 #include "testing/gmock/include/gmock/gmock.h" |
| 49 #include "testing/gtest/include/gtest/gtest.h" | 49 #include "testing/gtest/include/gtest/gtest.h" |
| 50 #include "third_party/WebKit/public/web/WebAutofillClient.h" | 50 #include "third_party/WebKit/public/web/WebAutofillClient.h" |
| 51 #include "third_party/WebKit/public/web/WebFormElement.h" | |
| 52 #include "ui/base/l10n/l10n_util.h" | 51 #include "ui/base/l10n/l10n_util.h" |
| 53 #include "ui/gfx/rect.h" | 52 #include "ui/gfx/rect.h" |
| 54 #include "url/gurl.h" | 53 #include "url/gurl.h" |
| 55 | 54 |
| 56 using base::ASCIIToUTF16; | 55 using base::ASCIIToUTF16; |
| 57 using base::UTF8ToUTF16; | 56 using base::UTF8ToUTF16; |
| 58 using content::WebContents; | 57 using content::WebContents; |
| 59 using blink::WebFormElement; | |
| 60 using testing::_; | 58 using testing::_; |
| 61 | 59 |
| 62 namespace autofill { | 60 namespace autofill { |
| 63 | 61 |
| 64 typedef PersonalDataManager::GUIDPair GUIDPair; | 62 typedef PersonalDataManager::GUIDPair GUIDPair; |
| 65 | 63 |
| 66 namespace { | 64 namespace { |
| 67 | 65 |
| 68 // The page ID sent to the AutofillManager from the RenderView, used to send | 66 // The page ID sent to the AutofillManager from the RenderView, used to send |
| 69 // an IPC message back to the renderer. | 67 // an IPC message back to the renderer. |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 personal_data_(personal_data), | 409 personal_data_(personal_data), |
| 412 autofill_enabled_(true) {} | 410 autofill_enabled_(true) {} |
| 413 virtual ~TestAutofillManager() {} | 411 virtual ~TestAutofillManager() {} |
| 414 | 412 |
| 415 virtual bool IsAutofillEnabled() const OVERRIDE { return autofill_enabled_; } | 413 virtual bool IsAutofillEnabled() const OVERRIDE { return autofill_enabled_; } |
| 416 | 414 |
| 417 void set_autofill_enabled(bool autofill_enabled) { | 415 void set_autofill_enabled(bool autofill_enabled) { |
| 418 autofill_enabled_ = autofill_enabled; | 416 autofill_enabled_ = autofill_enabled; |
| 419 } | 417 } |
| 420 | 418 |
| 421 const std::vector<std::pair<WebFormElement::AutocompleteResult, FormData> >& | |
| 422 request_autocomplete_results() const { | |
| 423 return request_autocomplete_results_; | |
| 424 } | |
| 425 | |
| 426 | |
| 427 void set_expected_submitted_field_types( | 419 void set_expected_submitted_field_types( |
| 428 const std::vector<ServerFieldTypeSet>& expected_types) { | 420 const std::vector<ServerFieldTypeSet>& expected_types) { |
| 429 expected_submitted_field_types_ = expected_types; | 421 expected_submitted_field_types_ = expected_types; |
| 430 } | 422 } |
| 431 | 423 |
| 432 virtual void UploadFormDataAsyncCallback( | 424 virtual void UploadFormDataAsyncCallback( |
| 433 const FormStructure* submitted_form, | 425 const FormStructure* submitted_form, |
| 434 const base::TimeTicks& load_time, | 426 const base::TimeTicks& load_time, |
| 435 const base::TimeTicks& interaction_time, | 427 const base::TimeTicks& interaction_time, |
| 436 const base::TimeTicks& submission_time) OVERRIDE { | 428 const base::TimeTicks& submission_time) OVERRIDE { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 | 504 |
| 513 void ClearFormStructures() { | 505 void ClearFormStructures() { |
| 514 form_structures()->clear(); | 506 form_structures()->clear(); |
| 515 } | 507 } |
| 516 | 508 |
| 517 private: | 509 private: |
| 518 // Weak reference. | 510 // Weak reference. |
| 519 TestPersonalDataManager* personal_data_; | 511 TestPersonalDataManager* personal_data_; |
| 520 | 512 |
| 521 bool autofill_enabled_; | 513 bool autofill_enabled_; |
| 522 std::vector<std::pair<WebFormElement::AutocompleteResult, FormData> > | |
| 523 request_autocomplete_results_; | |
| 524 | 514 |
| 525 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 515 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
| 526 | 516 |
| 527 std::string submitted_form_signature_; | 517 std::string submitted_form_signature_; |
| 528 std::vector<ServerFieldTypeSet> expected_submitted_field_types_; | 518 std::vector<ServerFieldTypeSet> expected_submitted_field_types_; |
| 529 | 519 |
| 530 DISALLOW_COPY_AND_ASSIGN(TestAutofillManager); | 520 DISALLOW_COPY_AND_ASSIGN(TestAutofillManager); |
| 531 }; | 521 }; |
| 532 | 522 |
| 533 class TestAutofillExternalDelegate : public AutofillExternalDelegate { | 523 class TestAutofillExternalDelegate : public AutofillExternalDelegate { |
| (...skipping 2389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2923 test::CreateTestAddressFormData(&form); | 2913 test::CreateTestAddressFormData(&form); |
| 2924 std::vector<FormData> forms(1, form); | 2914 std::vector<FormData> forms(1, form); |
| 2925 FormsSeen(forms); | 2915 FormsSeen(forms); |
| 2926 const FormFieldData& field = form.fields[0]; | 2916 const FormFieldData& field = form.fields[0]; |
| 2927 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() | 2917 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() |
| 2928 | 2918 |
| 2929 EXPECT_TRUE(external_delegate_->on_query_seen()); | 2919 EXPECT_TRUE(external_delegate_->on_query_seen()); |
| 2930 } | 2920 } |
| 2931 | 2921 |
| 2932 } // namespace autofill | 2922 } // namespace autofill |
| OLD | NEW |