| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/autofill/autofill_common_test.h" | 11 #include "chrome/browser/autofill/autofill_common_test.h" |
| 12 #include "chrome/browser/autofill/autofill_profile.h" | 12 #include "chrome/browser/autofill/autofill_profile.h" |
| 13 #include "chrome/browser/autofill/form_structure.h" | 13 #include "chrome/browser/autofill/form_structure.h" |
| 14 #include "chrome/browser/autofill/personal_data_manager.h" | 14 #include "chrome/browser/autofill/personal_data_manager.h" |
| 15 #include "chrome/browser/autofill/personal_data_manager_observer.h" | 15 #include "chrome/browser/autofill/personal_data_manager_observer.h" |
| 16 #include "chrome/browser/password_manager/encryptor.h" | 16 #include "chrome/browser/password_manager/encryptor.h" |
| 17 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 17 #include "chrome/common/guid.h" | 18 #include "chrome/common/guid.h" |
| 18 #include "chrome/test/base/testing_browser_process.h" | 19 #include "chrome/test/base/testing_browser_process.h" |
| 19 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 20 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
| 21 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
| 22 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
| 23 #include "content/public/browser/notification_types.h" | 24 #include "content/public/browser/notification_types.h" |
| 24 #include "content/test/notification_observer_mock.h" | 25 #include "content/test/notification_observer_mock.h" |
| 25 #include "content/test/test_browser_thread.h" | 26 #include "content/test/test_browser_thread.h" |
| 26 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 47 protected: | 48 protected: |
| 48 PersonalDataManagerTest() | 49 PersonalDataManagerTest() |
| 49 : ui_thread_(BrowserThread::UI, &message_loop_), | 50 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 50 db_thread_(BrowserThread::DB) { | 51 db_thread_(BrowserThread::DB) { |
| 51 } | 52 } |
| 52 | 53 |
| 53 virtual void SetUp() { | 54 virtual void SetUp() { |
| 54 db_thread_.Start(); | 55 db_thread_.Start(); |
| 55 | 56 |
| 56 profile_.reset(new TestingProfile); | 57 profile_.reset(new TestingProfile); |
| 57 profile_->CreateWebDataService(false); | |
| 58 | 58 |
| 59 autofill_test::DisableSystemServices(profile_.get()); | 59 autofill_test::DisableSystemServices(profile_.get()); |
| 60 ResetPersonalDataManager(); | 60 ResetPersonalDataManager(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 virtual void TearDown() { | 63 virtual void TearDown() { |
| 64 // Destruction order is imposed explicitly here. | 64 // Destruction order is imposed explicitly here. |
| 65 personal_data_.reset(NULL); | 65 personal_data_.reset(NULL); |
| 66 profile_.reset(NULL); | 66 profile_.reset(NULL); |
| 67 | 67 |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 AutofillProfile profile2; | 431 AutofillProfile profile2; |
| 432 autofill_test::SetProfileInfo(&profile2, | 432 autofill_test::SetProfileInfo(&profile2, |
| 433 "Josephine", "Alicia", "Saenz", | 433 "Josephine", "Alicia", "Saenz", |
| 434 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", | 434 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", |
| 435 "32801", "US", "19482937549"); | 435 "32801", "US", "19482937549"); |
| 436 | 436 |
| 437 // Adjust all labels. | 437 // Adjust all labels. |
| 438 profile_pointers.push_back(&profile2); | 438 profile_pointers.push_back(&profile2); |
| 439 AutofillProfile::AdjustInferredLabels(&profile_pointers); | 439 AutofillProfile::AdjustInferredLabels(&profile_pointers); |
| 440 | 440 |
| 441 WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); | 441 scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile( |
| 442 ASSERT_TRUE(wds); | 442 profile_.get(), Profile::EXPLICIT_ACCESS); |
| 443 ASSERT_TRUE(wds.get()); |
| 443 wds->AddAutofillProfile(profile2); | 444 wds->AddAutofillProfile(profile2); |
| 444 | 445 |
| 445 personal_data_->Refresh(); | 446 personal_data_->Refresh(); |
| 446 | 447 |
| 447 // Verify that the web database has been updated and the notification sent. | 448 // Verify that the web database has been updated and the notification sent. |
| 448 EXPECT_CALL(personal_data_observer_, | 449 EXPECT_CALL(personal_data_observer_, |
| 449 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 450 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 450 MessageLoop::current()->Run(); | 451 MessageLoop::current()->Run(); |
| 451 | 452 |
| 452 const std::vector<AutofillProfile*>& results2 = personal_data_->profiles(); | 453 const std::vector<AutofillProfile*>& results2 = personal_data_->profiles(); |
| (...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1949 | 1950 |
| 1950 // Modify expected to include multi-valued fields. | 1951 // Modify expected to include multi-valued fields. |
| 1951 std::vector<string16> values; | 1952 std::vector<string16> values; |
| 1952 expected.GetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, &values); | 1953 expected.GetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, &values); |
| 1953 values.push_back(ASCIIToUTF16("214-555-1234")); | 1954 values.push_back(ASCIIToUTF16("214-555-1234")); |
| 1954 expected.SetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, values); | 1955 expected.SetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, values); |
| 1955 | 1956 |
| 1956 ASSERT_EQ(1U, results2.size()); | 1957 ASSERT_EQ(1U, results2.size()); |
| 1957 EXPECT_EQ(0, expected.Compare(*results2[0])); | 1958 EXPECT_EQ(0, expected.Compare(*results2[0])); |
| 1958 } | 1959 } |
| OLD | NEW |