| 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 "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "wtf/OwnPtr.h" | 14 #include <memory> |
| 15 #include <utility> | 15 #include <utility> |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 class MockPaymentCompleter : public GarbageCollectedFinalized<MockPaymentComplet
er>, public PaymentCompleter { | 20 class MockPaymentCompleter : public GarbageCollectedFinalized<MockPaymentComplet
er>, public PaymentCompleter { |
| 21 USING_GARBAGE_COLLECTED_MIXIN(MockPaymentCompleter); | 21 USING_GARBAGE_COLLECTED_MIXIN(MockPaymentCompleter); |
| 22 WTF_MAKE_NONCOPYABLE(MockPaymentCompleter); | 22 WTF_MAKE_NONCOPYABLE(MockPaymentCompleter); |
| 23 | 23 |
| 24 public: | 24 public: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 44 : m_page(DummyPageHolder::create()) | 44 : m_page(DummyPageHolder::create()) |
| 45 { | 45 { |
| 46 } | 46 } |
| 47 | 47 |
| 48 ~PaymentResponseTest() override {} | 48 ~PaymentResponseTest() override {} |
| 49 | 49 |
| 50 ScriptState* getScriptState() { return ScriptState::forMainWorld(m_page->doc
ument().frame()); } | 50 ScriptState* getScriptState() { return ScriptState::forMainWorld(m_page->doc
ument().frame()); } |
| 51 ExceptionState& getExceptionState() { return m_exceptionState; } | 51 ExceptionState& getExceptionState() { return m_exceptionState; } |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 OwnPtr<DummyPageHolder> m_page; | 54 std::unique_ptr<DummyPageHolder> m_page; |
| 55 NonThrowableExceptionState m_exceptionState; | 55 NonThrowableExceptionState m_exceptionState; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 TEST_F(PaymentResponseTest, DataCopiedOver) | 58 TEST_F(PaymentResponseTest, DataCopiedOver) |
| 59 { | 59 { |
| 60 ScriptState::Scope scope(getScriptState()); | 60 ScriptState::Scope scope(getScriptState()); |
| 61 mojom::blink::PaymentResponsePtr input = mojom::blink::PaymentResponse::New(
); | 61 mojom::blink::PaymentResponsePtr input = mojom::blink::PaymentResponse::New(
); |
| 62 input->method_name = "foo"; | 62 input->method_name = "foo"; |
| 63 input->stringified_details = "{\"transactionId\": 123}"; | 63 input->stringified_details = "{\"transactionId\": 123}"; |
| 64 MockPaymentCompleter* completeCallback = new MockPaymentCompleter; | 64 MockPaymentCompleter* completeCallback = new MockPaymentCompleter; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(), false)); |
| 103 | 103 |
| 104 output.complete(getScriptState(), false); | 104 output.complete(getScriptState(), false); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace | 107 } // namespace |
| 108 } // namespace blink | 108 } // namespace blink |
| OLD | NEW |