| 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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" | 6 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" |
| 7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" | 7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" |
| 8 #include "components/autofill/core/browser/autofill_test_utils.h" | 8 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 9 #include "components/autofill/core/browser/personal_data_manager.h" | 9 #include "components/autofill/core/browser/personal_data_manager.h" |
| 10 #include "components/payments/content/payment_request.h" | 10 #include "components/payments/content/payment_request.h" |
| 11 #include "components/payments/content/payment_request_state.h" | 11 #include "components/payments/content/payment_request_state.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace payments { | 14 namespace payments { |
| 15 | 15 |
| 16 class PaymentMethodViewControllerTest : public PaymentRequestBrowserTestBase { | 16 class PaymentMethodViewControllerTest : public PaymentRequestBrowserTestBase { |
| 17 protected: | 17 protected: |
| 18 PaymentMethodViewControllerTest() | 18 PaymentMethodViewControllerTest() |
| 19 : PaymentRequestBrowserTestBase( | 19 : PaymentRequestBrowserTestBase( |
| 20 "/payment_request_no_shipping_test.html") {} | 20 "/payment_request_no_shipping_test.html") {} |
| 21 | 21 |
| 22 private: | 22 private: |
| 23 DISALLOW_COPY_AND_ASSIGN(PaymentMethodViewControllerTest); | 23 DISALLOW_COPY_AND_ASSIGN(PaymentMethodViewControllerTest); |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 IN_PROC_BROWSER_TEST_F(PaymentMethodViewControllerTest, EmptyList) { | |
| 27 InvokePaymentRequestUI(); | |
| 28 OpenPaymentMethodScreen(); | |
| 29 | |
| 30 views::View* list_view = dialog_view()->GetViewByID( | |
| 31 static_cast<int>(DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW)); | |
| 32 EXPECT_TRUE(list_view); | |
| 33 EXPECT_FALSE(list_view->has_children()); | |
| 34 } | |
| 35 | |
| 36 IN_PROC_BROWSER_TEST_F(PaymentMethodViewControllerTest, OneCardSelected) { | 26 IN_PROC_BROWSER_TEST_F(PaymentMethodViewControllerTest, OneCardSelected) { |
| 37 const autofill::CreditCard card = autofill::test::GetCreditCard(); | 27 const autofill::CreditCard card = autofill::test::GetCreditCard(); |
| 38 AddCreditCard(card); | 28 AddCreditCard(card); |
| 39 | 29 |
| 40 InvokePaymentRequestUI(); | 30 InvokePaymentRequestUI(); |
| 41 OpenPaymentMethodScreen(); | 31 OpenPaymentMethodScreen(); |
| 42 | 32 |
| 43 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents()).front(); | 33 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents()).front(); |
| 44 EXPECT_EQ(1U, request->state()->available_instruments().size()); | 34 EXPECT_EQ(1U, request->state()->available_instruments().size()); |
| 45 | 35 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 checkmark_view2 = list_view->child_at(1)->GetViewByID( | 99 checkmark_view2 = list_view->child_at(1)->GetViewByID( |
| 110 static_cast<int>(DialogViewID::CHECKMARK_VIEW)); | 100 static_cast<int>(DialogViewID::CHECKMARK_VIEW)); |
| 111 EXPECT_FALSE(checkmark_view->visible()); | 101 EXPECT_FALSE(checkmark_view->visible()); |
| 112 EXPECT_TRUE(checkmark_view2->visible()); | 102 EXPECT_TRUE(checkmark_view2->visible()); |
| 113 | 103 |
| 114 EXPECT_EQ(request->state()->available_instruments().back().get(), | 104 EXPECT_EQ(request->state()->available_instruments().back().get(), |
| 115 request->state()->selected_instrument()); | 105 request->state()->selected_instrument()); |
| 116 } | 106 } |
| 117 | 107 |
| 118 } // namespace payments | 108 } // namespace payments |
| OLD | NEW |