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

Side by Side Diff: chrome/browser/ui/views/payments/payment_method_view_controller_browsertest.cc

Issue 2757523002: [Payments] Use PaymentInstrument/AutofillPaymentInstrument throughout. (Closed)
Patch Set: Initial Created 3 years, 9 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" 5 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h"
6 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" 6 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
7 #include "components/autofill/core/browser/autofill_test_utils.h" 7 #include "components/autofill/core/browser/autofill_test_utils.h"
8 #include "components/autofill/core/browser/personal_data_manager.h" 8 #include "components/autofill/core/browser/personal_data_manager.h"
9 #include "components/payments/content/payment_request.h" 9 #include "components/payments/content/payment_request.h"
10 #include "components/payments/content/payment_request_state.h" 10 #include "components/payments/content/payment_request_state.h"
(...skipping 22 matching lines...) Expand all
33 } 33 }
34 34
35 IN_PROC_BROWSER_TEST_F(PaymentMethodViewControllerTest, OneCardSelected) { 35 IN_PROC_BROWSER_TEST_F(PaymentMethodViewControllerTest, OneCardSelected) {
36 const autofill::CreditCard card = autofill::test::GetCreditCard(); 36 const autofill::CreditCard card = autofill::test::GetCreditCard();
37 AddCreditCard(card); 37 AddCreditCard(card);
38 38
39 InvokePaymentRequestUI(); 39 InvokePaymentRequestUI();
40 OpenPaymentMethodScreen(); 40 OpenPaymentMethodScreen();
41 41
42 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents())[0]; 42 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents())[0];
43 EXPECT_EQ(1U, request->state()->credit_cards().size()); 43 EXPECT_EQ(1U, request->state()->available_instruments().size());
44 44
45 views::View* list_view = dialog_view()->GetViewByID( 45 views::View* list_view = dialog_view()->GetViewByID(
46 static_cast<int>(DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW)); 46 static_cast<int>(DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW));
47 EXPECT_TRUE(list_view); 47 EXPECT_TRUE(list_view);
48 EXPECT_EQ(1, list_view->child_count()); 48 EXPECT_EQ(1, list_view->child_count());
49 49
50 EXPECT_EQ(card, *request->state()->selected_credit_card()); 50 EXPECT_EQ(request->state()->available_instruments()[0],
51 request->state()->selected_instrument());
51 views::View* checkmark_view = list_view->child_at(0)->GetViewByID( 52 views::View* checkmark_view = list_view->child_at(0)->GetViewByID(
52 static_cast<int>(DialogViewID::CHECKMARK_VIEW)); 53 static_cast<int>(DialogViewID::CHECKMARK_VIEW));
53 EXPECT_TRUE(checkmark_view->visible()); 54 EXPECT_TRUE(checkmark_view->visible());
54 } 55 }
55 56
56 IN_PROC_BROWSER_TEST_F(PaymentMethodViewControllerTest, 57 IN_PROC_BROWSER_TEST_F(PaymentMethodViewControllerTest,
57 OneCardSelectedOutOfMany) { 58 OneCardSelectedOutOfMany) {
58 autofill::CreditCard card1 = autofill::test::GetCreditCard(); 59 autofill::CreditCard card1 = autofill::test::GetCreditCard();
59 // Ensure that this card is the first suggestion. 60 // Ensure that this card is the first suggestion.
60 card1.set_use_count(5U); 61 card1.set_use_count(5U);
61 AddCreditCard(card1); 62 AddCreditCard(card1);
62 63
63 autofill::CreditCard card2 = autofill::test::GetCreditCard2(); 64 autofill::CreditCard card2 = autofill::test::GetCreditCard2();
64 card2.set_use_count(1U); 65 card2.set_use_count(1U);
65 AddCreditCard(card2); 66 AddCreditCard(card2);
66 67
67 InvokePaymentRequestUI(); 68 InvokePaymentRequestUI();
68 OpenPaymentMethodScreen(); 69 OpenPaymentMethodScreen();
69 70
70 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents())[0]; 71 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents())[0];
71 EXPECT_EQ(2U, request->state()->credit_cards().size()); 72 EXPECT_EQ(2U, request->state()->available_instruments().size());
72 EXPECT_EQ(card1, *request->state()->selected_credit_card()); 73 EXPECT_EQ(request->state()->available_instruments()[0],
74 request->state()->selected_instrument());
73 75
74 views::View* list_view = dialog_view()->GetViewByID( 76 views::View* list_view = dialog_view()->GetViewByID(
75 static_cast<int>(DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW)); 77 static_cast<int>(DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW));
76 EXPECT_TRUE(list_view); 78 EXPECT_TRUE(list_view);
77 EXPECT_EQ(2, list_view->child_count()); 79 EXPECT_EQ(2, list_view->child_count());
78 80
79 EXPECT_EQ(card1, *request->state()->selected_credit_card()); 81 EXPECT_EQ(request->state()->available_instruments()[0],
82 request->state()->selected_instrument());
80 views::View* checkmark_view = list_view->child_at(0)->GetViewByID( 83 views::View* checkmark_view = list_view->child_at(0)->GetViewByID(
81 static_cast<int>(DialogViewID::CHECKMARK_VIEW)); 84 static_cast<int>(DialogViewID::CHECKMARK_VIEW));
82 EXPECT_TRUE(checkmark_view->visible()); 85 EXPECT_TRUE(checkmark_view->visible());
83 86
84 views::View* checkmark_view2 = list_view->child_at(1)->GetViewByID( 87 views::View* checkmark_view2 = list_view->child_at(1)->GetViewByID(
85 static_cast<int>(DialogViewID::CHECKMARK_VIEW)); 88 static_cast<int>(DialogViewID::CHECKMARK_VIEW));
86 EXPECT_FALSE(checkmark_view2->visible()); 89 EXPECT_FALSE(checkmark_view2->visible());
87 90
88 // Simulate selecting the second card. 91 // Simulate selecting the second card.
89 ClickOnDialogViewAndWait(list_view->child_at(1)); 92 ClickOnDialogViewAndWait(list_view->child_at(1));
90 93
91 EXPECT_EQ(card2, *request->state()->selected_credit_card()); 94 EXPECT_EQ(request->state()->available_instruments()[1],
95 request->state()->selected_instrument());
92 EXPECT_FALSE(checkmark_view->visible()); 96 EXPECT_FALSE(checkmark_view->visible());
93 EXPECT_TRUE(checkmark_view2->visible()); 97 EXPECT_TRUE(checkmark_view2->visible());
94 98
95 // Clicking on the second card again should not modify any state. 99 // Clicking on the second card again should not modify any state.
96 ClickOnDialogViewAndWait(list_view->child_at(1)); 100 ClickOnDialogViewAndWait(list_view->child_at(1));
97 101
98 EXPECT_EQ(card2, *request->state()->selected_credit_card()); 102 EXPECT_EQ(request->state()->available_instruments()[1],
103 request->state()->selected_instrument());
99 EXPECT_FALSE(checkmark_view->visible()); 104 EXPECT_FALSE(checkmark_view->visible());
100 EXPECT_TRUE(checkmark_view2->visible()); 105 EXPECT_TRUE(checkmark_view2->visible());
101 } 106 }
102 107
103 } // namespace payments 108 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698