| OLD | NEW |
| 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/payment_request.h" | 9 #include "components/payments/payment_request.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents())[0]; | 50 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents())[0]; |
| 51 EXPECT_EQ(1U, request->credit_cards().size()); | 51 EXPECT_EQ(1U, request->credit_cards().size()); |
| 52 | 52 |
| 53 views::View* list_view = dialog_view()->GetViewByID( | 53 views::View* list_view = dialog_view()->GetViewByID( |
| 54 static_cast<int>(DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW)); | 54 static_cast<int>(DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW)); |
| 55 EXPECT_TRUE(list_view); | 55 EXPECT_TRUE(list_view); |
| 56 EXPECT_EQ(1, list_view->child_count()); | 56 EXPECT_EQ(1, list_view->child_count()); |
| 57 | 57 |
| 58 EXPECT_EQ(card, *request->selected_credit_card()); | 58 EXPECT_EQ(card, *request->selected_credit_card()); |
| 59 views::View* checkmark_view = list_view->child_at(0)->GetViewByID( | 59 views::View* checkmark_view = list_view->child_at(0)->GetViewByID( |
| 60 static_cast<int>(DialogViewID::PAYMENT_METHOD_ITEM_CHECKMARK_VIEW)); | 60 static_cast<int>(DialogViewID::CHECKMARK_VIEW)); |
| 61 EXPECT_TRUE(checkmark_view->visible()); | 61 EXPECT_TRUE(checkmark_view->visible()); |
| 62 } | 62 } |
| 63 | 63 |
| 64 IN_PROC_BROWSER_TEST_F(PaymentMethodViewControllerTest, | 64 IN_PROC_BROWSER_TEST_F(PaymentMethodViewControllerTest, |
| 65 OneCardSelectedOutOfMany) { | 65 OneCardSelectedOutOfMany) { |
| 66 autofill::PersonalDataManager* personal_data_manager = GetDataManager(); | 66 autofill::PersonalDataManager* personal_data_manager = GetDataManager(); |
| 67 | 67 |
| 68 PersonalDataLoadedObserverMock personal_data_observer1; | 68 PersonalDataLoadedObserverMock personal_data_observer1; |
| 69 personal_data_manager->AddObserver(&personal_data_observer1); | 69 personal_data_manager->AddObserver(&personal_data_observer1); |
| 70 base::RunLoop card1_loop; | 70 base::RunLoop card1_loop; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 97 EXPECT_EQ(2U, request->credit_cards().size()); | 97 EXPECT_EQ(2U, request->credit_cards().size()); |
| 98 EXPECT_EQ(card1, *request->selected_credit_card()); | 98 EXPECT_EQ(card1, *request->selected_credit_card()); |
| 99 | 99 |
| 100 views::View* list_view = dialog_view()->GetViewByID( | 100 views::View* list_view = dialog_view()->GetViewByID( |
| 101 static_cast<int>(DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW)); | 101 static_cast<int>(DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW)); |
| 102 EXPECT_TRUE(list_view); | 102 EXPECT_TRUE(list_view); |
| 103 EXPECT_EQ(2, list_view->child_count()); | 103 EXPECT_EQ(2, list_view->child_count()); |
| 104 | 104 |
| 105 EXPECT_EQ(card1, *request->selected_credit_card()); | 105 EXPECT_EQ(card1, *request->selected_credit_card()); |
| 106 views::View* checkmark_view = list_view->child_at(0)->GetViewByID( | 106 views::View* checkmark_view = list_view->child_at(0)->GetViewByID( |
| 107 static_cast<int>(DialogViewID::PAYMENT_METHOD_ITEM_CHECKMARK_VIEW)); | 107 static_cast<int>(DialogViewID::CHECKMARK_VIEW)); |
| 108 EXPECT_TRUE(checkmark_view->visible()); | 108 EXPECT_TRUE(checkmark_view->visible()); |
| 109 | 109 |
| 110 views::View* checkmark_view2 = list_view->child_at(1)->GetViewByID( | 110 views::View* checkmark_view2 = list_view->child_at(1)->GetViewByID( |
| 111 static_cast<int>(DialogViewID::PAYMENT_METHOD_ITEM_CHECKMARK_VIEW)); | 111 static_cast<int>(DialogViewID::CHECKMARK_VIEW)); |
| 112 EXPECT_FALSE(checkmark_view2->visible()); | 112 EXPECT_FALSE(checkmark_view2->visible()); |
| 113 | 113 |
| 114 // Simulate selecting the second card. | 114 // Simulate selecting the second card. |
| 115 ClickOnDialogViewAndWait(list_view->child_at(1)); | 115 ClickOnDialogViewAndWait(list_view->child_at(1)); |
| 116 | 116 |
| 117 EXPECT_EQ(card2, *request->selected_credit_card()); | 117 EXPECT_EQ(card2, *request->selected_credit_card()); |
| 118 EXPECT_FALSE(checkmark_view->visible()); | 118 EXPECT_FALSE(checkmark_view->visible()); |
| 119 EXPECT_TRUE(checkmark_view2->visible()); | 119 EXPECT_TRUE(checkmark_view2->visible()); |
| 120 | 120 |
| 121 // Clicking on the second card again should not modify any state. | 121 // Clicking on the second card again should not modify any state. |
| 122 ClickOnDialogViewAndWait(list_view->child_at(1)); | 122 ClickOnDialogViewAndWait(list_view->child_at(1)); |
| 123 | 123 |
| 124 EXPECT_EQ(card2, *request->selected_credit_card()); | 124 EXPECT_EQ(card2, *request->selected_credit_card()); |
| 125 EXPECT_FALSE(checkmark_view->visible()); | 125 EXPECT_FALSE(checkmark_view->visible()); |
| 126 EXPECT_TRUE(checkmark_view2->visible()); | 126 EXPECT_TRUE(checkmark_view2->visible()); |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace payments | 129 } // namespace payments |
| OLD | NEW |