Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: third_party/WebKit/Source/core/page/PrintContextTest.cpp

Issue 1766723003: revise unittest for annotations in preparation for skia change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/SkAnnotation.h"
21 #include "third_party/skia/include/core/SkCanvas.h" 22 #include "third_party/skia/include/core/SkCanvas.h"
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) { }
(...skipping 14 matching lines...) Expand all
45 struct Operation { 46 struct Operation {
46 OperationType type; 47 OperationType type;
47 SkRect rect; 48 SkRect rect;
48 }; 49 };
49 50
50 MockCanvas() : SkCanvas(kPageWidth, kPageHeight) { } 51 MockCanvas() : SkCanvas(kPageWidth, kPageHeight) { }
51 52
52 #ifdef SK_SUPPORT_NEW_ANNOTATION_CANVAS_VIRTUAL 53 #ifdef SK_SUPPORT_NEW_ANNOTATION_CANVAS_VIRTUAL
53 void onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) o verride 54 void onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) o verride
54 { 55 {
55 if (rect.width() == 0 && rect.height()) { 56 if (rect.width() == 0 && rect.height() == 0) {
56 ASSERT_EQ(1u, count);
57 SkPoint point = getTotalMatrix().mapXY(rect.x(), rect.y()); 57 SkPoint point = getTotalMatrix().mapXY(rect.x(), rect.y());
58 Operation operation = { 58 Operation operation = {
59 DrawPoint, SkRect::MakeXYWH(point.x(), point.y(), 0, 0) }; 59 DrawPoint, SkRect::MakeXYWH(point.x(), point.y(), 0, 0) };
60 m_recordedOperations.append(operation); 60 m_recordedOperations.append(operation);
61 } else { 61 } else {
62 Operation operation = { DrawRect, rect }; 62 Operation operation = { DrawRect, rect };
63 getTotalMatrix().mapRect(&operation.rect); 63 getTotalMatrix().mapRect(&operation.rect);
64 m_recordedOperations.append(operation); 64 m_recordedOperations.append(operation);
65 } 65 }
66 } 66 }
67 #else 67 #else
68 void onDrawRect(const SkRect& rect, const SkPaint& paint) override 68 void onDrawRect(const SkRect& rect, const SkPaint& paint) override
69 { 69 {
70 if (!paint.getAnnotation()) 70 if (!paint.getAnnotation())
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 ASSERT_EQ(3u, operations.size()); 345 ASSERT_EQ(3u, operations.size());
346 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type); 346 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type);
347 EXPECT_SKRECT_EQ(50, 60, 70, 80, operations[0].rect); // FIXME: the rect sho uld be clipped. 347 EXPECT_SKRECT_EQ(50, 60, 70, 80, operations[0].rect); // FIXME: the rect sho uld be clipped.
348 EXPECT_EQ(MockCanvas::DrawRect, operations[1].type); 348 EXPECT_EQ(MockCanvas::DrawRect, operations[1].type);
349 EXPECT_SKRECT_EQ(150, 160, 170, 180, operations[1].rect); 349 EXPECT_SKRECT_EQ(150, 160, 170, 180, operations[1].rect);
350 EXPECT_EQ(MockCanvas::DrawRect, operations[2].type); 350 EXPECT_EQ(MockCanvas::DrawRect, operations[2].type);
351 EXPECT_SKRECT_EQ(250, 260, 270, 280, operations[2].rect); 351 EXPECT_SKRECT_EQ(250, 260, 270, 280, operations[2].rect);
352 } 352 }
353 353
354 } // namespace blink 354 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698