| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 "ui/base/l10n/l10n_util.h" | 51 #include "ui/base/l10n/l10n_util.h" |
| 52 #include "ui/gfx/rect.h" | 52 #include "ui/gfx/rect.h" |
| 53 #include "url/gurl.h" | 53 #include "url/gurl.h" |
| 54 | 54 |
| 55 using base::ASCIIToUTF16; |
| 56 using base::UTF8ToUTF16; |
| 55 using content::WebContents; | 57 using content::WebContents; |
| 58 using blink::WebFormElement; |
| 56 using testing::_; | 59 using testing::_; |
| 57 using blink::WebFormElement; | |
| 58 | 60 |
| 59 namespace autofill { | 61 namespace autofill { |
| 60 | 62 |
| 61 typedef PersonalDataManager::GUIDPair GUIDPair; | 63 typedef PersonalDataManager::GUIDPair GUIDPair; |
| 62 | 64 |
| 63 namespace { | 65 namespace { |
| 64 | 66 |
| 65 // The page ID sent to the AutofillManager from the RenderView, used to send | 67 // The page ID sent to the AutofillManager from the RenderView, used to send |
| 66 // an IPC message back to the renderer. | 68 // an IPC message back to the renderer. |
| 67 const int kDefaultPageID = 137; | 69 const int kDefaultPageID = 137; |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 message_loop_runner_->Quit(); | 436 message_loop_runner_->Quit(); |
| 435 | 437 |
| 436 // If we have expected field types set, make sure they match. | 438 // If we have expected field types set, make sure they match. |
| 437 if (!expected_submitted_field_types_.empty()) { | 439 if (!expected_submitted_field_types_.empty()) { |
| 438 ASSERT_EQ(expected_submitted_field_types_.size(), | 440 ASSERT_EQ(expected_submitted_field_types_.size(), |
| 439 submitted_form->field_count()); | 441 submitted_form->field_count()); |
| 440 for (size_t i = 0; i < expected_submitted_field_types_.size(); ++i) { | 442 for (size_t i = 0; i < expected_submitted_field_types_.size(); ++i) { |
| 441 SCOPED_TRACE( | 443 SCOPED_TRACE( |
| 442 base::StringPrintf( | 444 base::StringPrintf( |
| 443 "Field %d with value %s", static_cast<int>(i), | 445 "Field %d with value %s", static_cast<int>(i), |
| 444 UTF16ToUTF8(submitted_form->field(i)->value).c_str())); | 446 base::UTF16ToUTF8(submitted_form->field(i)->value).c_str())); |
| 445 const ServerFieldTypeSet& possible_types = | 447 const ServerFieldTypeSet& possible_types = |
| 446 submitted_form->field(i)->possible_types(); | 448 submitted_form->field(i)->possible_types(); |
| 447 EXPECT_EQ(expected_submitted_field_types_[i].size(), | 449 EXPECT_EQ(expected_submitted_field_types_[i].size(), |
| 448 possible_types.size()); | 450 possible_types.size()); |
| 449 for (ServerFieldTypeSet::const_iterator it = | 451 for (ServerFieldTypeSet::const_iterator it = |
| 450 expected_submitted_field_types_[i].begin(); | 452 expected_submitted_field_types_[i].begin(); |
| 451 it != expected_submitted_field_types_[i].end(); ++it) { | 453 it != expected_submitted_field_types_[i].end(); ++it) { |
| 452 EXPECT_TRUE(possible_types.count(*it)) | 454 EXPECT_TRUE(possible_types.count(*it)) |
| 453 << "Expected type: " << AutofillType(*it).ToString(); | 455 << "Expected type: " << AutofillType(*it).ToString(); |
| 454 } | 456 } |
| (...skipping 2465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2920 test::CreateTestAddressFormData(&form); | 2922 test::CreateTestAddressFormData(&form); |
| 2921 std::vector<FormData> forms(1, form); | 2923 std::vector<FormData> forms(1, form); |
| 2922 FormsSeen(forms); | 2924 FormsSeen(forms); |
| 2923 const FormFieldData& field = form.fields[0]; | 2925 const FormFieldData& field = form.fields[0]; |
| 2924 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() | 2926 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() |
| 2925 | 2927 |
| 2926 EXPECT_TRUE(external_delegate_->on_query_seen()); | 2928 EXPECT_TRUE(external_delegate_->on_query_seen()); |
| 2927 } | 2929 } |
| 2928 | 2930 |
| 2929 } // namespace autofill | 2931 } // namespace autofill |
| OLD | NEW |