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> | |
38 | 37 |
39 namespace blink { | 38 namespace blink { |
40 | 39 |
41 class MockActiveDOMObject final : public GarbageCollectedFinalized<MockActiveDOM
Object>, public ActiveDOMObject { | 40 class MockActiveDOMObject final : public GarbageCollectedFinalized<MockActiveDOM
Object>, public ActiveDOMObject { |
42 USING_GARBAGE_COLLECTED_MIXIN(MockActiveDOMObject); | 41 USING_GARBAGE_COLLECTED_MIXIN(MockActiveDOMObject); |
43 public: | 42 public: |
44 explicit MockActiveDOMObject(ExecutionContext* context) : ActiveDOMObject(co
ntext) { } | 43 explicit MockActiveDOMObject(ExecutionContext* context) : ActiveDOMObject(co
ntext) { } |
45 | 44 |
46 DEFINE_INLINE_VIRTUAL_TRACE() | 45 DEFINE_INLINE_VIRTUAL_TRACE() |
47 { | 46 { |
48 ActiveDOMObject::trace(visitor); | 47 ActiveDOMObject::trace(visitor); |
49 } | 48 } |
50 | 49 |
51 MOCK_METHOD0(suspend, void()); | 50 MOCK_METHOD0(suspend, void()); |
52 MOCK_METHOD0(resume, void()); | 51 MOCK_METHOD0(resume, void()); |
53 MOCK_METHOD0(stop, void()); | 52 MOCK_METHOD0(stop, void()); |
54 }; | 53 }; |
55 | 54 |
56 class ActiveDOMObjectTest : public ::testing::Test { | 55 class ActiveDOMObjectTest : public ::testing::Test { |
57 protected: | 56 protected: |
58 ActiveDOMObjectTest(); | 57 ActiveDOMObjectTest(); |
59 | 58 |
60 Document& srcDocument() const { return m_srcPageHolder->document(); } | 59 Document& srcDocument() const { return m_srcPageHolder->document(); } |
61 Document& destDocument() const { return m_destPageHolder->document(); } | 60 Document& destDocument() const { return m_destPageHolder->document(); } |
62 MockActiveDOMObject& activeDOMObject() { return *m_activeDOMObject; } | 61 MockActiveDOMObject& activeDOMObject() { return *m_activeDOMObject; } |
63 | 62 |
64 private: | 63 private: |
65 std::unique_ptr<DummyPageHolder> m_srcPageHolder; | 64 OwnPtr<DummyPageHolder> m_srcPageHolder; |
66 std::unique_ptr<DummyPageHolder> m_destPageHolder; | 65 OwnPtr<DummyPageHolder> m_destPageHolder; |
67 Persistent<MockActiveDOMObject> m_activeDOMObject; | 66 Persistent<MockActiveDOMObject> m_activeDOMObject; |
68 }; | 67 }; |
69 | 68 |
70 ActiveDOMObjectTest::ActiveDOMObjectTest() | 69 ActiveDOMObjectTest::ActiveDOMObjectTest() |
71 : m_srcPageHolder(DummyPageHolder::create(IntSize(800, 600))) | 70 : m_srcPageHolder(DummyPageHolder::create(IntSize(800, 600))) |
72 , m_destPageHolder(DummyPageHolder::create(IntSize(800, 600))) | 71 , m_destPageHolder(DummyPageHolder::create(IntSize(800, 600))) |
73 , m_activeDOMObject(new MockActiveDOMObject(&m_srcPageHolder->document())) | 72 , m_activeDOMObject(new MockActiveDOMObject(&m_srcPageHolder->document())) |
74 { | 73 { |
75 m_activeDOMObject->suspendIfNeeded(); | 74 m_activeDOMObject->suspendIfNeeded(); |
76 } | 75 } |
(...skipping 26 matching lines...) Expand all Loading... |
103 | 102 |
104 TEST_F(ActiveDOMObjectTest, MoveToStoppedDocument) | 103 TEST_F(ActiveDOMObjectTest, MoveToStoppedDocument) |
105 { | 104 { |
106 destDocument().detach(); | 105 destDocument().detach(); |
107 | 106 |
108 EXPECT_CALL(activeDOMObject(), stop()); | 107 EXPECT_CALL(activeDOMObject(), stop()); |
109 activeDOMObject().didMoveToNewExecutionContext(&destDocument()); | 108 activeDOMObject().didMoveToNewExecutionContext(&destDocument()); |
110 } | 109 } |
111 | 110 |
112 } // namespace blink | 111 } // namespace blink |
OLD | NEW |