OLD | NEW |
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" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 [container_ getField:CREDIT_CARD_EXP_4_DIGIT_YEAR]); | 112 [container_ getField:CREDIT_CARD_EXP_4_DIGIT_YEAR]); |
113 EXPECT_EQ(11, [yearPopup numberOfItems]); | 113 EXPECT_EQ(11, [yearPopup numberOfItems]); |
114 EXPECT_NSEQ(@"Year", [yearPopup itemTitleAtIndex:0]); | 114 EXPECT_NSEQ(@"Year", [yearPopup itemTitleAtIndex:0]); |
115 }; | 115 }; |
116 | 116 |
117 TEST_F(AutofillSectionContainerTest, OutputMatchesDefinition) { | 117 TEST_F(AutofillSectionContainerTest, OutputMatchesDefinition) { |
118 using namespace autofill; | 118 using namespace autofill; |
119 using namespace testing; | 119 using namespace testing; |
120 | 120 |
121 const DetailInput kTestInputs[] = { | 121 const DetailInput kTestInputs[] = { |
122 { DetailInput::LONG, | 122 { DetailInput::LONG, EMAIL_ADDRESS }, |
123 EMAIL_ADDRESS, | |
124 IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, | |
125 { DetailInput::SHORT, CREDIT_CARD_EXP_MONTH }, | 123 { DetailInput::SHORT, CREDIT_CARD_EXP_MONTH }, |
126 }; | 124 }; |
127 autofill::MonthComboboxModel comboModel; | 125 autofill::MonthComboboxModel comboModel; |
128 DetailInputs inputs; | 126 DetailInputs inputs; |
129 inputs.push_back(kTestInputs[0]); | 127 inputs.push_back(kTestInputs[0]); |
130 inputs.push_back(kTestInputs[1]); | 128 inputs.push_back(kTestInputs[1]); |
131 | 129 |
132 EXPECT_CALL(delegate_, RequestedFieldsForSection(section_)) | 130 EXPECT_CALL(delegate_, RequestedFieldsForSection(section_)) |
133 .WillOnce(ReturnRef(inputs)); | 131 .WillOnce(ReturnRef(inputs)); |
134 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 Loading... |
177 | 175 |
178 EXPECT_NSEQ(@"a", [[menu itemAtIndex:1] title]); | 176 EXPECT_NSEQ(@"a", [[menu itemAtIndex:1] title]); |
179 EXPECT_NSEQ(@"b", [[menu itemAtIndex:2] title]); | 177 EXPECT_NSEQ(@"b", [[menu itemAtIndex:2] title]); |
180 } | 178 } |
181 | 179 |
182 TEST_F(AutofillSectionContainerTest, FieldsAreInitiallyValid) { | 180 TEST_F(AutofillSectionContainerTest, FieldsAreInitiallyValid) { |
183 using namespace autofill; | 181 using namespace autofill; |
184 using namespace testing; | 182 using namespace testing; |
185 | 183 |
186 const DetailInput kTestInputs[] = { | 184 const DetailInput kTestInputs[] = { |
187 { DetailInput::LONG, | 185 { DetailInput::LONG, EMAIL_ADDRESS }, |
188 EMAIL_ADDRESS, | |
189 IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, | |
190 { DetailInput::SHORT, CREDIT_CARD_EXP_MONTH }, | 186 { DetailInput::SHORT, CREDIT_CARD_EXP_MONTH }, |
191 }; | 187 }; |
192 | 188 |
193 MonthComboboxModel comboModel; | 189 MonthComboboxModel comboModel; |
194 DetailInputs inputs; | 190 DetailInputs inputs; |
195 inputs.push_back(kTestInputs[0]); | 191 inputs.push_back(kTestInputs[0]); |
196 inputs.push_back(kTestInputs[1]); | 192 inputs.push_back(kTestInputs[1]); |
197 | 193 |
198 EXPECT_CALL(delegate_, RequestedFieldsForSection(section_)) | 194 EXPECT_CALL(delegate_, RequestedFieldsForSection(section_)) |
199 .WillOnce(ReturnRef(inputs)); | 195 .WillOnce(ReturnRef(inputs)); |
200 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(EMAIL_ADDRESS)) | 196 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(EMAIL_ADDRESS)) |
201 .WillRepeatedly(ReturnNull()); | 197 .WillRepeatedly(ReturnNull()); |
202 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH)) | 198 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH)) |
203 .WillRepeatedly(Return(&comboModel)); | 199 .WillRepeatedly(Return(&comboModel)); |
204 | 200 |
205 ResetContainer(); | 201 ResetContainer(); |
206 NSControl<AutofillInputField>* field = [container_ getField:EMAIL_ADDRESS]; | 202 NSControl<AutofillInputField>* field = [container_ getField:EMAIL_ADDRESS]; |
207 EXPECT_FALSE([field invalid]); | 203 EXPECT_FALSE([field invalid]); |
208 field = [container_ getField:CREDIT_CARD_EXP_MONTH]; | 204 field = [container_ getField:CREDIT_CARD_EXP_MONTH]; |
209 EXPECT_FALSE([field invalid]); | 205 EXPECT_FALSE([field invalid]); |
210 } | 206 } |
211 | 207 |
212 TEST_F(AutofillSectionContainerTest, ControllerInformsValidity) { | 208 TEST_F(AutofillSectionContainerTest, ControllerInformsValidity) { |
213 using namespace autofill; | 209 using namespace autofill; |
214 using namespace testing; | 210 using namespace testing; |
215 | 211 |
216 const DetailInput kTestInputs[] = { | 212 const DetailInput kTestInputs[] = { |
217 { DetailInput::LONG, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, | 213 { DetailInput::LONG, EMAIL_ADDRESS }, |
218 { DetailInput::SHORT, CREDIT_CARD_EXP_MONTH } | 214 { DetailInput::SHORT, CREDIT_CARD_EXP_MONTH }, |
219 }; | 215 }; |
220 | 216 |
221 MonthComboboxModel comboModel; | 217 MonthComboboxModel comboModel; |
222 DetailInputs inputs; | 218 DetailInputs inputs; |
223 inputs.push_back(kTestInputs[0]); | 219 inputs.push_back(kTestInputs[0]); |
224 inputs.push_back(kTestInputs[1]); | 220 inputs.push_back(kTestInputs[1]); |
225 | 221 |
226 ValidityMessages validity, validity2; | 222 ValidityMessages validity, validity2; |
227 | 223 |
228 validity.Set(EMAIL_ADDRESS, | 224 validity.Set(EMAIL_ADDRESS, |
(...skipping 19 matching lines...) Expand all Loading... |
248 EXPECT_TRUE([field invalid]); | 244 EXPECT_TRUE([field invalid]); |
249 field = [container_ getField:CREDIT_CARD_EXP_MONTH]; | 245 field = [container_ getField:CREDIT_CARD_EXP_MONTH]; |
250 EXPECT_FALSE([field invalid]); | 246 EXPECT_FALSE([field invalid]); |
251 | 247 |
252 [container_ validateFor:VALIDATE_FINAL]; | 248 [container_ validateFor:VALIDATE_FINAL]; |
253 field = [container_ getField:EMAIL_ADDRESS]; | 249 field = [container_ getField:EMAIL_ADDRESS]; |
254 EXPECT_FALSE([field invalid]); | 250 EXPECT_FALSE([field invalid]); |
255 field = [container_ getField:CREDIT_CARD_EXP_MONTH]; | 251 field = [container_ getField:CREDIT_CARD_EXP_MONTH]; |
256 EXPECT_TRUE([field invalid]); | 252 EXPECT_TRUE([field invalid]); |
257 } | 253 } |
OLD | NEW |