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 profile_->CreateWebDataService(); |
58 | 59 |
59 autofill_test::DisableSystemServices(profile_.get()); | 60 autofill_test::DisableSystemServices(profile_.get()); |
60 ResetPersonalDataManager(); | 61 ResetPersonalDataManager(); |
61 } | 62 } |
62 | 63 |
63 virtual void TearDown() { | 64 virtual void TearDown() { |
64 // Destruction order is imposed explicitly here. | 65 // Destruction order is imposed explicitly here. |
65 personal_data_.reset(NULL); | 66 personal_data_.reset(NULL); |
66 profile_.reset(NULL); | 67 profile_.reset(NULL); |
67 | 68 |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 AutofillProfile profile2; | 432 AutofillProfile profile2; |
432 autofill_test::SetProfileInfo(&profile2, | 433 autofill_test::SetProfileInfo(&profile2, |
433 "Josephine", "Alicia", "Saenz", | 434 "Josephine", "Alicia", "Saenz", |
434 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", | 435 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", |
435 "32801", "US", "19482937549"); | 436 "32801", "US", "19482937549"); |
436 | 437 |
437 // Adjust all labels. | 438 // Adjust all labels. |
438 profile_pointers.push_back(&profile2); | 439 profile_pointers.push_back(&profile2); |
439 AutofillProfile::AdjustInferredLabels(&profile_pointers); | 440 AutofillProfile::AdjustInferredLabels(&profile_pointers); |
440 | 441 |
441 WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); | 442 scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile( |
442 ASSERT_TRUE(wds); | 443 profile_.get(), Profile::EXPLICIT_ACCESS); |
| 444 ASSERT_TRUE(wds.get()); |
443 wds->AddAutofillProfile(profile2); | 445 wds->AddAutofillProfile(profile2); |
444 | 446 |
445 personal_data_->Refresh(); | 447 personal_data_->Refresh(); |
446 | 448 |
447 // Verify that the web database has been updated and the notification sent. | 449 // Verify that the web database has been updated and the notification sent. |
448 EXPECT_CALL(personal_data_observer_, | 450 EXPECT_CALL(personal_data_observer_, |
449 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 451 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
450 MessageLoop::current()->Run(); | 452 MessageLoop::current()->Run(); |
451 | 453 |
452 const std::vector<AutofillProfile*>& results2 = personal_data_->profiles(); | 454 const std::vector<AutofillProfile*>& results2 = personal_data_->profiles(); |
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 | 1951 |
1950 // Modify expected to include multi-valued fields. | 1952 // Modify expected to include multi-valued fields. |
1951 std::vector<string16> values; | 1953 std::vector<string16> values; |
1952 expected.GetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, &values); | 1954 expected.GetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, &values); |
1953 values.push_back(ASCIIToUTF16("214-555-1234")); | 1955 values.push_back(ASCIIToUTF16("214-555-1234")); |
1954 expected.SetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, values); | 1956 expected.SetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, values); |
1955 | 1957 |
1956 ASSERT_EQ(1U, results2.size()); | 1958 ASSERT_EQ(1U, results2.size()); |
1957 EXPECT_EQ(0, expected.Compare(*results2[0])); | 1959 EXPECT_EQ(0, expected.Compare(*results2[0])); |
1958 } | 1960 } |
OLD | NEW |