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" |
11 #include "core/layout/LayoutView.h" | 11 #include "core/layout/LayoutView.h" |
12 #include "core/paint/PaintLayer.h" | 12 #include "core/paint/PaintLayer.h" |
13 #include "core/paint/PaintLayerPainter.h" | 13 #include "core/paint/PaintLayerPainter.h" |
14 #include "core/testing/DummyPageHolder.h" | 14 #include "core/testing/DummyPageHolder.h" |
15 #include "platform/graphics/GraphicsContext.h" | 15 #include "platform/graphics/GraphicsContext.h" |
16 #include "platform/graphics/paint/DrawingRecorder.h" | 16 #include "platform/graphics/paint/DrawingRecorder.h" |
17 #include "platform/graphics/paint/SkPictureBuilder.h" | 17 #include "platform/graphics/paint/SkPictureBuilder.h" |
18 #include "platform/scroll/ScrollbarTheme.h" | 18 #include "platform/scroll/ScrollbarTheme.h" |
19 #include "platform/text/TextStream.h" | 19 #include "platform/text/TextStream.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "third_party/skia/include/core/SkCanvas.h" | 21 #include "third_party/skia/include/core/SkCanvas.h" |
| 22 #include <memory> |
22 | 23 |
23 namespace blink { | 24 namespace blink { |
24 | 25 |
25 const int kPageWidth = 800; | 26 const int kPageWidth = 800; |
26 const int kPageHeight = 600; | 27 const int kPageHeight = 600; |
27 | 28 |
28 class MockPrintContext : public PrintContext { | 29 class MockPrintContext : public PrintContext { |
29 public: | 30 public: |
30 MockPrintContext(LocalFrame* frame) : PrintContext(frame) { } | 31 MockPrintContext(LocalFrame* frame) : PrintContext(frame) { } |
31 | 32 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 122 } |
122 | 123 |
123 static String htmlForAnchor(int x, int y, const char* name, const char* text
Content) | 124 static String htmlForAnchor(int x, int y, const char* name, const char* text
Content) |
124 { | 125 { |
125 TextStream ts; | 126 TextStream ts; |
126 ts << "<a name='" << name << "' style='position: absolute; left: " << x
<< "px; top: " << y << "px'>" << textContent << "</a>"; | 127 ts << "<a name='" << name << "' style='position: absolute; left: " << x
<< "px; top: " << y << "px'>" << textContent << "</a>"; |
127 return ts.release(); | 128 return ts.release(); |
128 } | 129 } |
129 | 130 |
130 private: | 131 private: |
131 OwnPtr<DummyPageHolder> m_pageHolder; | 132 std::unique_ptr<DummyPageHolder> m_pageHolder; |
132 Persistent<MockPrintContext> m_printContext; | 133 Persistent<MockPrintContext> m_printContext; |
133 }; | 134 }; |
134 | 135 |
135 class PrintContextFrameTest : public PrintContextTest { | 136 class PrintContextFrameTest : public PrintContextTest { |
136 public: | 137 public: |
137 PrintContextFrameTest() : PrintContextTest(SingleChildFrameLoaderClient::cre
ate()) { } | 138 PrintContextFrameTest() : PrintContextTest(SingleChildFrameLoaderClient::cre
ate()) { } |
138 }; | 139 }; |
139 | 140 |
140 #define EXPECT_SKRECT_EQ(expectedX, expectedY, expectedWidth, expectedHeight, ac
tualRect) \ | 141 #define EXPECT_SKRECT_EQ(expectedX, expectedY, expectedWidth, expectedHeight, ac
tualRect) \ |
141 EXPECT_EQ(expectedX, actualRect.x()); \ | 142 EXPECT_EQ(expectedX, actualRect.x()); \ |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 ASSERT_EQ(3u, operations.size()); | 323 ASSERT_EQ(3u, operations.size()); |
323 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type); | 324 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. | 325 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); | 326 EXPECT_EQ(MockCanvas::DrawRect, operations[1].type); |
326 EXPECT_SKRECT_EQ(150, 160, 170, 180, operations[1].rect); | 327 EXPECT_SKRECT_EQ(150, 160, 170, 180, operations[1].rect); |
327 EXPECT_EQ(MockCanvas::DrawRect, operations[2].type); | 328 EXPECT_EQ(MockCanvas::DrawRect, operations[2].type); |
328 EXPECT_SKRECT_EQ(250, 260, 270, 280, operations[2].rect); | 329 EXPECT_SKRECT_EQ(250, 260, 270, 280, operations[2].rect); |
329 } | 330 } |
330 | 331 |
331 } // namespace blink | 332 } // namespace blink |
OLD | NEW |