| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH)) | 132 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH)) |
| 133 .WillRepeatedly(Return(&comboModel)); | 133 .WillRepeatedly(Return(&comboModel)); |
| 134 | 134 |
| 135 ResetContainer(); | 135 ResetContainer(); |
| 136 | 136 |
| 137 NSPopUpButton* popup = base::mac::ObjCCastStrict<NSPopUpButton>( | 137 NSPopUpButton* popup = base::mac::ObjCCastStrict<NSPopUpButton>( |
| 138 [container_ getField:CREDIT_CARD_EXP_MONTH]); | 138 [container_ getField:CREDIT_CARD_EXP_MONTH]); |
| 139 [popup selectItemWithTitle:@"02"]; | 139 [popup selectItemWithTitle:@"02"]; |
| 140 [[container_ getField:EMAIL_ADDRESS] setStringValue:@"magic@example.org"]; | 140 [[container_ getField:EMAIL_ADDRESS] setStringValue:@"magic@example.org"]; |
| 141 | 141 |
| 142 autofill::DetailOutputMap output; | 142 autofill::FieldValueMap output; |
| 143 [container_ getInputs:&output]; | 143 [container_ getInputs:&output]; |
| 144 | 144 |
| 145 ASSERT_EQ(inputs.size(), output.size()); | 145 ASSERT_EQ(inputs.size(), output.size()); |
| 146 EXPECT_EQ(ASCIIToUTF16("magic@example.org"), output[&inputs[0]]); | 146 EXPECT_EQ(ASCIIToUTF16("magic@example.org"), output[inputs[0].type]); |
| 147 EXPECT_EQ(ASCIIToUTF16("02"), output[&inputs[1]]); | 147 EXPECT_EQ(ASCIIToUTF16("02"), output[inputs[1].type]); |
| 148 } | 148 } |
| 149 | 149 |
| 150 TEST_F(AutofillSectionContainerTest, SuggestionsPopulatedByController) { | 150 TEST_F(AutofillSectionContainerTest, SuggestionsPopulatedByController) { |
| 151 ui::SimpleMenuModel model(NULL); | 151 ui::SimpleMenuModel model(NULL); |
| 152 model.AddItem(10, ASCIIToUTF16("a")); | 152 model.AddItem(10, ASCIIToUTF16("a")); |
| 153 model.AddItem(11, ASCIIToUTF16("b")); | 153 model.AddItem(11, ASCIIToUTF16("b")); |
| 154 | 154 |
| 155 using namespace autofill; | 155 using namespace autofill; |
| 156 using namespace testing; | 156 using namespace testing; |
| 157 | 157 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 const DetailInput kTestInputs[] = { | 210 const DetailInput kTestInputs[] = { |
| 211 { 1, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, | 211 { 1, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, |
| 212 { 2, CREDIT_CARD_EXP_MONTH } | 212 { 2, CREDIT_CARD_EXP_MONTH } |
| 213 }; | 213 }; |
| 214 | 214 |
| 215 MonthComboboxModel comboModel; | 215 MonthComboboxModel comboModel; |
| 216 DetailInputs inputs; | 216 DetailInputs inputs; |
| 217 inputs.push_back(kTestInputs[0]); | 217 inputs.push_back(kTestInputs[0]); |
| 218 inputs.push_back(kTestInputs[1]); | 218 inputs.push_back(kTestInputs[1]); |
| 219 | 219 |
| 220 DetailOutputMap output; | |
| 221 ValidityMessages validity, validity2; | 220 ValidityMessages validity, validity2; |
| 222 | 221 |
| 223 validity.Set(EMAIL_ADDRESS, | 222 validity.Set(EMAIL_ADDRESS, |
| 224 ValidityMessage(ASCIIToUTF16("Some error message"), false)); | 223 ValidityMessage(ASCIIToUTF16("Some error message"), false)); |
| 225 validity2.Set(CREDIT_CARD_EXP_MONTH, | 224 validity2.Set(CREDIT_CARD_EXP_MONTH, |
| 226 ValidityMessage(ASCIIToUTF16("Some other error message"), false)); | 225 ValidityMessage(ASCIIToUTF16("Some other error message"), false)); |
| 227 EXPECT_CALL(delegate_, RequestedFieldsForSection(section_)) | 226 EXPECT_CALL(delegate_, RequestedFieldsForSection(section_)) |
| 228 .WillOnce(ReturnRef(inputs)); | 227 .WillOnce(ReturnRef(inputs)); |
| 229 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(EMAIL_ADDRESS)) | 228 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(EMAIL_ADDRESS)) |
| 230 .WillRepeatedly(ReturnNull()); | 229 .WillRepeatedly(ReturnNull()); |
| 231 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH)) | 230 EXPECT_CALL(delegate_, ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH)) |
| 232 .WillRepeatedly(Return(&comboModel)); | 231 .WillRepeatedly(Return(&comboModel)); |
| 233 | 232 |
| 234 ResetContainer(); | 233 ResetContainer(); |
| 234 FieldValueMap output; |
| 235 [container_ getInputs:&output]; | 235 [container_ getInputs:&output]; |
| 236 EXPECT_CALL(delegate_, InputsAreValid(section_, output)) | 236 EXPECT_CALL(delegate_, InputsAreValid(section_, output)) |
| 237 .WillOnce(Return(validity)) | 237 .WillOnce(Return(validity)) |
| 238 .WillOnce(Return(validity2)); | 238 .WillOnce(Return(validity2)); |
| 239 | 239 |
| 240 [container_ validateFor:VALIDATE_FINAL]; | 240 [container_ validateFor:VALIDATE_FINAL]; |
| 241 NSControl<AutofillInputField>* field = [container_ getField:EMAIL_ADDRESS]; | 241 NSControl<AutofillInputField>* field = [container_ getField:EMAIL_ADDRESS]; |
| 242 EXPECT_TRUE([field invalid]); | 242 EXPECT_TRUE([field invalid]); |
| 243 field = [container_ getField:CREDIT_CARD_EXP_MONTH]; | 243 field = [container_ getField:CREDIT_CARD_EXP_MONTH]; |
| 244 EXPECT_FALSE([field invalid]); | 244 EXPECT_FALSE([field invalid]); |
| 245 | 245 |
| 246 [container_ validateFor:VALIDATE_FINAL]; | 246 [container_ validateFor:VALIDATE_FINAL]; |
| 247 field = [container_ getField:EMAIL_ADDRESS]; | 247 field = [container_ getField:EMAIL_ADDRESS]; |
| 248 EXPECT_FALSE([field invalid]); | 248 EXPECT_FALSE([field invalid]); |
| 249 field = [container_ getField:CREDIT_CARD_EXP_MONTH]; | 249 field = [container_ getField:CREDIT_CARD_EXP_MONTH]; |
| 250 EXPECT_TRUE([field invalid]); | 250 EXPECT_TRUE([field invalid]); |
| 251 } | 251 } |
| OLD | NEW |