Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1104)

Side by Side Diff: chrome/browser/ui/autofill/data_model_wrapper_unittest.cc

Issue 25092011: rAc: update android test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git try Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/strings/string_number_conversions.h" 6 #include "base/strings/string_number_conversions.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" 8 #include "chrome/browser/ui/autofill/autofill_dialog_models.h"
9 #include "chrome/browser/ui/autofill/data_model_wrapper.h" 9 #include "chrome/browser/ui/autofill/data_model_wrapper.h"
10 #include "components/autofill/content/browser/wallet/wallet_items.h" 10 #include "components/autofill/content/browser/wallet/wallet_items.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 ASSERT_TRUE( 96 ASSERT_TRUE(
97 instrument_wrapper.GetInfo( 97 instrument_wrapper.GetInfo(
98 AutofillType(PHONE_HOME_WHOLE_NUMBER)).empty()); 98 AutofillType(PHONE_HOME_WHOLE_NUMBER)).empty());
99 EXPECT_FALSE(instrument_wrapper.GetDisplayText(&unused, &unused2)); 99 EXPECT_FALSE(instrument_wrapper.GetDisplayText(&unused, &unused2));
100 100
101 ASSERT_TRUE( 101 ASSERT_TRUE(
102 address_wrapper.GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER)).empty()); 102 address_wrapper.GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER)).empty());
103 EXPECT_FALSE(address_wrapper.GetDisplayText(&unused, &unused2)); 103 EXPECT_FALSE(address_wrapper.GetDisplayText(&unused, &unused2));
104 } 104 }
105 105
106 TEST(DataModelWrapperTest, GetDisplayPhoneNumber) {
107 const base::string16 national_unformatted = ASCIIToUTF16("3104567890");
108 const base::string16 national_formatted = ASCIIToUTF16("(310) 456-7890");
109 const base::string16 international_unformatted = ASCIIToUTF16("13104567890");
110 const base::string16 international_formatted =
111 ASCIIToUTF16("+1 310-456-7890");
112 const base::string16 user_formatted = ASCIIToUTF16("310.456 78 90");
113
114 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument(
115 wallet::GetTestMaskedInstrument());
116 AutofillProfile profile(test::GetVerifiedProfile());
117
118 // No matter what format a wallet number is in, it gets formatted in a
119 // standard way.
120 WalletInstrumentWrapper instrument_wrapper(instrument.get());
121 const_cast<wallet::Address*>(&instrument->address())->
122 set_phone_number(national_unformatted);
123 EXPECT_EQ(national_formatted,
124 instrument_wrapper.GetInfoForDisplay(
125 AutofillType(PHONE_HOME_WHOLE_NUMBER)));
126 WalletAddressWrapper address_wrapper(&instrument->address());
127 EXPECT_EQ(national_formatted,
128 address_wrapper.GetInfoForDisplay(
129 AutofillType(PHONE_HOME_WHOLE_NUMBER)));
130 AutofillProfileWrapper profile_wrapper(&profile);
131
132 const_cast<wallet::Address*>(&instrument->address())->
133 set_phone_number(national_formatted);
134 EXPECT_EQ(national_formatted,
135 instrument_wrapper.GetInfoForDisplay(
136 AutofillType(PHONE_HOME_WHOLE_NUMBER)));
137 EXPECT_EQ(national_formatted,
138 address_wrapper.GetInfoForDisplay(
139 AutofillType(PHONE_HOME_WHOLE_NUMBER)));
140
141 const_cast<wallet::Address*>(&instrument->address())->
142 set_phone_number(international_unformatted);
143 EXPECT_EQ(national_formatted,
144 instrument_wrapper.GetInfoForDisplay(
145 AutofillType(PHONE_HOME_WHOLE_NUMBER)));
146 EXPECT_EQ(national_formatted,
147 address_wrapper.GetInfoForDisplay(
148 AutofillType(PHONE_HOME_WHOLE_NUMBER)));
149
150 // Autofill numbers that are unformatted get formatted either nationally or
151 // internationally depending on the presence of a country code. Formatted
152 // numbers stay formatted.
153 profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, international_unformatted);
154 EXPECT_EQ(international_formatted,
155 profile_wrapper.GetInfoForDisplay(
156 AutofillType(PHONE_HOME_WHOLE_NUMBER)));
157 profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, national_unformatted);
158 EXPECT_EQ(national_formatted,
159 profile_wrapper.GetInfoForDisplay(
160 AutofillType(PHONE_HOME_WHOLE_NUMBER)));
161 profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, national_formatted);
162 EXPECT_EQ(national_formatted,
163 profile_wrapper.GetInfoForDisplay(
164 AutofillType(PHONE_HOME_WHOLE_NUMBER)));
165 profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, user_formatted);
166 EXPECT_EQ(user_formatted,
167 profile_wrapper.GetInfoForDisplay(
168 AutofillType(PHONE_HOME_WHOLE_NUMBER)));
169
170 }
171
106 } // namespace autofill 172 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698