| 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/paint/RenderDrawingRecorder.h" | 6 #include "core/paint/RenderDrawingRecorder.h" |
| 7 | 7 |
| 8 #include "core/rendering/RenderLayer.h" | 8 #include "core/rendering/RenderLayer.h" |
| 9 #include "core/rendering/RenderView.h" | 9 #include "core/rendering/RenderView.h" |
| 10 #include "core/rendering/RenderingTestHelper.h" | 10 #include "core/rendering/RenderingTestHelper.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 54 } |
| 55 | 55 |
| 56 | 56 |
| 57 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Nothing) | 57 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Nothing) |
| 58 { | 58 { |
| 59 GraphicsContext context(nullptr, &rootDisplayItemList()); | 59 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 60 FloatRect bound = renderView()->viewRect(); | 60 FloatRect bound = renderView()->viewRect(); |
| 61 EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size()); | 61 EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size()); |
| 62 | 62 |
| 63 drawNothing(&context, renderView(), PaintPhaseForeground, bound); | 63 drawNothing(&context, renderView(), PaintPhaseForeground, bound); |
| 64 rootDisplayItemList().endNewPaints(); |
| 64 EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size()); | 65 EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size()); |
| 65 #ifndef NDEBUG | 66 #ifndef NDEBUG |
| 66 EXPECT_STREQ("Dummy", rootDisplayItemList().paintList()[0]->name()); | 67 EXPECT_STREQ("Dummy", rootDisplayItemList().paintList()[0]->name()); |
| 67 #endif | 68 #endif |
| 68 } | 69 } |
| 69 | 70 |
| 70 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Rect) | 71 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Rect) |
| 71 { | 72 { |
| 72 GraphicsContext context(nullptr, &rootDisplayItemList()); | 73 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 73 FloatRect bound = renderView()->viewRect(); | 74 FloatRect bound = renderView()->viewRect(); |
| 74 drawRect(&context, renderView(), PaintPhaseForeground, bound); | 75 drawRect(&context, renderView(), PaintPhaseForeground, bound); |
| 76 rootDisplayItemList().endNewPaints(); |
| 75 EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size()); | 77 EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size()); |
| 76 #ifndef NDEBUG | 78 #ifndef NDEBUG |
| 77 EXPECT_STREQ("Drawing", rootDisplayItemList().paintList()[0]->name()); | 79 EXPECT_STREQ("Drawing", rootDisplayItemList().paintList()[0]->name()); |
| 78 #endif | 80 #endif |
| 79 } | 81 } |
| 80 | 82 |
| 81 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Cached) | 83 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Cached) |
| 82 { | 84 { |
| 83 GraphicsContext context(nullptr, &rootDisplayItemList()); | 85 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 84 FloatRect bound = renderView()->viewRect(); | 86 FloatRect bound = renderView()->viewRect(); |
| 85 drawNothing(&context, renderView(), PaintPhaseBlockBackground, bound); | 87 drawNothing(&context, renderView(), PaintPhaseBlockBackground, bound); |
| 86 drawRect(&context, renderView(), PaintPhaseForeground, bound); | 88 drawRect(&context, renderView(), PaintPhaseForeground, bound); |
| 89 rootDisplayItemList().endNewPaints(); |
| 87 EXPECT_EQ((size_t)2, rootDisplayItemList().paintList().size()); | 90 EXPECT_EQ((size_t)2, rootDisplayItemList().paintList().size()); |
| 88 #ifndef NDEBUG | 91 #ifndef NDEBUG |
| 89 EXPECT_STREQ("Dummy", rootDisplayItemList().paintList()[0]->name()); | 92 EXPECT_STREQ("Dummy", rootDisplayItemList().paintList()[0]->name()); |
| 90 EXPECT_STREQ("Drawing", rootDisplayItemList().paintList()[1]->name()); | 93 EXPECT_STREQ("Drawing", rootDisplayItemList().paintList()[1]->name()); |
| 91 #endif | 94 #endif |
| 92 | 95 |
| 93 drawNothing(&context, renderView(), PaintPhaseBlockBackground, bound); | 96 drawNothing(&context, renderView(), PaintPhaseBlockBackground, bound); |
| 94 drawRect(&context, renderView(), PaintPhaseForeground, bound); | 97 drawRect(&context, renderView(), PaintPhaseForeground, bound); |
| 98 rootDisplayItemList().endNewPaints(); |
| 95 EXPECT_EQ((size_t)2, rootDisplayItemList().paintList().size()); | 99 EXPECT_EQ((size_t)2, rootDisplayItemList().paintList().size()); |
| 96 #ifndef NDEBUG | 100 #ifndef NDEBUG |
| 97 EXPECT_STREQ("Dummy", rootDisplayItemList().paintList()[0]->name()); | 101 EXPECT_STREQ("Dummy", rootDisplayItemList().paintList()[0]->name()); |
| 98 EXPECT_STREQ("Drawing", rootDisplayItemList().paintList()[1]->name()); | 102 EXPECT_STREQ("Drawing", rootDisplayItemList().paintList()[1]->name()); |
| 99 #endif | 103 #endif |
| 100 } | 104 } |
| 101 | 105 |
| 102 } | 106 } |
| 103 } | 107 } |
| OLD | NEW |