| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014, Google Inc. All rights reserved. | 2 * Copyright (c) 2014, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/dom/ActiveDOMObject.h" | 31 #include "core/dom/ActiveDOMObject.h" |
| 32 | 32 |
| 33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
| 34 #include "core/testing/DummyPageHolder.h" | 34 #include "core/testing/DummyPageHolder.h" |
| 35 #include "testing/gmock/include/gmock/gmock.h" | 35 #include "testing/gmock/include/gmock/gmock.h" |
| 36 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
| 37 #include <memory> |
| 37 | 38 |
| 38 namespace blink { | 39 namespace blink { |
| 39 | 40 |
| 40 class MockActiveDOMObject final : public GarbageCollectedFinalized<MockActiveDOM
Object>, public ActiveDOMObject { | 41 class MockActiveDOMObject final : public GarbageCollectedFinalized<MockActiveDOM
Object>, public ActiveDOMObject { |
| 41 USING_GARBAGE_COLLECTED_MIXIN(MockActiveDOMObject); | 42 USING_GARBAGE_COLLECTED_MIXIN(MockActiveDOMObject); |
| 42 public: | 43 public: |
| 43 explicit MockActiveDOMObject(ExecutionContext* context) : ActiveDOMObject(co
ntext) { } | 44 explicit MockActiveDOMObject(ExecutionContext* context) : ActiveDOMObject(co
ntext) { } |
| 44 | 45 |
| 45 DEFINE_INLINE_VIRTUAL_TRACE() | 46 DEFINE_INLINE_VIRTUAL_TRACE() |
| 46 { | 47 { |
| 47 ActiveDOMObject::trace(visitor); | 48 ActiveDOMObject::trace(visitor); |
| 48 } | 49 } |
| 49 | 50 |
| 50 MOCK_METHOD0(suspend, void()); | 51 MOCK_METHOD0(suspend, void()); |
| 51 MOCK_METHOD0(resume, void()); | 52 MOCK_METHOD0(resume, void()); |
| 52 MOCK_METHOD0(stop, void()); | 53 MOCK_METHOD0(stop, void()); |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 class ActiveDOMObjectTest : public ::testing::Test { | 56 class ActiveDOMObjectTest : public ::testing::Test { |
| 56 protected: | 57 protected: |
| 57 ActiveDOMObjectTest(); | 58 ActiveDOMObjectTest(); |
| 58 | 59 |
| 59 Document& srcDocument() const { return m_srcPageHolder->document(); } | 60 Document& srcDocument() const { return m_srcPageHolder->document(); } |
| 60 Document& destDocument() const { return m_destPageHolder->document(); } | 61 Document& destDocument() const { return m_destPageHolder->document(); } |
| 61 MockActiveDOMObject& activeDOMObject() { return *m_activeDOMObject; } | 62 MockActiveDOMObject& activeDOMObject() { return *m_activeDOMObject; } |
| 62 | 63 |
| 63 private: | 64 private: |
| 64 OwnPtr<DummyPageHolder> m_srcPageHolder; | 65 std::unique_ptr<DummyPageHolder> m_srcPageHolder; |
| 65 OwnPtr<DummyPageHolder> m_destPageHolder; | 66 std::unique_ptr<DummyPageHolder> m_destPageHolder; |
| 66 Persistent<MockActiveDOMObject> m_activeDOMObject; | 67 Persistent<MockActiveDOMObject> m_activeDOMObject; |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 ActiveDOMObjectTest::ActiveDOMObjectTest() | 70 ActiveDOMObjectTest::ActiveDOMObjectTest() |
| 70 : m_srcPageHolder(DummyPageHolder::create(IntSize(800, 600))) | 71 : m_srcPageHolder(DummyPageHolder::create(IntSize(800, 600))) |
| 71 , m_destPageHolder(DummyPageHolder::create(IntSize(800, 600))) | 72 , m_destPageHolder(DummyPageHolder::create(IntSize(800, 600))) |
| 72 , m_activeDOMObject(new MockActiveDOMObject(&m_srcPageHolder->document())) | 73 , m_activeDOMObject(new MockActiveDOMObject(&m_srcPageHolder->document())) |
| 73 { | 74 { |
| 74 m_activeDOMObject->suspendIfNeeded(); | 75 m_activeDOMObject->suspendIfNeeded(); |
| 75 } | 76 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 102 | 103 |
| 103 TEST_F(ActiveDOMObjectTest, MoveToStoppedDocument) | 104 TEST_F(ActiveDOMObjectTest, MoveToStoppedDocument) |
| 104 { | 105 { |
| 105 destDocument().detach(); | 106 destDocument().detach(); |
| 106 | 107 |
| 107 EXPECT_CALL(activeDOMObject(), stop()); | 108 EXPECT_CALL(activeDOMObject(), stop()); |
| 108 activeDOMObject().didMoveToNewExecutionContext(&destDocument()); | 109 activeDOMObject().didMoveToNewExecutionContext(&destDocument()); |
| 109 } | 110 } |
| 110 | 111 |
| 111 } // namespace blink | 112 } // namespace blink |
| OLD | NEW |