| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef LayoutTestHelper_h | 5 #ifndef LayoutTestHelper_h |
| 6 #define LayoutTestHelper_h | 6 #define LayoutTestHelper_h |
| 7 | 7 |
| 8 #include <gtest/gtest.h> |
| 9 #include <memory> |
| 10 |
| 8 #include "core/dom/Document.h" | 11 #include "core/dom/Document.h" |
| 9 #include "core/frame/FrameHost.h" | 12 #include "core/frame/FrameHost.h" |
| 10 #include "core/frame/FrameView.h" | 13 #include "core/frame/FrameView.h" |
| 14 #include "core/frame/LocalFrameClient.h" |
| 11 #include "core/frame/Settings.h" | 15 #include "core/frame/Settings.h" |
| 12 #include "core/html/HTMLElement.h" | 16 #include "core/html/HTMLElement.h" |
| 13 #include "core/layout/api/LayoutAPIShim.h" | 17 #include "core/layout/api/LayoutAPIShim.h" |
| 14 #include "core/layout/api/LayoutViewItem.h" | 18 #include "core/layout/api/LayoutViewItem.h" |
| 15 #include "core/loader/EmptyClients.h" | 19 #include "core/loader/EmptyClients.h" |
| 16 #include "core/testing/DummyPageHolder.h" | 20 #include "core/testing/DummyPageHolder.h" |
| 17 #include "wtf/Allocator.h" | 21 #include "wtf/Allocator.h" |
| 18 #include <gtest/gtest.h> | |
| 19 #include <memory> | |
| 20 | 22 |
| 21 namespace blink { | 23 namespace blink { |
| 22 | 24 |
| 23 class SingleChildFrameLoaderClient final : public EmptyFrameLoaderClient { | 25 class SingleChildFrameLoaderClient final : public EmptyLocalFrameClient { |
| 24 public: | 26 public: |
| 25 static SingleChildFrameLoaderClient* create() { | 27 static SingleChildFrameLoaderClient* create() { |
| 26 return new SingleChildFrameLoaderClient(); | 28 return new SingleChildFrameLoaderClient(); |
| 27 } | 29 } |
| 28 | 30 |
| 29 DEFINE_INLINE_VIRTUAL_TRACE() { | 31 DEFINE_INLINE_VIRTUAL_TRACE() { |
| 30 visitor->trace(m_child); | 32 visitor->trace(m_child); |
| 31 EmptyFrameLoaderClient::trace(visitor); | 33 EmptyLocalFrameClient::trace(visitor); |
| 32 } | 34 } |
| 33 | 35 |
| 34 // FrameLoaderClient overrides: | 36 // FrameLoaderClient overrides: |
| 35 LocalFrame* firstChild() const override { return m_child.get(); } | 37 LocalFrame* firstChild() const override { return m_child.get(); } |
| 36 LocalFrame* createFrame(const FrameLoadRequest&, | 38 LocalFrame* createFrame(const FrameLoadRequest&, |
| 37 const AtomicString& name, | 39 const AtomicString& name, |
| 38 HTMLFrameOwnerElement*) override; | 40 HTMLFrameOwnerElement*) override; |
| 39 | 41 |
| 40 void didDetachChild() { m_child = nullptr; } | 42 void didDetachChild() { m_child = nullptr; } |
| 41 | 43 |
| 42 private: | 44 private: |
| 43 explicit SingleChildFrameLoaderClient() {} | 45 explicit SingleChildFrameLoaderClient() {} |
| 44 | 46 |
| 45 Member<LocalFrame> m_child; | 47 Member<LocalFrame> m_child; |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 class FrameLoaderClientWithParent final : public EmptyFrameLoaderClient { | 50 class FrameLoaderClientWithParent final : public EmptyLocalFrameClient { |
| 49 public: | 51 public: |
| 50 static FrameLoaderClientWithParent* create(LocalFrame* parent) { | 52 static FrameLoaderClientWithParent* create(LocalFrame* parent) { |
| 51 return new FrameLoaderClientWithParent(parent); | 53 return new FrameLoaderClientWithParent(parent); |
| 52 } | 54 } |
| 53 | 55 |
| 54 DEFINE_INLINE_VIRTUAL_TRACE() { | 56 DEFINE_INLINE_VIRTUAL_TRACE() { |
| 55 visitor->trace(m_parent); | 57 visitor->trace(m_parent); |
| 56 EmptyFrameLoaderClient::trace(visitor); | 58 EmptyLocalFrameClient::trace(visitor); |
| 57 } | 59 } |
| 58 | 60 |
| 59 // FrameClient overrides: | 61 // FrameClient overrides: |
| 60 void detached(FrameDetachType) override; | 62 void detached(FrameDetachType) override; |
| 61 LocalFrame* parent() const override { return m_parent.get(); } | 63 LocalFrame* parent() const override { return m_parent.get(); } |
| 62 | 64 |
| 63 private: | 65 private: |
| 64 explicit FrameLoaderClientWithParent(LocalFrame* parent) : m_parent(parent) {} | 66 explicit FrameLoaderClientWithParent(LocalFrame* parent) : m_parent(parent) {} |
| 65 | 67 |
| 66 Member<LocalFrame> m_parent; | 68 Member<LocalFrame> m_parent; |
| 67 }; | 69 }; |
| 68 | 70 |
| 69 class RenderingTest : public testing::Test { | 71 class RenderingTest : public testing::Test { |
| 70 USING_FAST_MALLOC(RenderingTest); | 72 USING_FAST_MALLOC(RenderingTest); |
| 71 | 73 |
| 72 public: | 74 public: |
| 73 virtual FrameSettingOverrideFunction settingOverrider() const { | 75 virtual FrameSettingOverrideFunction settingOverrider() const { |
| 74 return nullptr; | 76 return nullptr; |
| 75 } | 77 } |
| 76 virtual ChromeClient& chromeClient() const; | 78 virtual ChromeClient& chromeClient() const; |
| 77 | 79 |
| 78 RenderingTest(FrameLoaderClient* = nullptr); | 80 RenderingTest(LocalFrameClient* = nullptr); |
| 79 | 81 |
| 80 protected: | 82 protected: |
| 81 void SetUp() override; | 83 void SetUp() override; |
| 82 void TearDown() override; | 84 void TearDown() override; |
| 83 | 85 |
| 84 Document& document() const { return m_pageHolder->document(); } | 86 Document& document() const { return m_pageHolder->document(); } |
| 85 LayoutView& layoutView() const { | 87 LayoutView& layoutView() const { |
| 86 return *toLayoutView( | 88 return *toLayoutView( |
| 87 LayoutAPIShim::layoutObjectFrom(document().view()->layoutViewItem())); | 89 LayoutAPIShim::layoutObjectFrom(document().view()->layoutViewItem())); |
| 88 } | 90 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 115 void loadAhem(); | 117 void loadAhem(); |
| 116 | 118 |
| 117 private: | 119 private: |
| 118 Persistent<FrameLoaderClient> m_frameLoaderClient; | 120 Persistent<FrameLoaderClient> m_frameLoaderClient; |
| 119 std::unique_ptr<DummyPageHolder> m_pageHolder; | 121 std::unique_ptr<DummyPageHolder> m_pageHolder; |
| 120 }; | 122 }; |
| 121 | 123 |
| 122 } // namespace blink | 124 } // namespace blink |
| 123 | 125 |
| 124 #endif // LayoutTestHelper_h | 126 #endif // LayoutTestHelper_h |
| OLD | NEW |