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