OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 break; | 45 break; |
46 } | 46 } |
47 case AutofillChange::REMOVE: { | 47 case AutofillChange::REMOVE: { |
48 os << "REMOVE"; | 48 os << "REMOVE"; |
49 break; | 49 break; |
50 } | 50 } |
51 } | 51 } |
52 return os << " " << change.key(); | 52 return os << " " << change.key(); |
53 } | 53 } |
54 | 54 |
55 // So we can compare AutoFillProfiles with EXPECT_EQ(). | |
56 std::ostream& operator<<(std::ostream& os, const AutoFillProfile& profile) { | |
57 return os | |
58 << UTF16ToASCII(profile.Label()) | |
59 << " " | |
60 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(NAME_FIRST))) | |
61 << " " | |
62 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(NAME_MIDDLE))) | |
63 << " " | |
64 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(NAME_LAST))) | |
65 << " " | |
66 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(EMAIL_ADDRESS))) | |
67 << " " | |
68 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(COMPANY_NAME))) | |
69 << " " | |
70 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_LINE1))) | |
71 << " " | |
72 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_LINE2))) | |
73 << " " | |
74 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_CITY))) | |
75 << " " | |
76 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_STATE))) | |
77 << " " | |
78 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_ZIP))) | |
79 << " " | |
80 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_COUNTRY))) | |
81 << " " | |
82 << UTF16ToUTF8(profile.GetFieldText(AutoFillType( | |
83 PHONE_HOME_WHOLE_NUMBER))) | |
84 << " " | |
85 << UTF16ToUTF8(profile.GetFieldText(AutoFillType( | |
86 PHONE_FAX_WHOLE_NUMBER))); | |
87 } | |
88 | |
89 class WebDatabaseTest : public testing::Test { | 55 class WebDatabaseTest : public testing::Test { |
90 protected: | 56 protected: |
91 typedef std::vector<AutofillChange> AutofillChangeList; | 57 typedef std::vector<AutofillChange> AutofillChangeList; |
92 virtual void SetUp() { | 58 virtual void SetUp() { |
93 PathService::Get(chrome::DIR_TEST_DATA, &file_); | 59 PathService::Get(chrome::DIR_TEST_DATA, &file_); |
94 const std::string test_db = "TestWebDatabase" + | 60 const std::string test_db = "TestWebDatabase" + |
95 Int64ToString(base::Time::Now().ToInternalValue()) + | 61 Int64ToString(base::Time::Now().ToInternalValue()) + |
96 ".db"; | 62 ".db"; |
97 file_ = file_.AppendASCII(test_db); | 63 file_ = file_.AppendASCII(test_db); |
98 file_util::Delete(file_, false); | 64 file_util::Delete(file_, false); |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 | 922 |
957 // Update the 'Billing' profile. | 923 // Update the 'Billing' profile. |
958 billing_profile.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("Jane")); | 924 billing_profile.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("Jane")); |
959 EXPECT_TRUE(db.UpdateAutoFillProfile(billing_profile)); | 925 EXPECT_TRUE(db.UpdateAutoFillProfile(billing_profile)); |
960 EXPECT_TRUE(db.GetAutoFillProfileForLabel(ASCIIToUTF16("Billing"), | 926 EXPECT_TRUE(db.GetAutoFillProfileForLabel(ASCIIToUTF16("Billing"), |
961 &db_profile)); | 927 &db_profile)); |
962 EXPECT_EQ(billing_profile, *db_profile); | 928 EXPECT_EQ(billing_profile, *db_profile); |
963 delete db_profile; | 929 delete db_profile; |
964 | 930 |
965 // Remove the 'Billing' profile. | 931 // Remove the 'Billing' profile. |
966 EXPECT_TRUE(db.RemoveAutoFillProfile(billing_profile)); | 932 EXPECT_TRUE(db.RemoveAutoFillProfile(billing_profile.unique_id())); |
967 EXPECT_FALSE(db.GetAutoFillProfileForLabel(ASCIIToUTF16("Billing"), | 933 EXPECT_FALSE(db.GetAutoFillProfileForLabel(ASCIIToUTF16("Billing"), |
968 &db_profile)); | 934 &db_profile)); |
969 } | 935 } |
OLD | NEW |