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

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

Issue 2808883002: [Payments] Fix bug in shipping option selection. (Closed)
Patch Set: Initial Created 3 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <list>
6
7 #include "base/strings/utf_string_conversions.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"
10 #include "components/autofill/core/browser/autofill_profile.h"
11 #include "components/autofill/core/browser/autofill_test_utils.h"
12 #include "components/autofill/core/browser/field_types.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 namespace payments {
16
17 class PaymentRequestShippingOptionViewControllerTest
18 : public PaymentRequestBrowserTestBase {
19 protected:
20 PaymentRequestShippingOptionViewControllerTest()
21 : PaymentRequestBrowserTestBase(
22 "/payment_request_dynamic_shipping_test.html") {}
23
24 private:
25 DISALLOW_COPY_AND_ASSIGN(PaymentRequestShippingOptionViewControllerTest);
26 };
27
28 IN_PROC_BROWSER_TEST_F(PaymentRequestShippingOptionViewControllerTest,
29 OrderSummaryReflectsShippingOption) {
30 // In MI state, shipping is $5.00.
31 autofill::AutofillProfile michigan = autofill::test::GetFullProfile2();
32 michigan.set_use_count(100U);
33 AddAutofillProfile(michigan);
34 // A Canadian address will have no shipping options.
35 autofill::AutofillProfile canada = autofill::test::GetFullProfile();
36 canada.SetRawInfo(autofill::ADDRESS_HOME_COUNTRY, base::ASCIIToUTF16("CA"));
37 canada.set_use_count(50U);
38 AddAutofillProfile(canada);
39
40 InvokePaymentRequestUI();
41
42 // There is no shipping option section, because no address has been selected.
43 EXPECT_EQ(nullptr, dialog_view()->GetViewByID(static_cast<int>(
44 DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION)));
45
46 // Go to the shipping address screen and select the first address (MI state).
47 OpenShippingAddressSectionScreen();
48 ResetEventObserverForSequence(std::list<DialogEvent>{
49 DialogEvent::BACK_NAVIGATION, DialogEvent::SPEC_DONE_UPDATING});
50 ClickOnChildInListViewAndWait(
51 /* child_index=*/0, /*total_num_children=*/2,
52 DialogViewID::SHIPPING_ADDRESS_SHEET_LIST_VIEW);
53
54 // Michigan address is selected and has standard shipping.
55 std::vector<base::string16> shipping_address_labels = GetThreeLineLabelValues(
56 DialogViewID::PAYMENT_SHEET_SHIPPING_ADDRESS_SECTION);
57 EXPECT_EQ(base::ASCIIToUTF16("Jane A. Smith"), shipping_address_labels[0]);
58 EXPECT_EQ(
59 base::ASCIIToUTF16("ACME, 123 Main Street, Unit 1, Greensdale, MI 48838"),
60 shipping_address_labels[1]);
61 EXPECT_EQ(base::ASCIIToUTF16("13105557889"), shipping_address_labels[2]);
62
63 // The shipping option section exists, and the shipping option is shown.
64 std::vector<base::string16> shipping_option_labels =
65 GetShippingOptionLabelValues(
66 DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION);
67 EXPECT_EQ(base::ASCIIToUTF16("Standard shipping in US"),
68 shipping_option_labels[0]);
69 EXPECT_EQ(base::ASCIIToUTF16("$5.00"), shipping_option_labels[1]);
70
71 // Go to the shipping address screen and select the second address (Canada).
72 OpenShippingAddressSectionScreen();
73 ResetEventObserverForSequence(std::list<DialogEvent>{
74 DialogEvent::BACK_NAVIGATION, DialogEvent::SPEC_DONE_UPDATING});
75 ClickOnChildInListViewAndWait(
76 /* child_index=*/1, /*total_num_children=*/2,
77 DialogViewID::SHIPPING_ADDRESS_SHEET_LIST_VIEW);
78
79 // There is no longer shipping option section, because no shipping options are
80 // available for Canada.
81 EXPECT_EQ(nullptr, dialog_view()->GetViewByID(static_cast<int>(
82 DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION)));
83 }
84
85 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/shipping_option_view_controller.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698