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

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: let's try this again, android Created 7 years 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 namespace { 24 namespace {
24 25
25 class AutofillSectionContainerTest : public ui::CocoaTest { 26 class AutofillSectionContainerTest : public ui::CocoaTest {
26 public: 27 public:
27 AutofillSectionContainerTest() : section_(autofill::SECTION_BILLING) {} 28 AutofillSectionContainerTest() : section_(autofill::SECTION_BILLING) {}
28 virtual void SetUp() { 29 virtual void SetUp() {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 [container_ getField:CREDIT_CARD_EXP_4_DIGIT_YEAR]); 111 [container_ getField:CREDIT_CARD_EXP_4_DIGIT_YEAR]);
111 EXPECT_EQ(11, [yearPopup numberOfItems]); 112 EXPECT_EQ(11, [yearPopup numberOfItems]);
112 EXPECT_NSEQ(@"Year", [yearPopup itemTitleAtIndex:0]); 113 EXPECT_NSEQ(@"Year", [yearPopup itemTitleAtIndex:0]);
113 }; 114 };
114 115
115 TEST_F(AutofillSectionContainerTest, OutputMatchesDefinition) { 116 TEST_F(AutofillSectionContainerTest, OutputMatchesDefinition) {
116 using namespace autofill; 117 using namespace autofill;
117 using namespace testing; 118 using namespace testing;
118 119
119 const DetailInput kTestInputs[] = { 120 const DetailInput kTestInputs[] = {
120 { 1, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, 121 { 1, EMAIL_ADDRESS,
122 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL) },
121 { 2, CREDIT_CARD_EXP_MONTH } 123 { 2, CREDIT_CARD_EXP_MONTH }
122 }; 124 };
123 autofill::MonthComboboxModel comboModel; 125 autofill::MonthComboboxModel comboModel;
124 DetailInputs inputs; 126 DetailInputs inputs;
125 inputs.push_back(kTestInputs[0]); 127 inputs.push_back(kTestInputs[0]);
126 inputs.push_back(kTestInputs[1]); 128 inputs.push_back(kTestInputs[1]);
127 129
128 EXPECT_CALL(delegate_, RequestedFieldsForSection(section_)) 130 EXPECT_CALL(delegate_, RequestedFieldsForSection(section_))
129 .WillOnce(ReturnRef(inputs)); 131 .WillOnce(ReturnRef(inputs));
130 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(EMAIL_ADDRESS)) 132 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(EMAIL_ADDRESS))
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 175
174 EXPECT_NSEQ(@"a", [[menu itemAtIndex:1] title]); 176 EXPECT_NSEQ(@"a", [[menu itemAtIndex:1] title]);
175 EXPECT_NSEQ(@"b", [[menu itemAtIndex:2] title]); 177 EXPECT_NSEQ(@"b", [[menu itemAtIndex:2] title]);
176 } 178 }
177 179
178 TEST_F(AutofillSectionContainerTest, FieldsAreInitiallyValid) { 180 TEST_F(AutofillSectionContainerTest, FieldsAreInitiallyValid) {
179 using namespace autofill; 181 using namespace autofill;
180 using namespace testing; 182 using namespace testing;
181 183
182 const DetailInput kTestInputs[] = { 184 const DetailInput kTestInputs[] = {
183 { 1, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, 185 { 1, EMAIL_ADDRESS,
186 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL) },
184 { 2, CREDIT_CARD_EXP_MONTH } 187 { 2, CREDIT_CARD_EXP_MONTH }
185 }; 188 };
186 189
187 MonthComboboxModel comboModel; 190 MonthComboboxModel comboModel;
188 DetailInputs inputs; 191 DetailInputs inputs;
189 inputs.push_back(kTestInputs[0]); 192 inputs.push_back(kTestInputs[0]);
190 inputs.push_back(kTestInputs[1]); 193 inputs.push_back(kTestInputs[1]);
191 194
192 EXPECT_CALL(delegate_, RequestedFieldsForSection(section_)) 195 EXPECT_CALL(delegate_, RequestedFieldsForSection(section_))
193 .WillOnce(ReturnRef(inputs)); 196 .WillOnce(ReturnRef(inputs));
194 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(EMAIL_ADDRESS)) 197 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(EMAIL_ADDRESS))
195 .WillRepeatedly(ReturnNull()); 198 .WillRepeatedly(ReturnNull());
196 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH)) 199 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH))
197 .WillRepeatedly(Return(&comboModel)); 200 .WillRepeatedly(Return(&comboModel));
198 201
199 ResetContainer(); 202 ResetContainer();
200 NSControl<AutofillInputField>* field = [container_ getField:EMAIL_ADDRESS]; 203 NSControl<AutofillInputField>* field = [container_ getField:EMAIL_ADDRESS];
201 EXPECT_FALSE([field invalid]); 204 EXPECT_FALSE([field invalid]);
202 field = [container_ getField:CREDIT_CARD_EXP_MONTH]; 205 field = [container_ getField:CREDIT_CARD_EXP_MONTH];
203 EXPECT_FALSE([field invalid]); 206 EXPECT_FALSE([field invalid]);
204 } 207 }
205 208
206 TEST_F(AutofillSectionContainerTest, ControllerInformsValidity) { 209 TEST_F(AutofillSectionContainerTest, ControllerInformsValidity) {
207 using namespace autofill; 210 using namespace autofill;
208 using namespace testing; 211 using namespace testing;
209 212
210 const DetailInput kTestInputs[] = { 213 const DetailInput kTestInputs[] = {
211 { 1, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, 214 { 1, EMAIL_ADDRESS,
215 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL) },
212 { 2, CREDIT_CARD_EXP_MONTH } 216 { 2, CREDIT_CARD_EXP_MONTH }
213 }; 217 };
214 218
215 MonthComboboxModel comboModel; 219 MonthComboboxModel comboModel;
216 DetailInputs inputs; 220 DetailInputs inputs;
217 inputs.push_back(kTestInputs[0]); 221 inputs.push_back(kTestInputs[0]);
218 inputs.push_back(kTestInputs[1]); 222 inputs.push_back(kTestInputs[1]);
219 223
220 ValidityMessages validity, validity2; 224 ValidityMessages validity, validity2;
221 225
(...skipping 20 matching lines...) Expand all
242 EXPECT_TRUE([field invalid]); 246 EXPECT_TRUE([field invalid]);
243 field = [container_ getField:CREDIT_CARD_EXP_MONTH]; 247 field = [container_ getField:CREDIT_CARD_EXP_MONTH];
244 EXPECT_FALSE([field invalid]); 248 EXPECT_FALSE([field invalid]);
245 249
246 [container_ validateFor:VALIDATE_FINAL]; 250 [container_ validateFor:VALIDATE_FINAL];
247 field = [container_ getField:EMAIL_ADDRESS]; 251 field = [container_ getField:EMAIL_ADDRESS];
248 EXPECT_FALSE([field invalid]); 252 EXPECT_FALSE([field invalid]);
249 field = [container_ getField:CREDIT_CARD_EXP_MONTH]; 253 field = [container_ getField:CREDIT_CARD_EXP_MONTH];
250 EXPECT_TRUE([field invalid]); 254 EXPECT_TRUE([field invalid]);
251 } 255 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698