| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/page/PrintContext.h" | 6 #include "core/page/PrintContext.h" |
| 7 | 7 |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/html/HTMLElement.h" | 9 #include "core/html/HTMLElement.h" |
| 10 #include "core/testing/DummyPageHolder.h" | 10 #include "core/testing/DummyPageHolder.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 DrawPoint | 35 DrawPoint |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 struct Operation { | 38 struct Operation { |
| 39 OperationType type; | 39 OperationType type; |
| 40 SkRect rect; | 40 SkRect rect; |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 MockCanvas() : SkCanvas(kPageWidth, kPageHeight) { } | 43 MockCanvas() : SkCanvas(kPageWidth, kPageHeight) { } |
| 44 | 44 |
| 45 virtual void drawRect(const SkRect& rect, const SkPaint& paint) OVERRIDE | 45 virtual void drawRect(const SkRect& rect, const SkPaint& paint) override |
| 46 { | 46 { |
| 47 ASSERT_TRUE(paint.getAnnotation()); | 47 ASSERT_TRUE(paint.getAnnotation()); |
| 48 Operation operation = { DrawRect, rect }; | 48 Operation operation = { DrawRect, rect }; |
| 49 m_recordedOperations.append(operation); | 49 m_recordedOperations.append(operation); |
| 50 } | 50 } |
| 51 | 51 |
| 52 virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[], c
onst SkPaint& paint) OVERRIDE | 52 virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[], c
onst SkPaint& paint) override |
| 53 { | 53 { |
| 54 ASSERT_EQ(1u, count); // Only called from drawPoint(). | 54 ASSERT_EQ(1u, count); // Only called from drawPoint(). |
| 55 ASSERT_TRUE(paint.getAnnotation()); | 55 ASSERT_TRUE(paint.getAnnotation()); |
| 56 Operation operation = { DrawPoint, SkRect::MakeXYWH(pts[0].x(), pts[0].y
(), 0, 0) }; | 56 Operation operation = { DrawPoint, SkRect::MakeXYWH(pts[0].x(), pts[0].y
(), 0, 0) }; |
| 57 m_recordedOperations.append(operation); | 57 m_recordedOperations.append(operation); |
| 58 } | 58 } |
| 59 | 59 |
| 60 const Vector<Operation>& recordedOperations() const { return m_recordedOpera
tions; } | 60 const Vector<Operation>& recordedOperations() const { return m_recordedOpera
tions; } |
| 61 | 61 |
| 62 private: | 62 private: |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 size_t firstIndex = operations[0].rect.x() == 50 ? 0 : 1; | 150 size_t firstIndex = operations[0].rect.x() == 50 ? 0 : 1; |
| 151 EXPECT_EQ(MockCanvas::DrawRect, operations[firstIndex].type); | 151 EXPECT_EQ(MockCanvas::DrawRect, operations[firstIndex].type); |
| 152 EXPECT_SKRECT_EQ(50, 60, 70, 80, operations[firstIndex].rect); | 152 EXPECT_SKRECT_EQ(50, 60, 70, 80, operations[firstIndex].rect); |
| 153 | 153 |
| 154 size_t secondIndex = firstIndex == 0 ? 1 : 0; | 154 size_t secondIndex = firstIndex == 0 ? 1 : 0; |
| 155 EXPECT_EQ(MockCanvas::DrawPoint, operations[secondIndex].type); | 155 EXPECT_EQ(MockCanvas::DrawPoint, operations[secondIndex].type); |
| 156 EXPECT_SKRECT_EQ(250, 260, 0, 0, operations[secondIndex].rect); | 156 EXPECT_SKRECT_EQ(250, 260, 0, 0, operations[secondIndex].rect); |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace blink | 159 } // namespace blink |
| OLD | NEW |