| 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 #include "core/page/PrintContext.h" | 5 #include "core/page/PrintContext.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/html/HTMLElement.h" | 9 #include "core/html/HTMLElement.h" |
| 10 #include "core/layout/LayoutTestHelper.h" | 10 #include "core/layout/LayoutTestHelper.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 } | 69 } |
| 70 | 70 |
| 71 const Vector<Operation>& recordedOperations() const { return m_recordedOpera
tions; } | 71 const Vector<Operation>& recordedOperations() const { return m_recordedOpera
tions; } |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 Vector<Operation> m_recordedOperations; | 74 Vector<Operation> m_recordedOperations; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 class PrintContextTest : public RenderingTest { | 77 class PrintContextTest : public RenderingTest { |
| 78 protected: | 78 protected: |
| 79 explicit PrintContextTest(PassOwnPtrWillBeRawPtr<FrameLoaderClient> frameLoa
derClient = nullptr) | 79 explicit PrintContextTest(RawPtr<FrameLoaderClient> frameLoaderClient = null
ptr) |
| 80 : RenderingTest(frameLoaderClient) { } | 80 : RenderingTest(frameLoaderClient) { } |
| 81 | 81 |
| 82 void SetUp() override | 82 void SetUp() override |
| 83 { | 83 { |
| 84 RenderingTest::SetUp(); | 84 RenderingTest::SetUp(); |
| 85 m_printContext = adoptPtrWillBeNoop(new MockPrintContext(document().fram
e())); | 85 m_printContext = (new MockPrintContext(document().frame())); |
| 86 } | 86 } |
| 87 | 87 |
| 88 MockPrintContext& printContext() { return *m_printContext.get(); } | 88 MockPrintContext& printContext() { return *m_printContext.get(); } |
| 89 | 89 |
| 90 void setBodyInnerHTML(String bodyContent) | 90 void setBodyInnerHTML(String bodyContent) |
| 91 { | 91 { |
| 92 document().body()->setAttribute(HTMLNames::styleAttr, "margin: 0"); | 92 document().body()->setAttribute(HTMLNames::styleAttr, "margin: 0"); |
| 93 document().body()->setInnerHTML(bodyContent, ASSERT_NO_EXCEPTION); | 93 document().body()->setInnerHTML(bodyContent, ASSERT_NO_EXCEPTION); |
| 94 } | 94 } |
| 95 | 95 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 static String htmlForAnchor(int x, int y, const char* name, const char* text
Content) | 128 static String htmlForAnchor(int x, int y, const char* name, const char* text
Content) |
| 129 { | 129 { |
| 130 TextStream ts; | 130 TextStream ts; |
| 131 ts << "<a name='" << name << "' style='position: absolute; left: " << x
<< "px; top: " << y << "px'>" << textContent << "</a>"; | 131 ts << "<a name='" << name << "' style='position: absolute; left: " << x
<< "px; top: " << y << "px'>" << textContent << "</a>"; |
| 132 return ts.release(); | 132 return ts.release(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 private: | 135 private: |
| 136 OwnPtr<DummyPageHolder> m_pageHolder; | 136 OwnPtr<DummyPageHolder> m_pageHolder; |
| 137 OwnPtrWillBePersistent<MockPrintContext> m_printContext; | 137 Persistent<MockPrintContext> m_printContext; |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 class PrintContextFrameTest : public PrintContextTest { | 140 class PrintContextFrameTest : public PrintContextTest { |
| 141 public: | 141 public: |
| 142 PrintContextFrameTest() : PrintContextTest(SingleChildFrameLoaderClient::cre
ate()) { } | 142 PrintContextFrameTest() : PrintContextTest(SingleChildFrameLoaderClient::cre
ate()) { } |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 #define EXPECT_SKRECT_EQ(expectedX, expectedY, expectedWidth, expectedHeight, ac
tualRect) \ | 145 #define EXPECT_SKRECT_EQ(expectedX, expectedY, expectedWidth, expectedHeight, ac
tualRect) \ |
| 146 EXPECT_EQ(expectedX, actualRect.x()); \ | 146 EXPECT_EQ(expectedX, actualRect.x()); \ |
| 147 EXPECT_EQ(expectedY, actualRect.y()); \ | 147 EXPECT_EQ(expectedY, actualRect.y()); \ |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 ASSERT_EQ(3u, operations.size()); | 327 ASSERT_EQ(3u, operations.size()); |
| 328 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type); | 328 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type); |
| 329 EXPECT_SKRECT_EQ(50, 60, 70, 80, operations[0].rect); // FIXME: the rect sho
uld be clipped. | 329 EXPECT_SKRECT_EQ(50, 60, 70, 80, operations[0].rect); // FIXME: the rect sho
uld be clipped. |
| 330 EXPECT_EQ(MockCanvas::DrawRect, operations[1].type); | 330 EXPECT_EQ(MockCanvas::DrawRect, operations[1].type); |
| 331 EXPECT_SKRECT_EQ(150, 160, 170, 180, operations[1].rect); | 331 EXPECT_SKRECT_EQ(150, 160, 170, 180, operations[1].rect); |
| 332 EXPECT_EQ(MockCanvas::DrawRect, operations[2].type); | 332 EXPECT_EQ(MockCanvas::DrawRect, operations[2].type); |
| 333 EXPECT_SKRECT_EQ(250, 260, 270, 280, operations[2].rect); | 333 EXPECT_SKRECT_EQ(250, 260, 270, 280, operations[2].rect); |
| 334 } | 334 } |
| 335 | 335 |
| 336 } // namespace blink | 336 } // namespace blink |
| OLD | NEW |