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

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

Issue 2742813004: [Payments] Refactor into PaymentRequestState and Spec (Closed)
Patch Set: don't stop rebasin' 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 "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace payments { 13 namespace payments {
13 14
14 class PaymentMethodViewControllerTest : public PaymentRequestBrowserTestBase { 15 class PaymentMethodViewControllerTest : public PaymentRequestBrowserTestBase {
15 protected: 16 protected:
16 PaymentMethodViewControllerTest() 17 PaymentMethodViewControllerTest()
17 : PaymentRequestBrowserTestBase( 18 : PaymentRequestBrowserTestBase(
18 "/payment_request_no_shipping_test.html") {} 19 "/payment_request_no_shipping_test.html") {}
19 20
(...skipping 12 matching lines...) Expand all
32 } 33 }
33 34
34 IN_PROC_BROWSER_TEST_F(PaymentMethodViewControllerTest, OneCardSelected) { 35 IN_PROC_BROWSER_TEST_F(PaymentMethodViewControllerTest, OneCardSelected) {
35 const autofill::CreditCard card = autofill::test::GetCreditCard(); 36 const autofill::CreditCard card = autofill::test::GetCreditCard();
36 AddCreditCard(card); 37 AddCreditCard(card);
37 38
38 InvokePaymentRequestUI(); 39 InvokePaymentRequestUI();
39 OpenPaymentMethodScreen(); 40 OpenPaymentMethodScreen();
40 41
41 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents())[0]; 42 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents())[0];
42 EXPECT_EQ(1U, request->credit_cards().size()); 43 EXPECT_EQ(1U, request->state()->credit_cards().size());
43 44
44 views::View* list_view = dialog_view()->GetViewByID( 45 views::View* list_view = dialog_view()->GetViewByID(
45 static_cast<int>(DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW)); 46 static_cast<int>(DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW));
46 EXPECT_TRUE(list_view); 47 EXPECT_TRUE(list_view);
47 EXPECT_EQ(1, list_view->child_count()); 48 EXPECT_EQ(1, list_view->child_count());
48 49
49 EXPECT_EQ(card, *request->selected_credit_card()); 50 EXPECT_EQ(card, *request->state()->selected_credit_card());
50 views::View* checkmark_view = list_view->child_at(0)->GetViewByID( 51 views::View* checkmark_view = list_view->child_at(0)->GetViewByID(
51 static_cast<int>(DialogViewID::CHECKMARK_VIEW)); 52 static_cast<int>(DialogViewID::CHECKMARK_VIEW));
52 EXPECT_TRUE(checkmark_view->visible()); 53 EXPECT_TRUE(checkmark_view->visible());
53 } 54 }
54 55
55 IN_PROC_BROWSER_TEST_F(PaymentMethodViewControllerTest, 56 IN_PROC_BROWSER_TEST_F(PaymentMethodViewControllerTest,
56 OneCardSelectedOutOfMany) { 57 OneCardSelectedOutOfMany) {
57 autofill::CreditCard card1 = autofill::test::GetCreditCard(); 58 autofill::CreditCard card1 = autofill::test::GetCreditCard();
58 // Ensure that this card is the first suggestion. 59 // Ensure that this card is the first suggestion.
59 card1.set_use_count(5U); 60 card1.set_use_count(5U);
60 AddCreditCard(card1); 61 AddCreditCard(card1);
61 62
62 autofill::CreditCard card2 = autofill::test::GetCreditCard2(); 63 autofill::CreditCard card2 = autofill::test::GetCreditCard2();
63 card2.set_use_count(1U); 64 card2.set_use_count(1U);
64 AddCreditCard(card2); 65 AddCreditCard(card2);
65 66
66 InvokePaymentRequestUI(); 67 InvokePaymentRequestUI();
67 OpenPaymentMethodScreen(); 68 OpenPaymentMethodScreen();
68 69
69 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents())[0]; 70 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents())[0];
70 EXPECT_EQ(2U, request->credit_cards().size()); 71 EXPECT_EQ(2U, request->state()->credit_cards().size());
71 EXPECT_EQ(card1, *request->selected_credit_card()); 72 EXPECT_EQ(card1, *request->state()->selected_credit_card());
72 73
73 views::View* list_view = dialog_view()->GetViewByID( 74 views::View* list_view = dialog_view()->GetViewByID(
74 static_cast<int>(DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW)); 75 static_cast<int>(DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW));
75 EXPECT_TRUE(list_view); 76 EXPECT_TRUE(list_view);
76 EXPECT_EQ(2, list_view->child_count()); 77 EXPECT_EQ(2, list_view->child_count());
77 78
78 EXPECT_EQ(card1, *request->selected_credit_card()); 79 EXPECT_EQ(card1, *request->state()->selected_credit_card());
79 views::View* checkmark_view = list_view->child_at(0)->GetViewByID( 80 views::View* checkmark_view = list_view->child_at(0)->GetViewByID(
80 static_cast<int>(DialogViewID::CHECKMARK_VIEW)); 81 static_cast<int>(DialogViewID::CHECKMARK_VIEW));
81 EXPECT_TRUE(checkmark_view->visible()); 82 EXPECT_TRUE(checkmark_view->visible());
82 83
83 views::View* checkmark_view2 = list_view->child_at(1)->GetViewByID( 84 views::View* checkmark_view2 = list_view->child_at(1)->GetViewByID(
84 static_cast<int>(DialogViewID::CHECKMARK_VIEW)); 85 static_cast<int>(DialogViewID::CHECKMARK_VIEW));
85 EXPECT_FALSE(checkmark_view2->visible()); 86 EXPECT_FALSE(checkmark_view2->visible());
86 87
87 // Simulate selecting the second card. 88 // Simulate selecting the second card.
88 ClickOnDialogViewAndWait(list_view->child_at(1)); 89 ClickOnDialogViewAndWait(list_view->child_at(1));
89 90
90 EXPECT_EQ(card2, *request->selected_credit_card()); 91 EXPECT_EQ(card2, *request->state()->selected_credit_card());
91 EXPECT_FALSE(checkmark_view->visible()); 92 EXPECT_FALSE(checkmark_view->visible());
92 EXPECT_TRUE(checkmark_view2->visible()); 93 EXPECT_TRUE(checkmark_view2->visible());
93 94
94 // Clicking on the second card again should not modify any state. 95 // Clicking on the second card again should not modify any state.
95 ClickOnDialogViewAndWait(list_view->child_at(1)); 96 ClickOnDialogViewAndWait(list_view->child_at(1));
96 97
97 EXPECT_EQ(card2, *request->selected_credit_card()); 98 EXPECT_EQ(card2, *request->state()->selected_credit_card());
98 EXPECT_FALSE(checkmark_view->visible()); 99 EXPECT_FALSE(checkmark_view->visible());
99 EXPECT_TRUE(checkmark_view2->visible()); 100 EXPECT_TRUE(checkmark_view2->visible());
100 } 101 }
101 102
102 } // namespace payments 103 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698