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 <list> | 5 #include <list> |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" | 8 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" |
9 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" | 9 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" |
10 #include "components/autofill/core/browser/autofill_profile.h" | 10 #include "components/autofill/core/browser/autofill_profile.h" |
11 #include "components/autofill/core/browser/autofill_test_utils.h" | 11 #include "components/autofill/core/browser/autofill_test_utils.h" |
12 #include "components/autofill/core/browser/field_types.h" | 12 #include "components/autofill/core/browser/field_types.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace payments { | 15 namespace payments { |
16 | 16 |
17 class PaymentRequestShippingOptionViewControllerTest | 17 class PaymentRequestShippingOptionViewControllerTest |
18 : public PaymentRequestBrowserTestBase { | 18 : public PaymentRequestBrowserTestBase { |
19 protected: | 19 protected: |
20 PaymentRequestShippingOptionViewControllerTest() | 20 PaymentRequestShippingOptionViewControllerTest() |
21 : PaymentRequestBrowserTestBase( | 21 : PaymentRequestBrowserTestBase( |
22 "/payment_request_dynamic_shipping_test.html") {} | 22 "/payment_request_dynamic_shipping_test.html") {} |
23 | 23 |
24 private: | 24 private: |
25 DISALLOW_COPY_AND_ASSIGN(PaymentRequestShippingOptionViewControllerTest); | 25 DISALLOW_COPY_AND_ASSIGN(PaymentRequestShippingOptionViewControllerTest); |
26 }; | 26 }; |
27 | 27 |
28 IN_PROC_BROWSER_TEST_F(PaymentRequestShippingOptionViewControllerTest, | 28 IN_PROC_BROWSER_TEST_F(PaymentRequestShippingOptionViewControllerTest, |
29 OrderSummaryReflectsShippingOption) { | 29 SelectingVariousShippingOptions) { |
30 // In MI state, shipping is $5.00. | 30 // In MI state, shipping is $5.00. |
31 autofill::AutofillProfile michigan = autofill::test::GetFullProfile2(); | 31 autofill::AutofillProfile michigan = autofill::test::GetFullProfile2(); |
32 michigan.set_use_count(100U); | 32 michigan.set_use_count(100U); |
33 AddAutofillProfile(michigan); | 33 AddAutofillProfile(michigan); |
34 // A Canadian address will have no shipping options. | 34 // A Canadian address will have no shipping options. |
35 autofill::AutofillProfile canada = autofill::test::GetFullProfile(); | 35 autofill::AutofillProfile canada = autofill::test::GetFullProfile(); |
36 canada.SetRawInfo(autofill::ADDRESS_HOME_COUNTRY, base::ASCIIToUTF16("CA")); | 36 canada.SetRawInfo(autofill::ADDRESS_HOME_COUNTRY, base::ASCIIToUTF16("CA")); |
37 canada.set_use_count(50U); | 37 canada.set_use_count(50U); |
38 AddAutofillProfile(canada); | 38 AddAutofillProfile(canada); |
39 | 39 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 ResetEventObserverForSequence(std::list<DialogEvent>{ | 73 ResetEventObserverForSequence(std::list<DialogEvent>{ |
74 DialogEvent::BACK_NAVIGATION, DialogEvent::SPEC_DONE_UPDATING}); | 74 DialogEvent::BACK_NAVIGATION, DialogEvent::SPEC_DONE_UPDATING}); |
75 ClickOnChildInListViewAndWait( | 75 ClickOnChildInListViewAndWait( |
76 /* child_index=*/1, /*total_num_children=*/2, | 76 /* child_index=*/1, /*total_num_children=*/2, |
77 DialogViewID::SHIPPING_ADDRESS_SHEET_LIST_VIEW); | 77 DialogViewID::SHIPPING_ADDRESS_SHEET_LIST_VIEW); |
78 | 78 |
79 // There is no longer shipping option section, because no shipping options are | 79 // There is no longer shipping option section, because no shipping options are |
80 // available for Canada. | 80 // available for Canada. |
81 EXPECT_EQ(nullptr, dialog_view()->GetViewByID(static_cast<int>( | 81 EXPECT_EQ(nullptr, dialog_view()->GetViewByID(static_cast<int>( |
82 DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION))); | 82 DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION))); |
| 83 |
| 84 // There is now an appropriate error that is shown in the shipping address |
| 85 // section of the Payment Sheet. The string is returned by the merchant. |
| 86 EXPECT_EQ(base::ASCIIToUTF16("We do not ship to this address"), |
| 87 GetProfileLabelValues( |
| 88 DialogViewID::PAYMENT_SHEET_SHIPPING_ADDRESS_SECTION) |
| 89 .back()); |
| 90 |
| 91 // Go to the address selector and see this error as well. |
| 92 OpenShippingAddressSectionScreen(); |
| 93 EXPECT_EQ(base::ASCIIToUTF16("We do not ship to this address"), |
| 94 GetLabelText(DialogViewID::SHIPPING_ADDRESS_OPTION_ERROR)); |
83 } | 95 } |
84 | 96 |
85 } // namespace payments | 97 } // namespace payments |
OLD | NEW |