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

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc

Issue 15979002: Making credit card number un-editable in Wallet mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 7 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) 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/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/time.h" 8 #include "base/time.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"
11 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" 11 #include "chrome/browser/ui/autofill/autofill_dialog_view.h"
12 #include "chrome/browser/ui/autofill/data_model_wrapper.h" 12 #include "chrome/browser/ui/autofill/data_model_wrapper.h"
13 #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h" 13 #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/test/base/in_process_browser_test.h" 16 #include "chrome/test/base/in_process_browser_test.h"
17 #include "components/autofill/browser/autofill_common_test.h" 17 #include "components/autofill/browser/autofill_common_test.h"
18 #include "components/autofill/browser/autofill_metrics.h" 18 #include "components/autofill/browser/autofill_metrics.h"
19 #include "components/autofill/browser/test_personal_data_manager.h" 19 #include "components/autofill/browser/test_personal_data_manager.h"
20 #include "components/autofill/browser/wallet/wallet_test_util.h"
20 #include "components/autofill/common/form_data.h" 21 #include "components/autofill/common/form_data.h"
21 #include "components/autofill/common/form_field_data.h" 22 #include "components/autofill/common/form_field_data.h"
22 #include "content/public/test/test_utils.h" 23 #include "content/public/test/test_utils.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 25
25 namespace autofill { 26 namespace autofill {
26 27
27 namespace { 28 namespace {
28 29
29 void MockCallback(const FormStructure*, const std::string&) {} 30 void MockCallback(const FormStructure*, const std::string&) {}
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 const FormData& form_data, 81 const FormData& form_data,
81 const AutofillMetrics& metric_logger, 82 const AutofillMetrics& metric_logger,
82 scoped_refptr<content::MessageLoopRunner> runner, 83 scoped_refptr<content::MessageLoopRunner> runner,
83 const DialogType dialog_type) 84 const DialogType dialog_type)
84 : AutofillDialogControllerImpl(contents, 85 : AutofillDialogControllerImpl(contents,
85 form_data, 86 form_data,
86 GURL(), 87 GURL(),
87 dialog_type, 88 dialog_type,
88 base::Bind(&MockCallback)), 89 base::Bind(&MockCallback)),
89 metric_logger_(metric_logger), 90 metric_logger_(metric_logger),
90 message_loop_runner_(runner) { 91 message_loop_runner_(runner) {
Evan Stade 2013/05/25 00:41:19 {} on same line
Dan Beam 2013/05/25 02:36:57 Done.
91 DisableWallet();
92 } 92 }
93 93
94 virtual ~TestAutofillDialogController() {} 94 virtual ~TestAutofillDialogController() {}
95 95
96 virtual void ViewClosed() OVERRIDE { 96 virtual void ViewClosed() OVERRIDE {
97 message_loop_runner_->Quit(); 97 message_loop_runner_->Quit();
98 AutofillDialogControllerImpl::ViewClosed(); 98 AutofillDialogControllerImpl::ViewClosed();
99 } 99 }
100 100
101 virtual string16 InputValidityMessage( 101 virtual string16 InputValidityMessage(
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 EXPECT_EQ(wrapper2.GetInfo(input.type), 411 EXPECT_EQ(wrapper2.GetInfo(input.type),
412 view->GetTextContentsOfInput(input)); 412 view->GetTextContentsOfInput(input));
413 } else if (input.type == CREDIT_CARD_VERIFICATION_CODE) { 413 } else if (input.type == CREDIT_CARD_VERIFICATION_CODE) {
414 EXPECT_TRUE(view->GetTextContentsOfInput(input).empty()); 414 EXPECT_TRUE(view->GetTextContentsOfInput(input).empty());
415 } else { 415 } else {
416 EXPECT_EQ(wrapper1.GetInfo(input.type), 416 EXPECT_EQ(wrapper1.GetInfo(input.type),
417 view->GetTextContentsOfInput(input)); 417 view->GetTextContentsOfInput(input));
418 } 418 }
419 } 419 }
420 } 420 }
421
422 // Tests that credit card number is disabled while editing a Wallet instrument.
423 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, WalletCreditCardDisabled) {
424 InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE);
425 controller()->OnUserNameFetchSuccess("user@example.com");
426
427 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
428 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument());
429 controller()->OnDidGetWalletItems(wallet_items.Pass());
430
431 controller()->EditClickedForSection(SECTION_CC_BILLING);
432
433 const DetailInputs& inputs =
434 controller()->RequestedFieldsForSection(SECTION_CC_BILLING);
435 size_t i;
436 for (i = 0; i < inputs.size(); ++i) {
437 if (inputs[i].type == CREDIT_CARD_NUMBER) {
438 EXPECT_FALSE(inputs[i].enabled);
439 break;
440 }
441 }
442 ASSERT_LT(i, inputs.size());
443
444 DetailOutputMap output;
445 controller()->view()->GetUserInput(SECTION_CC_BILLING, &output);
446 for (DetailOutputMap::const_iterator it = output.begin(); it != output.end();
447 ++it) {
Evan Stade 2013/05/25 00:41:19 one more space of indent
Dan Beam 2013/05/25 02:36:57 removed
448 EXPECT_NE(CREDIT_CARD_NUMBER, it->first->type);
449 }
450 }
421 #endif // defined(TOOLKIT_VIEWS) 451 #endif // defined(TOOLKIT_VIEWS)
422 452
423 } // namespace autofill 453 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698