| 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" |
| 11 #include "modules/payments/PaymentCompleter.h" | 11 #include "modules/payments/PaymentCompleter.h" |
| 12 #include "modules/payments/PaymentTestHelper.h" | 12 #include "modules/payments/PaymentTestHelper.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "wtf/OwnPtr.h" | 15 #include <memory> |
| 16 #include <utility> | 16 #include <utility> |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 class MockPaymentCompleter : public GarbageCollectedFinalized<MockPaymentComplet
er>, public PaymentCompleter { | 21 class MockPaymentCompleter : public GarbageCollectedFinalized<MockPaymentComplet
er>, public PaymentCompleter { |
| 22 USING_GARBAGE_COLLECTED_MIXIN(MockPaymentCompleter); | 22 USING_GARBAGE_COLLECTED_MIXIN(MockPaymentCompleter); |
| 23 WTF_MAKE_NONCOPYABLE(MockPaymentCompleter); | 23 WTF_MAKE_NONCOPYABLE(MockPaymentCompleter); |
| 24 | 24 |
| 25 public: | 25 public: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 45 : m_page(DummyPageHolder::create()) | 45 : m_page(DummyPageHolder::create()) |
| 46 { | 46 { |
| 47 } | 47 } |
| 48 | 48 |
| 49 ~PaymentResponseTest() override {} | 49 ~PaymentResponseTest() override {} |
| 50 | 50 |
| 51 ScriptState* getScriptState() { return ScriptState::forMainWorld(m_page->doc
ument().frame()); } | 51 ScriptState* getScriptState() { return ScriptState::forMainWorld(m_page->doc
ument().frame()); } |
| 52 ExceptionState& getExceptionState() { return m_exceptionState; } | 52 ExceptionState& getExceptionState() { return m_exceptionState; } |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 OwnPtr<DummyPageHolder> m_page; | 55 std::unique_ptr<DummyPageHolder> m_page; |
| 56 NonThrowableExceptionState m_exceptionState; | 56 NonThrowableExceptionState m_exceptionState; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 TEST_F(PaymentResponseTest, DataCopiedOver) | 59 TEST_F(PaymentResponseTest, DataCopiedOver) |
| 60 { | 60 { |
| 61 ScriptState::Scope scope(getScriptState()); | 61 ScriptState::Scope scope(getScriptState()); |
| 62 mojom::blink::PaymentResponsePtr input = buildPaymentResponseForTest(); | 62 mojom::blink::PaymentResponsePtr input = buildPaymentResponseForTest(); |
| 63 input->method_name = "foo"; | 63 input->method_name = "foo"; |
| 64 input->total_amount->currency = "USD"; | 64 input->total_amount->currency = "USD"; |
| 65 input->total_amount->value = "5.00"; | 65 input->total_amount->value = "5.00"; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 MockPaymentCompleter* completeCallback = new MockPaymentCompleter; | 107 MockPaymentCompleter* completeCallback = new MockPaymentCompleter; |
| 108 PaymentResponse output(std::move(input), completeCallback); | 108 PaymentResponse output(std::move(input), completeCallback); |
| 109 | 109 |
| 110 EXPECT_CALL(*completeCallback, complete(getScriptState(), false)); | 110 EXPECT_CALL(*completeCallback, complete(getScriptState(), false)); |
| 111 | 111 |
| 112 output.complete(getScriptState(), false); | 112 output.complete(getScriptState(), false); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace | 115 } // namespace |
| 116 } // namespace blink | 116 } // namespace blink |
| OLD | NEW |