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

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

Issue 2720223004: Use PaymentRequestItemList for Shipping screen (Closed)
Patch Set: rebase 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_dialog_view_ids.h" 5 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
6 #include "chrome/browser/ui/views/payments/payment_request_interactive_uitest_ba se.h" 6 #include "chrome/browser/ui/views/payments/payment_request_interactive_uitest_ba se.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 "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents())[0]; 42 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents())[0];
43 EXPECT_EQ(1U, request->credit_cards().size()); 43 EXPECT_EQ(1U, request->credit_cards().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->selected_credit_card()); 50 EXPECT_EQ(card, *request->selected_credit_card());
51 views::View* checkmark_view = list_view->child_at(0)->GetViewByID( 51 views::View* checkmark_view = list_view->child_at(0)->GetViewByID(
52 static_cast<int>(DialogViewID::PAYMENT_METHOD_ITEM_CHECKMARK_VIEW)); 52 static_cast<int>(DialogViewID::CHECKMARK_VIEW));
53 EXPECT_TRUE(checkmark_view->visible()); 53 EXPECT_TRUE(checkmark_view->visible());
54 } 54 }
55 55
56 IN_PROC_BROWSER_TEST_F(PaymentMethodViewControllerTest, 56 IN_PROC_BROWSER_TEST_F(PaymentMethodViewControllerTest,
57 OneCardSelectedOutOfMany) { 57 OneCardSelectedOutOfMany) {
58 autofill::CreditCard card1 = autofill::test::GetCreditCard(); 58 autofill::CreditCard card1 = autofill::test::GetCreditCard();
59 // Ensure that this card is the first suggestion. 59 // Ensure that this card is the first suggestion.
60 card1.set_use_count(5U); 60 card1.set_use_count(5U);
61 AddCreditCard(card1); 61 AddCreditCard(card1);
62 62
63 autofill::CreditCard card2 = autofill::test::GetCreditCard2(); 63 autofill::CreditCard card2 = autofill::test::GetCreditCard2();
64 card2.set_use_count(1U); 64 card2.set_use_count(1U);
65 AddCreditCard(card2); 65 AddCreditCard(card2);
66 66
67 InvokePaymentRequestUI(); 67 InvokePaymentRequestUI();
68 OpenPaymentMethodScreen(); 68 OpenPaymentMethodScreen();
69 69
70 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents())[0]; 70 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents())[0];
71 EXPECT_EQ(2U, request->credit_cards().size()); 71 EXPECT_EQ(2U, request->credit_cards().size());
72 EXPECT_EQ(card1, *request->selected_credit_card()); 72 EXPECT_EQ(card1, *request->selected_credit_card());
73 73
74 views::View* list_view = dialog_view()->GetViewByID( 74 views::View* list_view = dialog_view()->GetViewByID(
75 static_cast<int>(DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW)); 75 static_cast<int>(DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW));
76 EXPECT_TRUE(list_view); 76 EXPECT_TRUE(list_view);
77 EXPECT_EQ(2, list_view->child_count()); 77 EXPECT_EQ(2, list_view->child_count());
78 78
79 EXPECT_EQ(card1, *request->selected_credit_card()); 79 EXPECT_EQ(card1, *request->selected_credit_card());
80 views::View* checkmark_view = list_view->child_at(0)->GetViewByID( 80 views::View* checkmark_view = list_view->child_at(0)->GetViewByID(
81 static_cast<int>(DialogViewID::PAYMENT_METHOD_ITEM_CHECKMARK_VIEW)); 81 static_cast<int>(DialogViewID::CHECKMARK_VIEW));
82 EXPECT_TRUE(checkmark_view->visible()); 82 EXPECT_TRUE(checkmark_view->visible());
83 83
84 views::View* checkmark_view2 = list_view->child_at(1)->GetViewByID( 84 views::View* checkmark_view2 = list_view->child_at(1)->GetViewByID(
85 static_cast<int>(DialogViewID::PAYMENT_METHOD_ITEM_CHECKMARK_VIEW)); 85 static_cast<int>(DialogViewID::CHECKMARK_VIEW));
86 EXPECT_FALSE(checkmark_view2->visible()); 86 EXPECT_FALSE(checkmark_view2->visible());
87 87
88 // Simulate selecting the second card. 88 // Simulate selecting the second card.
89 ClickOnDialogViewAndWait(list_view->child_at(1)); 89 ClickOnDialogViewAndWait(list_view->child_at(1));
90 90
91 EXPECT_EQ(card2, *request->selected_credit_card()); 91 EXPECT_EQ(card2, *request->selected_credit_card());
92 EXPECT_FALSE(checkmark_view->visible()); 92 EXPECT_FALSE(checkmark_view->visible());
93 EXPECT_TRUE(checkmark_view2->visible()); 93 EXPECT_TRUE(checkmark_view2->visible());
94 94
95 // Clicking on the second card again should not modify any state. 95 // Clicking on the second card again should not modify any state.
96 ClickOnDialogViewAndWait(list_view->child_at(1)); 96 ClickOnDialogViewAndWait(list_view->child_at(1));
97 97
98 EXPECT_EQ(card2, *request->selected_credit_card()); 98 EXPECT_EQ(card2, *request->selected_credit_card());
99 EXPECT_FALSE(checkmark_view->visible()); 99 EXPECT_FALSE(checkmark_view->visible());
100 EXPECT_TRUE(checkmark_view2->visible()); 100 EXPECT_TRUE(checkmark_view2->visible());
101 } 101 }
102 102
103 } // namespace payments 103 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698