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

Side by Side Diff: chrome/browser/ui/cocoa/autofill/autofill_section_container_unittest.mm

Issue 63053003: Ask libaddressinput for address components to use in requestAutocomplete(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: estade@ review Created 6 years, 11 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #import "chrome/browser/ui/cocoa/autofill/autofill_section_container.h" 5 #import "chrome/browser/ui/cocoa/autofill/autofill_section_container.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/mac/scoped_nsobject.h" 8 #include "base/mac/scoped_nsobject.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" 10 #include "chrome/browser/ui/autofill/autofill_dialog_models.h"
11 #include "chrome/browser/ui/autofill/mock_autofill_dialog_view_delegate.h" 11 #include "chrome/browser/ui/autofill/mock_autofill_dialog_view_delegate.h"
12 #import "chrome/browser/ui/cocoa/autofill/autofill_input_field.h" 12 #import "chrome/browser/ui/cocoa/autofill/autofill_input_field.h"
13 #import "chrome/browser/ui/cocoa/autofill/layout_view.h" 13 #import "chrome/browser/ui/cocoa/autofill/layout_view.h"
14 #import "chrome/browser/ui/cocoa/menu_button.h" 14 #import "chrome/browser/ui/cocoa/menu_button.h"
15 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "testing/gtest_mac.h" 17 #include "testing/gtest_mac.h"
18 #include "testing/platform_test.h" 18 #include "testing/platform_test.h"
19 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/models/combobox_model.h" 20 #include "ui/base/models/combobox_model.h"
20 #include "ui/base/models/simple_menu_model.h" 21 #include "ui/base/models/simple_menu_model.h"
21 #import "ui/base/test/ui_cocoa_test_helper.h" 22 #import "ui/base/test/ui_cocoa_test_helper.h"
22 23
23 using base::ASCIIToUTF16; 24 using base::ASCIIToUTF16;
24 25
25 namespace { 26 namespace {
26 27
27 class AutofillSectionContainerTest : public ui::CocoaTest { 28 class AutofillSectionContainerTest : public ui::CocoaTest {
28 public: 29 public:
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 EXPECT_NSEQ(@"Year", [yearPopup itemTitleAtIndex:0]); 115 EXPECT_NSEQ(@"Year", [yearPopup itemTitleAtIndex:0]);
115 }; 116 };
116 117
117 TEST_F(AutofillSectionContainerTest, OutputMatchesDefinition) { 118 TEST_F(AutofillSectionContainerTest, OutputMatchesDefinition) {
118 using namespace autofill; 119 using namespace autofill;
119 using namespace testing; 120 using namespace testing;
120 121
121 const DetailInput kTestInputs[] = { 122 const DetailInput kTestInputs[] = {
122 { DetailInput::LONG, 123 { DetailInput::LONG,
123 EMAIL_ADDRESS, 124 EMAIL_ADDRESS,
124 IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, 125 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL) },
groby-ooo-7-16 2014/01/04 01:15:33 Since the string constants are never used in the t
Dan Beam 2014/01/04 01:39:23 Done.
125 { DetailInput::SHORT, CREDIT_CARD_EXP_MONTH }, 126 { DetailInput::SHORT, CREDIT_CARD_EXP_MONTH },
126 }; 127 };
127 autofill::MonthComboboxModel comboModel; 128 autofill::MonthComboboxModel comboModel;
128 DetailInputs inputs; 129 DetailInputs inputs;
129 inputs.push_back(kTestInputs[0]); 130 inputs.push_back(kTestInputs[0]);
130 inputs.push_back(kTestInputs[1]); 131 inputs.push_back(kTestInputs[1]);
131 132
132 EXPECT_CALL(delegate_, RequestedFieldsForSection(section_)) 133 EXPECT_CALL(delegate_, RequestedFieldsForSection(section_))
133 .WillOnce(ReturnRef(inputs)); 134 .WillOnce(ReturnRef(inputs));
134 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(EMAIL_ADDRESS)) 135 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(EMAIL_ADDRESS))
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 EXPECT_NSEQ(@"b", [[menu itemAtIndex:2] title]); 180 EXPECT_NSEQ(@"b", [[menu itemAtIndex:2] title]);
180 } 181 }
181 182
182 TEST_F(AutofillSectionContainerTest, FieldsAreInitiallyValid) { 183 TEST_F(AutofillSectionContainerTest, FieldsAreInitiallyValid) {
183 using namespace autofill; 184 using namespace autofill;
184 using namespace testing; 185 using namespace testing;
185 186
186 const DetailInput kTestInputs[] = { 187 const DetailInput kTestInputs[] = {
187 { DetailInput::LONG, 188 { DetailInput::LONG,
188 EMAIL_ADDRESS, 189 EMAIL_ADDRESS,
189 IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, 190 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL) },
190 { DetailInput::SHORT, CREDIT_CARD_EXP_MONTH }, 191 { DetailInput::SHORT, CREDIT_CARD_EXP_MONTH },
191 }; 192 };
192 193
193 MonthComboboxModel comboModel; 194 MonthComboboxModel comboModel;
194 DetailInputs inputs; 195 DetailInputs inputs;
195 inputs.push_back(kTestInputs[0]); 196 inputs.push_back(kTestInputs[0]);
196 inputs.push_back(kTestInputs[1]); 197 inputs.push_back(kTestInputs[1]);
197 198
198 EXPECT_CALL(delegate_, RequestedFieldsForSection(section_)) 199 EXPECT_CALL(delegate_, RequestedFieldsForSection(section_))
199 .WillOnce(ReturnRef(inputs)); 200 .WillOnce(ReturnRef(inputs));
200 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(EMAIL_ADDRESS)) 201 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(EMAIL_ADDRESS))
201 .WillRepeatedly(ReturnNull()); 202 .WillRepeatedly(ReturnNull());
202 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH)) 203 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH))
203 .WillRepeatedly(Return(&comboModel)); 204 .WillRepeatedly(Return(&comboModel));
204 205
205 ResetContainer(); 206 ResetContainer();
206 NSControl<AutofillInputField>* field = [container_ getField:EMAIL_ADDRESS]; 207 NSControl<AutofillInputField>* field = [container_ getField:EMAIL_ADDRESS];
207 EXPECT_FALSE([field invalid]); 208 EXPECT_FALSE([field invalid]);
208 field = [container_ getField:CREDIT_CARD_EXP_MONTH]; 209 field = [container_ getField:CREDIT_CARD_EXP_MONTH];
209 EXPECT_FALSE([field invalid]); 210 EXPECT_FALSE([field invalid]);
210 } 211 }
211 212
212 TEST_F(AutofillSectionContainerTest, ControllerInformsValidity) { 213 TEST_F(AutofillSectionContainerTest, ControllerInformsValidity) {
213 using namespace autofill; 214 using namespace autofill;
214 using namespace testing; 215 using namespace testing;
215 216
216 const DetailInput kTestInputs[] = { 217 const DetailInput kTestInputs[] = {
217 { DetailInput::LONG, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, 218 { DetailInput::LONG,
219 EMAIL_ADDRESS,
220 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL) },
218 { DetailInput::SHORT, CREDIT_CARD_EXP_MONTH } 221 { DetailInput::SHORT, CREDIT_CARD_EXP_MONTH }
219 }; 222 };
220 223
221 MonthComboboxModel comboModel; 224 MonthComboboxModel comboModel;
222 DetailInputs inputs; 225 DetailInputs inputs;
223 inputs.push_back(kTestInputs[0]); 226 inputs.push_back(kTestInputs[0]);
224 inputs.push_back(kTestInputs[1]); 227 inputs.push_back(kTestInputs[1]);
225 228
226 ValidityMessages validity, validity2; 229 ValidityMessages validity, validity2;
227 230
(...skipping 20 matching lines...) Expand all
248 EXPECT_TRUE([field invalid]); 251 EXPECT_TRUE([field invalid]);
249 field = [container_ getField:CREDIT_CARD_EXP_MONTH]; 252 field = [container_ getField:CREDIT_CARD_EXP_MONTH];
250 EXPECT_FALSE([field invalid]); 253 EXPECT_FALSE([field invalid]);
251 254
252 [container_ validateFor:VALIDATE_FINAL]; 255 [container_ validateFor:VALIDATE_FINAL];
253 field = [container_ getField:EMAIL_ADDRESS]; 256 field = [container_ getField:EMAIL_ADDRESS];
254 EXPECT_FALSE([field invalid]); 257 EXPECT_FALSE([field invalid]);
255 field = [container_ getField:CREDIT_CARD_EXP_MONTH]; 258 field = [container_ getField:CREDIT_CARD_EXP_MONTH];
256 EXPECT_TRUE([field invalid]); 259 EXPECT_TRUE([field invalid]);
257 } 260 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698