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 "core/testing/DummyPageHolder.h" | 10 #include "core/testing/DummyPageHolder.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 public: | 24 public: |
25 MockPaymentCompleter() | 25 MockPaymentCompleter() |
26 { | 26 { |
27 ON_CALL(*this, complete(testing::_, testing::_)) | 27 ON_CALL(*this, complete(testing::_, testing::_)) |
28 .WillByDefault(testing::ReturnPointee(&m_dummyPromise)); | 28 .WillByDefault(testing::ReturnPointee(&m_dummyPromise)); |
29 } | 29 } |
30 | 30 |
31 ~MockPaymentCompleter() override {} | 31 ~MockPaymentCompleter() override {} |
32 | 32 |
33 MOCK_METHOD2(complete, ScriptPromise(ScriptState*, bool success)); | 33 MOCK_METHOD2(complete, ScriptPromise(ScriptState*, const PaymentComplete res
ult)); |
34 | 34 |
35 DEFINE_INLINE_TRACE() {} | 35 DEFINE_INLINE_TRACE() {} |
36 | 36 |
37 private: | 37 private: |
38 ScriptPromise m_dummyPromise; | 38 ScriptPromise m_dummyPromise; |
39 }; | 39 }; |
40 | 40 |
41 class PaymentResponseTest : public testing::Test { | 41 class PaymentResponseTest : public testing::Test { |
42 public: | 42 public: |
43 PaymentResponseTest() | 43 PaymentResponseTest() |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 79 } |
80 | 80 |
81 TEST_F(PaymentResponseTest, CompleteCalledWithSuccess) | 81 TEST_F(PaymentResponseTest, CompleteCalledWithSuccess) |
82 { | 82 { |
83 mojom::blink::PaymentResponsePtr input = mojom::blink::PaymentResponse::New(
); | 83 mojom::blink::PaymentResponsePtr input = mojom::blink::PaymentResponse::New(
); |
84 input->method_name = "foo"; | 84 input->method_name = "foo"; |
85 input->stringified_details = "{\"transactionId\": 123}"; | 85 input->stringified_details = "{\"transactionId\": 123}"; |
86 MockPaymentCompleter* completeCallback = new MockPaymentCompleter; | 86 MockPaymentCompleter* completeCallback = new MockPaymentCompleter; |
87 PaymentResponse output(std::move(input), completeCallback); | 87 PaymentResponse output(std::move(input), completeCallback); |
88 | 88 |
89 EXPECT_CALL(*completeCallback, complete(getScriptState(), true)); | 89 EXPECT_CALL(*completeCallback, complete(getScriptState(), Success)); |
90 | 90 |
91 output.complete(getScriptState(), true); | 91 output.complete(getScriptState(), "success"); |
92 } | 92 } |
93 | 93 |
94 TEST_F(PaymentResponseTest, CompleteCalledWithFailure) | 94 TEST_F(PaymentResponseTest, CompleteCalledWithFailure) |
95 { | 95 { |
96 mojom::blink::PaymentResponsePtr input = mojom::blink::PaymentResponse::New(
); | 96 mojom::blink::PaymentResponsePtr input = mojom::blink::PaymentResponse::New(
); |
97 input->method_name = "foo"; | 97 input->method_name = "foo"; |
98 input->stringified_details = "{\"transactionId\": 123}"; | 98 input->stringified_details = "{\"transactionId\": 123}"; |
99 MockPaymentCompleter* completeCallback = new MockPaymentCompleter; | 99 MockPaymentCompleter* completeCallback = new MockPaymentCompleter; |
100 PaymentResponse output(std::move(input), completeCallback); | 100 PaymentResponse output(std::move(input), completeCallback); |
101 | 101 |
102 EXPECT_CALL(*completeCallback, complete(getScriptState(), false)); | 102 EXPECT_CALL(*completeCallback, complete(getScriptState(), Fail)); |
103 | 103 |
104 output.complete(getScriptState(), false); | 104 output.complete(getScriptState(), "fail"); |
105 } | 105 } |
106 | 106 |
107 } // namespace | 107 } // namespace |
108 } // namespace blink | 108 } // namespace blink |
OLD | NEW |