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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/DisplayItemListTest.cpp

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: Rebase Created 3 years, 10 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "platform/graphics/paint/DisplayItemList.h" 5 #include "platform/graphics/paint/DisplayItemList.h"
6 6
7 #include "SkPictureRecorder.h"
8 #include "SkTypes.h" 7 #include "SkTypes.h"
9 #include "platform/graphics/paint/DrawingDisplayItem.h" 8 #include "platform/graphics/paint/DrawingDisplayItem.h"
9 #include "platform/graphics/paint/PaintFlags.h"
10 #include "platform/graphics/paint/PaintRecorder.h"
10 #include "platform/graphics/paint/SubsequenceDisplayItem.h" 11 #include "platform/graphics/paint/SubsequenceDisplayItem.h"
11 #include "platform/graphics/skia/SkiaUtils.h" 12 #include "platform/graphics/skia/SkiaUtils.h"
12 #include "platform/testing/FakeDisplayItemClient.h" 13 #include "platform/testing/FakeDisplayItemClient.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace blink { 16 namespace blink {
16 namespace { 17 namespace {
17 18
18 #define EXPECT_RECT_EQ(expected, actual) \ 19 #define EXPECT_RECT_EQ(expected, actual) \
19 do { \ 20 do { \
20 const IntRect& actualRect = actual; \ 21 const IntRect& actualRect = actual; \
21 EXPECT_EQ(expected.x(), actualRect.x()); \ 22 EXPECT_EQ(expected.x(), actualRect.x()); \
22 EXPECT_EQ(expected.y(), actualRect.y()); \ 23 EXPECT_EQ(expected.y(), actualRect.y()); \
23 EXPECT_EQ(expected.width(), actualRect.width()); \ 24 EXPECT_EQ(expected.width(), actualRect.width()); \
24 EXPECT_EQ(expected.height(), actualRect.height()); \ 25 EXPECT_EQ(expected.height(), actualRect.height()); \
25 } while (false) 26 } while (false)
26 27
27 static const size_t kDefaultListBytes = 10 * 1024; 28 static const size_t kDefaultListBytes = 10 * 1024;
28 29
29 class DisplayItemListTest : public ::testing::Test { 30 class DisplayItemListTest : public ::testing::Test {
30 public: 31 public:
31 DisplayItemListTest() : m_list(kDefaultListBytes) {} 32 DisplayItemListTest() : m_list(kDefaultListBytes) {}
32 33
33 DisplayItemList m_list; 34 DisplayItemList m_list;
34 FakeDisplayItemClient m_client; 35 FakeDisplayItemClient m_client;
35 }; 36 };
36 37
37 static sk_sp<SkPicture> createRectPicture(const IntRect& bounds) { 38 static sk_sp<PaintRecord> createRectPicture(const IntRect& bounds) {
38 SkPictureRecorder recorder; 39 PaintRecorder recorder;
39 SkCanvas* canvas = recorder.beginRecording(bounds.width(), bounds.height()); 40 PaintCanvas* canvas =
41 recorder.beginRecording(bounds.width(), bounds.height());
40 canvas->drawRect( 42 canvas->drawRect(
41 SkRect::MakeXYWH(bounds.x(), bounds.y(), bounds.width(), bounds.height()), 43 SkRect::MakeXYWH(bounds.x(), bounds.y(), bounds.width(), bounds.height()),
42 SkPaint()); 44 PaintFlags());
43 return recorder.finishRecordingAsPicture(); 45 return recorder.finishRecordingAsPicture();
44 } 46 }
45 47
46 TEST_F(DisplayItemListTest, AppendVisualRect_Simple) { 48 TEST_F(DisplayItemListTest, AppendVisualRect_Simple) {
47 IntRect drawingBounds(5, 6, 7, 8); 49 IntRect drawingBounds(5, 6, 7, 8);
48 m_list.allocateAndConstruct<DrawingDisplayItem>( 50 m_list.allocateAndConstruct<DrawingDisplayItem>(
49 m_client, DisplayItem::Type::kDocumentBackground, 51 m_client, DisplayItem::Type::kDocumentBackground,
50 createRectPicture(drawingBounds), true); 52 createRectPicture(drawingBounds), true);
51 m_list.appendVisualRect(drawingBounds); 53 m_list.appendVisualRect(drawingBounds);
52 54
(...skipping 21 matching lines...) Expand all
74 m_list.allocateAndConstruct<EndSubsequenceDisplayItem>(m_client); 76 m_list.allocateAndConstruct<EndSubsequenceDisplayItem>(m_client);
75 m_list.appendVisualRect(subsequenceBounds); 77 m_list.appendVisualRect(subsequenceBounds);
76 78
77 EXPECT_EQ(static_cast<size_t>(3), m_list.size()); 79 EXPECT_EQ(static_cast<size_t>(3), m_list.size());
78 EXPECT_RECT_EQ(subsequenceBounds, m_list.visualRect(0)); 80 EXPECT_RECT_EQ(subsequenceBounds, m_list.visualRect(0));
79 EXPECT_RECT_EQ(drawingBounds, m_list.visualRect(1)); 81 EXPECT_RECT_EQ(drawingBounds, m_list.visualRect(1));
80 EXPECT_RECT_EQ(subsequenceBounds, m_list.visualRect(2)); 82 EXPECT_RECT_EQ(subsequenceBounds, m_list.visualRect(2));
81 } 83 }
82 } // namespace 84 } // namespace
83 } // namespace blink 85 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698