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

Unified Diff: components/payments/content/payment_request_state_unittest.cc

Issue 2789093002: [Payments] Desktop: implement shipping address/option change (Closed)
Patch Set: fixed test 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 side-by-side diff with in-line comments
Download patch
Index: components/payments/content/payment_request_state_unittest.cc
diff --git a/components/payments/content/payment_request_state_unittest.cc b/components/payments/content/payment_request_state_unittest.cc
index 814206cbdcdb0d54685e3d183ff361fd968ec200..0a628e95c13f3370fe1d9bd965ea687939b10add 100644
--- a/components/payments/content/payment_request_state_unittest.cc
+++ b/components/payments/content/payment_request_state_unittest.cc
@@ -52,6 +52,9 @@ class PaymentRequestStateTest : public testing::Test,
void OnPaymentResponseAvailable(mojom::PaymentResponsePtr response) override {
payment_response_ = std::move(response);
};
+ void OnShippingOptionIdSelected(
+ const std::string& shipping_option_id) override {}
+ void OnShippingAddressSelected(mojom::PaymentAddressPtr address) override {}
void RecreateStateWithOptionsAndDetails(
mojom::PaymentOptionsPtr options,
@@ -201,28 +204,6 @@ TEST_F(PaymentRequestStateTest, CanMakePayment_BasicCard_SpecificUnavailable) {
EXPECT_FALSE(state()->CanMakePayment());
}
-// Test that the last shipping option is selected.
-TEST_F(PaymentRequestStateTest, ShippingOptionsSelection) {
- std::vector<mojom::PaymentShippingOptionPtr> shipping_options;
- mojom::PaymentShippingOptionPtr option = mojom::PaymentShippingOption::New();
- option->id = "option:1";
- option->selected = false;
- shipping_options.push_back(std::move(option));
- mojom::PaymentShippingOptionPtr option2 = mojom::PaymentShippingOption::New();
- option2->id = "option:2";
- option2->selected = true;
- shipping_options.push_back(std::move(option2));
- mojom::PaymentDetailsPtr details = mojom::PaymentDetails::New();
- details->shipping_options = std::move(shipping_options);
-
- mojom::PaymentOptionsPtr options = mojom::PaymentOptions::New();
- options->request_shipping = true;
- RecreateStateWithOptionsAndDetails(std::move(options), std::move(details),
- GetMethodDataForVisa());
-
- EXPECT_EQ("option:2", state()->selected_shipping_option()->id);
-}
-
TEST_F(PaymentRequestStateTest, ReadyToPay_DefaultSelections) {
mojom::PaymentOptionsPtr options = mojom::PaymentOptions::New();
options->request_shipping = true;
@@ -231,6 +212,13 @@ TEST_F(PaymentRequestStateTest, ReadyToPay_DefaultSelections) {
options->request_payer_email = true;
RecreateStateWithOptions(std::move(options));
+ // Because there are shipping options, no address is selected by default.
+ // Therefore we are not ready to pay.
+ EXPECT_FALSE(state()->is_ready_to_pay());
+
+ state()->SetSelectedShippingProfile(test_address());
+ EXPECT_EQ(1, num_on_selected_information_changed_called());
+
EXPECT_TRUE(state()->is_ready_to_pay());
}

Powered by Google App Engine
This is Rietveld 408576698