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

Side by Side Diff: third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp

Issue 2020913002: PaymentRequest: Rename ShippingAddress to PaymentAddress. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "modules/payments/PaymentRequest.h" 5 #include "modules/payments/PaymentRequest.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/JSONValuesForV8.h" 8 #include "bindings/core/v8/JSONValuesForV8.h"
9 #include "bindings/core/v8/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "core/dom/ExceptionCode.h" 10 #include "core/dom/ExceptionCode.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 216 }
217 217
218 TEST_F(PaymentRequestTest, RejectShowPromiseOnInvalidShippingAddress) 218 TEST_F(PaymentRequestTest, RejectShowPromiseOnInvalidShippingAddress)
219 { 219 {
220 ScriptState::Scope scope(getScriptState()); 220 ScriptState::Scope scope(getScriptState());
221 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St ring>(1, "foo"), buildPaymentDetailsForTest(), getExceptionState()); 221 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St ring>(1, "foo"), buildPaymentDetailsForTest(), getExceptionState());
222 EXPECT_FALSE(getExceptionState().hadException()); 222 EXPECT_FALSE(getExceptionState().hadException());
223 223
224 request->show(getScriptState()).then(MockFunction::expectNoCall(getScriptSta te()), MockFunction::expectCall(getScriptState())); 224 request->show(getScriptState()).then(MockFunction::expectNoCall(getScriptSta te()), MockFunction::expectCall(getScriptState()));
225 225
226 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnShippingAddress Change(mojom::blink::ShippingAddress::New()); 226 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnShippingAddress Change(mojom::blink::PaymentAddress::New());
227 } 227 }
228 228
229 TEST_F(PaymentRequestTest, RejectShowPromiseOnInvalidShippingAddressInResponse) 229 TEST_F(PaymentRequestTest, RejectShowPromiseOnInvalidShippingAddressInResponse)
230 { 230 {
231 ScriptState::Scope scope(getScriptState()); 231 ScriptState::Scope scope(getScriptState());
232 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St ring>(1, "foo"), buildPaymentDetailsForTest(), getExceptionState()); 232 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St ring>(1, "foo"), buildPaymentDetailsForTest(), getExceptionState());
233 EXPECT_FALSE(getExceptionState().hadException()); 233 EXPECT_FALSE(getExceptionState().hadException());
234 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N ew(); 234 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N ew();
235 response->shipping_address = mojom::blink::ShippingAddress::New(); 235 response->shipping_address = mojom::blink::PaymentAddress::New();
236 236
237 request->show(getScriptState()).then(MockFunction::expectNoCall(getScriptSta te()), MockFunction::expectCall(getScriptState())); 237 request->show(getScriptState()).then(MockFunction::expectNoCall(getScriptSta te()), MockFunction::expectCall(getScriptState()));
238 238
239 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse (std::move(response)); 239 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse (std::move(response));
240 } 240 }
241 241
242 TEST_F(PaymentRequestTest, DontRejectShowPromiseForValidShippingAddress) 242 TEST_F(PaymentRequestTest, DontRejectShowPromiseForValidShippingAddress)
243 { 243 {
244 ScriptState::Scope scope(getScriptState()); 244 ScriptState::Scope scope(getScriptState());
245 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St ring>(1, "foo"), buildPaymentDetailsForTest(), getExceptionState()); 245 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St ring>(1, "foo"), buildPaymentDetailsForTest(), getExceptionState());
246 EXPECT_FALSE(getExceptionState().hadException()); 246 EXPECT_FALSE(getExceptionState().hadException());
247 mojom::blink::ShippingAddressPtr shippingAddress = mojom::blink::ShippingAdd ress::New(); 247 mojom::blink::PaymentAddressPtr shippingAddress = mojom::blink::PaymentAddre ss::New();
248 shippingAddress->region_code = "US"; 248 shippingAddress->region_code = "US";
249 shippingAddress->language_code = "en"; 249 shippingAddress->language_code = "en";
250 shippingAddress->script_code = "Latn"; 250 shippingAddress->script_code = "Latn";
251 251
252 request->show(getScriptState()).then(MockFunction::expectNoCall(getScriptSta te()), MockFunction::expectNoCall(getScriptState())); 252 request->show(getScriptState()).then(MockFunction::expectNoCall(getScriptSta te()), MockFunction::expectNoCall(getScriptState()));
253 253
254 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnShippingAddress Change(std::move(shippingAddress)); 254 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnShippingAddress Change(std::move(shippingAddress));
255 } 255 }
256 256
257 TEST_F(PaymentRequestTest, ResolveShowPromiseWithValidShippingAddressInResponse) 257 TEST_F(PaymentRequestTest, ResolveShowPromiseWithValidShippingAddressInResponse)
258 { 258 {
259 ScriptState::Scope scope(getScriptState()); 259 ScriptState::Scope scope(getScriptState());
260 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St ring>(1, "foo"), buildPaymentDetailsForTest(), getExceptionState()); 260 PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<St ring>(1, "foo"), buildPaymentDetailsForTest(), getExceptionState());
261 EXPECT_FALSE(getExceptionState().hadException()); 261 EXPECT_FALSE(getExceptionState().hadException());
262 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N ew(); 262 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N ew();
263 response->shipping_address = mojom::blink::ShippingAddress::New(); 263 response->shipping_address = mojom::blink::PaymentAddress::New();
264 response->shipping_address->region_code = "US"; 264 response->shipping_address->region_code = "US";
265 response->shipping_address->language_code = "en"; 265 response->shipping_address->language_code = "en";
266 response->shipping_address->script_code = "Latn"; 266 response->shipping_address->script_code = "Latn";
267 267
268 request->show(getScriptState()).then(MockFunction::expectCall(getScriptState ()), MockFunction::expectNoCall(getScriptState())); 268 request->show(getScriptState()).then(MockFunction::expectCall(getScriptState ()), MockFunction::expectNoCall(getScriptState()));
269 269
270 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse (std::move(response)); 270 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse (std::move(response));
271 } 271 }
272 272
273 TEST_F(PaymentRequestTest, ResolveShowPromiseWithoutShippingAddressInResponse) 273 TEST_F(PaymentRequestTest, ResolveShowPromiseWithoutShippingAddressInResponse)
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 "\"shippingOptions\": [{\"id\": \"standardShippingOption\", \"label\": \ "Standard shipping\", \"amount\": {\"currency\": \"USD\", \"value\": \"5.00\"}}] }"; 463 "\"shippingOptions\": [{\"id\": \"standardShippingOption\", \"label\": \ "Standard shipping\", \"amount\": {\"currency\": \"USD\", \"value\": \"5.00\"}}] }";
464 464
465 request->onUpdatePaymentDetails(ScriptValue::from(getScriptState(), fromJSON String(getScriptState(), detail, getExceptionState()))); 465 request->onUpdatePaymentDetails(ScriptValue::from(getScriptState(), fromJSON String(getScriptState(), detail, getExceptionState())));
466 EXPECT_FALSE(getExceptionState().hadException()); 466 EXPECT_FALSE(getExceptionState().hadException());
467 467
468 EXPECT_EQ("standardShippingOption", request->shippingOption()); 468 EXPECT_EQ("standardShippingOption", request->shippingOption());
469 } 469 }
470 470
471 } // namespace 471 } // namespace
472 } // namespace blink 472 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698