| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/guid.h" | 5 #include "base/guid.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" | 10 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 TestAutofillDialogView() {} | 47 TestAutofillDialogView() {} |
| 48 virtual ~TestAutofillDialogView() {} | 48 virtual ~TestAutofillDialogView() {} |
| 49 | 49 |
| 50 virtual void Show() OVERRIDE {} | 50 virtual void Show() OVERRIDE {} |
| 51 virtual void Hide() OVERRIDE {} | 51 virtual void Hide() OVERRIDE {} |
| 52 virtual void UpdateNotificationArea() OVERRIDE {} | 52 virtual void UpdateNotificationArea() OVERRIDE {} |
| 53 virtual void UpdateAccountChooser() OVERRIDE {} | 53 virtual void UpdateAccountChooser() OVERRIDE {} |
| 54 virtual void UpdateButtonStrip() OVERRIDE {} | 54 virtual void UpdateButtonStrip() OVERRIDE {} |
| 55 virtual void UpdateSection(DialogSection section) OVERRIDE {} | 55 virtual void UpdateSection(DialogSection section) OVERRIDE {} |
| 56 virtual void FillSection(DialogSection section, | 56 virtual void FillSection(DialogSection section, |
| 57 const DetailInput& originating_input) OVERRIDE {}; | 57 AutofillFieldType originating_input) OVERRIDE {} |
| 58 virtual void GetUserInput(DialogSection section, DetailOutputMap* output) | 58 virtual void GetUserInput(DialogSection section, DetailOutputMap* output) |
| 59 OVERRIDE { | 59 OVERRIDE { |
| 60 *output = outputs_[section]; | 60 *output = outputs_[section]; |
| 61 } | 61 } |
| 62 | 62 |
| 63 virtual string16 GetCvc() OVERRIDE { return string16(); } | 63 virtual string16 GetCvc() OVERRIDE { return string16(); } |
| 64 virtual bool SaveDetailsLocally() OVERRIDE { return true; } | 64 virtual bool SaveDetailsLocally() OVERRIDE { return true; } |
| 65 virtual const content::NavigationController* ShowSignIn() OVERRIDE { | 65 virtual const content::NavigationController* ShowSignIn() OVERRIDE { |
| 66 return NULL; | 66 return NULL; |
| 67 } | 67 } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 list->AppendString("verify_cvv"); | 262 list->AppendString("verify_cvv"); |
| 263 dict.Set("required_action", list.release()); | 263 dict.Set("required_action", list.release()); |
| 264 return wallet::FullWallet::CreateFullWallet(dict); | 264 return wallet::FullWallet::CreateFullWallet(dict); |
| 265 } | 265 } |
| 266 | 266 |
| 267 void FillCreditCardInputs() { | 267 void FillCreditCardInputs() { |
| 268 DetailOutputMap cc_outputs; | 268 DetailOutputMap cc_outputs; |
| 269 const DetailInputs& cc_inputs = | 269 const DetailInputs& cc_inputs = |
| 270 controller()->RequestedFieldsForSection(SECTION_CC); | 270 controller()->RequestedFieldsForSection(SECTION_CC); |
| 271 for (size_t i = 0; i < cc_inputs.size(); ++i) { | 271 for (size_t i = 0; i < cc_inputs.size(); ++i) { |
| 272 cc_outputs[&cc_inputs[i]] = ASCIIToUTF16("11"); | 272 cc_outputs[cc_inputs[i].type] = ASCIIToUTF16("11"); |
| 273 } | 273 } |
| 274 controller()->GetView()->SetUserInput(SECTION_CC, cc_outputs); | 274 controller()->GetView()->SetUserInput(SECTION_CC, cc_outputs); |
| 275 } | 275 } |
| 276 | 276 |
| 277 std::vector<DialogNotification> NotificationsOfType( | 277 std::vector<DialogNotification> NotificationsOfType( |
| 278 DialogNotification::Type type) { | 278 DialogNotification::Type type) { |
| 279 std::vector<DialogNotification> right_type; | 279 std::vector<DialogNotification> right_type; |
| 280 const std::vector<DialogNotification>& notifications = | 280 const std::vector<DialogNotification>& notifications = |
| 281 controller()->CurrentNotifications(); | 281 controller()->CurrentNotifications(); |
| 282 for (size_t i = 0; i < notifications.size(); ++i) { | 282 for (size_t i = 0; i < notifications.size(); ++i) { |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 | 524 |
| 525 AutofillProfile full_profile(test::GetFullProfile()); | 525 AutofillProfile full_profile(test::GetFullProfile()); |
| 526 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 526 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
| 527 controller()->EditClickedForSection(SECTION_SHIPPING); | 527 controller()->EditClickedForSection(SECTION_SHIPPING); |
| 528 | 528 |
| 529 DetailOutputMap outputs; | 529 DetailOutputMap outputs; |
| 530 const DetailInputs& inputs = | 530 const DetailInputs& inputs = |
| 531 controller()->RequestedFieldsForSection(SECTION_SHIPPING); | 531 controller()->RequestedFieldsForSection(SECTION_SHIPPING); |
| 532 for (size_t i = 0; i < inputs.size(); ++i) { | 532 for (size_t i = 0; i < inputs.size(); ++i) { |
| 533 const DetailInput& input = inputs[i]; | 533 const DetailInput& input = inputs[i]; |
| 534 outputs[&input] = input.type == NAME_FULL ? ASCIIToUTF16("Edited Name") : | 534 outputs[input.type] = input.type == NAME_FULL ? ASCIIToUTF16("Edited Name") |
| 535 input.initial_value; | 535 : input.initial_value; |
| 536 } | 536 } |
| 537 controller()->GetView()->SetUserInput(SECTION_SHIPPING, outputs); | 537 controller()->GetView()->SetUserInput(SECTION_SHIPPING, outputs); |
| 538 | 538 |
| 539 // We also have to simulate CC inputs to keep the controller happy. | 539 // We also have to simulate CC inputs to keep the controller happy. |
| 540 FillCreditCardInputs(); | 540 FillCreditCardInputs(); |
| 541 | 541 |
| 542 controller()->OnAccept(); | 542 controller()->OnAccept(); |
| 543 const AutofillProfile& edited_profile = | 543 const AutofillProfile& edited_profile = |
| 544 controller()->GetTestingManager()->imported_profile(); | 544 controller()->GetTestingManager()->imported_profile(); |
| 545 | 545 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 562 // Activate the "Add billing address" menu item. | 562 // Activate the "Add billing address" menu item. |
| 563 model->ActivatedAt(model->GetItemCount() - 2); | 563 model->ActivatedAt(model->GetItemCount() - 2); |
| 564 | 564 |
| 565 // Fill in the inputs from the profile. | 565 // Fill in the inputs from the profile. |
| 566 DetailOutputMap outputs; | 566 DetailOutputMap outputs; |
| 567 const DetailInputs& inputs = | 567 const DetailInputs& inputs = |
| 568 controller()->RequestedFieldsForSection(SECTION_BILLING); | 568 controller()->RequestedFieldsForSection(SECTION_BILLING); |
| 569 AutofillProfile full_profile2(test::GetFullProfile2()); | 569 AutofillProfile full_profile2(test::GetFullProfile2()); |
| 570 for (size_t i = 0; i < inputs.size(); ++i) { | 570 for (size_t i = 0; i < inputs.size(); ++i) { |
| 571 const DetailInput& input = inputs[i]; | 571 const DetailInput& input = inputs[i]; |
| 572 outputs[&input] = full_profile2.GetInfo(input.type, "en-US"); | 572 outputs[input.type] = full_profile2.GetInfo(input.type, "en-US"); |
| 573 } | 573 } |
| 574 controller()->GetView()->SetUserInput(SECTION_BILLING, outputs); | 574 controller()->GetView()->SetUserInput(SECTION_BILLING, outputs); |
| 575 | 575 |
| 576 // Fill in some CC info. The name field will be used to fill in the billing | 576 // Fill in some CC info. The name field will be used to fill in the billing |
| 577 // address name in the newly minted AutofillProfile. | 577 // address name in the newly minted AutofillProfile. |
| 578 DetailOutputMap cc_outputs; | 578 DetailOutputMap cc_outputs; |
| 579 const DetailInputs& cc_inputs = | 579 const DetailInputs& cc_inputs = |
| 580 controller()->RequestedFieldsForSection(SECTION_CC); | 580 controller()->RequestedFieldsForSection(SECTION_CC); |
| 581 for (size_t i = 0; i < cc_inputs.size(); ++i) { | 581 for (size_t i = 0; i < cc_inputs.size(); ++i) { |
| 582 cc_outputs[&cc_inputs[i]] = cc_inputs[i].type == CREDIT_CARD_NAME ? | 582 cc_outputs[cc_inputs[i].type] = |
| 583 ASCIIToUTF16("Bill Money") : ASCIIToUTF16("111"); | 583 cc_inputs[i].type == CREDIT_CARD_NAME ? ASCIIToUTF16("Bill Money") |
| 584 : ASCIIToUTF16("111"); |
| 584 } | 585 } |
| 585 controller()->GetView()->SetUserInput(SECTION_CC, cc_outputs); | 586 controller()->GetView()->SetUserInput(SECTION_CC, cc_outputs); |
| 586 | 587 |
| 587 controller()->OnAccept(); | 588 controller()->OnAccept(); |
| 588 const AutofillProfile& added_profile = | 589 const AutofillProfile& added_profile = |
| 589 controller()->GetTestingManager()->imported_profile(); | 590 controller()->GetTestingManager()->imported_profile(); |
| 590 | 591 |
| 591 const DetailInputs& shipping_inputs = | 592 const DetailInputs& shipping_inputs = |
| 592 controller()->RequestedFieldsForSection(SECTION_SHIPPING); | 593 controller()->RequestedFieldsForSection(SECTION_SHIPPING); |
| 593 for (size_t i = 0; i < shipping_inputs.size(); ++i) { | 594 for (size_t i = 0; i < shipping_inputs.size(); ++i) { |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome()); | 910 EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome()); |
| 910 | 911 |
| 911 controller()->MenuModelForSection(SECTION_EMAIL)->ActivatedAt(1); | 912 controller()->MenuModelForSection(SECTION_EMAIL)->ActivatedAt(1); |
| 912 EXPECT_TRUE(controller()->ShouldOfferToSaveInChrome()); | 913 EXPECT_TRUE(controller()->ShouldOfferToSaveInChrome()); |
| 913 | 914 |
| 914 profile()->set_incognito(true); | 915 profile()->set_incognito(true); |
| 915 EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome()); | 916 EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome()); |
| 916 } | 917 } |
| 917 | 918 |
| 918 } // namespace autofill | 919 } // namespace autofill |
| OLD | NEW |