Chromium Code Reviews| Index: Source/platform/graphics/GraphicsContextTest.cpp |
| diff --git a/Source/platform/graphics/GraphicsContextTest.cpp b/Source/platform/graphics/GraphicsContextTest.cpp |
| index fe18ecc722515bab7c72bec37a99dab507061de7..3a44f91495088476d0f645b5b8f981417a0e6efb 100644 |
| --- a/Source/platform/graphics/GraphicsContextTest.cpp |
| +++ b/Source/platform/graphics/GraphicsContextTest.cpp |
| @@ -1154,45 +1154,36 @@ TEST(GraphicsContextTest, RecordingTotalMatrix) |
| EXPECT_EQ(context.getCTM(), controlContext.getCTM()); |
| } |
|
chrishtr
2014/09/05 18:28:13
Add a test with clips or transforms?
Stephen Chennney
2014/09/05 18:36:19
Can do, but not trivial because you can't inspect
chrishtr
2014/09/05 18:40:58
Ok. For now we can test that clips & transforms ar
|
| -TEST(GraphicsContextTest, DisplayList) |
| +TEST(GraphicsContextTest, RecordingCanvas) |
| { |
| - FloatRect rect(0, 0, 1, 1); |
| - RefPtr<DisplayList> dl = adoptRef(new DisplayList(rect)); |
| - |
| - // picture() returns 0 initially |
| - SkPicture* pic = dl->picture(); |
| - EXPECT_FALSE(pic); |
| + SkBitmap bitmap; |
| + ASSERT_TRUE(bitmap.allocN32Pixels(1, 1)); |
| + bitmap.eraseColor(0); |
| + SkCanvas canvas(bitmap); |
| + GraphicsContext context(&canvas); |
| - // endRecording without a beginRecording does nothing |
| - dl->endRecording(); |
| - pic = dl->picture(); |
| - EXPECT_FALSE(pic); |
| + FloatRect rect(0, 0, 1, 1); |
| // Two beginRecordings in a row generate two canvases. |
| // Unfortunately the new one could be allocated in the same |
| // spot as the old one so ref the first one to prolong its life. |
| - IntSize size(1, 1); |
| - SkCanvas* canvas1 = dl->beginRecording(size); |
| + context.beginRecording(rect); |
| + SkCanvas* canvas1 = context.canvas(); |
| EXPECT_TRUE(canvas1); |
| - canvas1->ref(); |
| - SkCanvas* canvas2 = dl->beginRecording(size); |
| + context.beginRecording(rect); |
| + SkCanvas* canvas2 = context.canvas(); |
| EXPECT_TRUE(canvas2); |
| EXPECT_NE(canvas1, canvas2); |
| EXPECT_EQ(1, canvas1->getRefCnt()); |
| - canvas1->unref(); |
| - |
| - EXPECT_TRUE(dl->isRecording()); |
| - |
| - // picture() returns 0 during recording |
| - pic = dl->picture(); |
| - EXPECT_FALSE(pic); |
| // endRecording finally makes the picture accessible |
| - dl->endRecording(); |
| - pic = dl->picture(); |
| + RefPtr<DisplayList> dl = context.endRecording(); |
| + SkPicture* pic = dl->picture(); |
| EXPECT_TRUE(pic); |
| EXPECT_EQ(1, pic->getRefCnt()); |
| + |
| + context.endRecording(); |
| } |
| } // namespace |