| OLD | NEW | 
|---|
| 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/PaymentResponse.h" | 5 #include "modules/payments/PaymentResponse.h" | 
| 6 | 6 | 
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" | 
| 8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" | 
| 9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" | 
| 10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 25 | 25 | 
| 26 public: | 26 public: | 
| 27     MockPaymentCompleter() | 27     MockPaymentCompleter() | 
| 28     { | 28     { | 
| 29         ON_CALL(*this, complete(testing::_, testing::_)) | 29         ON_CALL(*this, complete(testing::_, testing::_)) | 
| 30             .WillByDefault(testing::ReturnPointee(&m_dummyPromise)); | 30             .WillByDefault(testing::ReturnPointee(&m_dummyPromise)); | 
| 31     } | 31     } | 
| 32 | 32 | 
| 33     ~MockPaymentCompleter() override {} | 33     ~MockPaymentCompleter() override {} | 
| 34 | 34 | 
| 35     MOCK_METHOD2(complete, ScriptPromise(ScriptState*, bool success)); | 35     MOCK_METHOD2(complete, ScriptPromise(ScriptState*, const PaymentComplete res
     ult)); | 
| 36 | 36 | 
| 37     DEFINE_INLINE_TRACE() {} | 37     DEFINE_INLINE_TRACE() {} | 
| 38 | 38 | 
| 39 private: | 39 private: | 
| 40     ScriptPromise m_dummyPromise; | 40     ScriptPromise m_dummyPromise; | 
| 41 }; | 41 }; | 
| 42 | 42 | 
| 43 TEST(PaymentResponseTest, DataCopiedOver) | 43 TEST(PaymentResponseTest, DataCopiedOver) | 
| 44 { | 44 { | 
| 45     V8TestingScope scope; | 45     V8TestingScope scope; | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 72 | 72 | 
| 73 TEST(PaymentResponseTest, CompleteCalledWithSuccess) | 73 TEST(PaymentResponseTest, CompleteCalledWithSuccess) | 
| 74 { | 74 { | 
| 75     V8TestingScope scope; | 75     V8TestingScope scope; | 
| 76     mojom::blink::PaymentResponsePtr input = buildPaymentResponseForTest(); | 76     mojom::blink::PaymentResponsePtr input = buildPaymentResponseForTest(); | 
| 77     input->method_name = "foo"; | 77     input->method_name = "foo"; | 
| 78     input->stringified_details = "{\"transactionId\": 123}"; | 78     input->stringified_details = "{\"transactionId\": 123}"; | 
| 79     MockPaymentCompleter* completeCallback = new MockPaymentCompleter; | 79     MockPaymentCompleter* completeCallback = new MockPaymentCompleter; | 
| 80     PaymentResponse output(std::move(input), completeCallback); | 80     PaymentResponse output(std::move(input), completeCallback); | 
| 81 | 81 | 
| 82     EXPECT_CALL(*completeCallback, complete(scope.getScriptState(), true)); | 82     EXPECT_CALL(*completeCallback, complete(scope.getScriptState(), Success)); | 
| 83 | 83 | 
| 84     output.complete(scope.getScriptState(), true); | 84     output.complete(scope.getScriptState(), "success"); | 
| 85 } | 85 } | 
| 86 | 86 | 
| 87 TEST(PaymentResponseTest, CompleteCalledWithFailure) | 87 TEST(PaymentResponseTest, CompleteCalledWithFailure) | 
| 88 { | 88 { | 
| 89     V8TestingScope scope; | 89     V8TestingScope scope; | 
| 90     mojom::blink::PaymentResponsePtr input = buildPaymentResponseForTest(); | 90     mojom::blink::PaymentResponsePtr input = buildPaymentResponseForTest(); | 
| 91     input->method_name = "foo"; | 91     input->method_name = "foo"; | 
| 92     input->stringified_details = "{\"transactionId\": 123}"; | 92     input->stringified_details = "{\"transactionId\": 123}"; | 
| 93     MockPaymentCompleter* completeCallback = new MockPaymentCompleter; | 93     MockPaymentCompleter* completeCallback = new MockPaymentCompleter; | 
| 94     PaymentResponse output(std::move(input), completeCallback); | 94     PaymentResponse output(std::move(input), completeCallback); | 
| 95 | 95 | 
| 96     EXPECT_CALL(*completeCallback, complete(scope.getScriptState(), false)); | 96     EXPECT_CALL(*completeCallback, complete(scope.getScriptState(), Fail)); | 
| 97 | 97 | 
| 98     output.complete(scope.getScriptState(), false); | 98     output.complete(scope.getScriptState(), "fail"); | 
| 99 } | 99 } | 
| 100 | 100 | 
| 101 } // namespace | 101 } // namespace | 
| 102 } // namespace blink | 102 } // namespace blink | 
| OLD | NEW | 
|---|