| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/guid.h" | 9 #include "base/guid.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 29 |
| 30 using base::ASCIIToUTF16; | 30 using base::ASCIIToUTF16; |
| 31 | 31 |
| 32 namespace autofill { | 32 namespace autofill { |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 enum UserMode { USER_MODE_NORMAL, USER_MODE_INCOGNITO }; | 35 enum UserMode { USER_MODE_NORMAL, USER_MODE_INCOGNITO }; |
| 36 | 36 |
| 37 bool ReturnTrue(const AutofillProfile&) { return true; } |
| 38 |
| 37 ACTION(QuitMainMessageLoop) { base::MessageLoop::current()->Quit(); } | 39 ACTION(QuitMainMessageLoop) { base::MessageLoop::current()->Quit(); } |
| 38 | 40 |
| 39 class PersonalDataLoadedObserverMock : public PersonalDataManagerObserver { | 41 class PersonalDataLoadedObserverMock : public PersonalDataManagerObserver { |
| 40 public: | 42 public: |
| 41 PersonalDataLoadedObserverMock() {} | 43 PersonalDataLoadedObserverMock() {} |
| 42 virtual ~PersonalDataLoadedObserverMock() {} | 44 virtual ~PersonalDataLoadedObserverMock() {} |
| 43 | 45 |
| 44 MOCK_METHOD0(OnPersonalDataChanged, void()); | 46 MOCK_METHOD0(OnPersonalDataChanged, void()); |
| 45 }; | 47 }; |
| 46 | 48 |
| (...skipping 2510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2557 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) | 2559 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) |
| 2558 .WillOnce(QuitMainMessageLoop()); | 2560 .WillOnce(QuitMainMessageLoop()); |
| 2559 base::MessageLoop::current()->Run(); | 2561 base::MessageLoop::current()->Run(); |
| 2560 | 2562 |
| 2561 const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles(); | 2563 const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles(); |
| 2562 ASSERT_EQ(1U, results.size()); | 2564 ASSERT_EQ(1U, results.size()); |
| 2563 EXPECT_EQ(0, profile.Compare(*results[0])); | 2565 EXPECT_EQ(0, profile.Compare(*results[0])); |
| 2564 EXPECT_EQ("en", results[0]->language_code()); | 2566 EXPECT_EQ("en", results[0]->language_code()); |
| 2565 } | 2567 } |
| 2566 | 2568 |
| 2569 TEST_F(PersonalDataManagerTest, GetProfileSuggestions) { |
| 2570 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com"); |
| 2571 test::SetProfileInfo(&profile, |
| 2572 "Marion", "Mitchell", "Morrison", |
| 2573 "johnwayne@me.xyz", "Fox", |
| 2574 "123 Zoo St.\nSecond Line\nThird line", "unit 5", "Hollywood", "CA", |
| 2575 "91601", "US", "12345678910"); |
| 2576 personal_data_->AddProfile(profile); |
| 2577 ResetPersonalDataManager(USER_MODE_NORMAL); |
| 2578 |
| 2579 std::vector<base::string16> values; |
| 2580 std::vector<base::string16> labels; |
| 2581 std::vector<base::string16> icons; |
| 2582 std::vector<PersonalDataManager::GUIDPair> guid_pairs; |
| 2583 personal_data_->GetProfileSuggestions( |
| 2584 AutofillType(ADDRESS_HOME_STREET_ADDRESS), |
| 2585 base::UTF8ToUTF16("123"), |
| 2586 false, |
| 2587 std::vector<ServerFieldType>(), |
| 2588 base::Bind(ReturnTrue), |
| 2589 &values, |
| 2590 &labels, |
| 2591 &icons, |
| 2592 &guid_pairs); |
| 2593 ASSERT_FALSE(values.empty()); |
| 2594 EXPECT_EQ(values[0], |
| 2595 base::UTF8ToUTF16("123 Zoo St., Second Line, Third line, unit 5")); |
| 2596 } |
| 2597 |
| 2567 } // namespace autofill | 2598 } // namespace autofill |
| OLD | NEW |