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

Side by Side Diff: Source/core/platform/graphics/chromium/Canvas2DLayerBridgeTest.cpp

Issue 22929012: Change Canvas2DLayerBridge to stay alive until last mailbox is returned. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Trivial fix for layout test failure Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 public: 50 public:
51 MOCK_METHOD0(flush, void(void)); 51 MOCK_METHOD0(flush, void(void));
52 MOCK_METHOD0(createTexture, unsigned(void)); 52 MOCK_METHOD0(createTexture, unsigned(void));
53 MOCK_METHOD1(deleteTexture, void(unsigned)); 53 MOCK_METHOD1(deleteTexture, void(unsigned));
54 54
55 virtual GrGLInterface* onCreateGrGLInterface() OVERRIDE { return 0; } 55 virtual GrGLInterface* onCreateGrGLInterface() OVERRIDE { return 0; }
56 }; 56 };
57 57
58 class FakeCanvas2DLayerBridge : public Canvas2DLayerBridge { 58 class FakeCanvas2DLayerBridge : public Canvas2DLayerBridge {
59 public: 59 public:
60 static PassOwnPtr<FakeCanvas2DLayerBridge> create(PassRefPtr<GraphicsContext 3D> context, SkDeferredCanvas* canvas, OpacityMode opacityMode) 60 static PassRefPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D> context, SkDeferredCanvas* canvas, OpacityMode opacityMode)
61 { 61 {
62 return adoptPtr(new FakeCanvas2DLayerBridge(context, canvas, opacityMode )); 62 return adoptRef(static_cast<Canvas2DLayerBridge*>(new FakeCanvas2DLayerB ridge(context, canvas, opacityMode)));
63 } 63 }
64 protected: 64 protected:
65 FakeCanvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, SkDeferredCan vas* canvas, OpacityMode opacityMode) : 65 FakeCanvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, SkDeferredCan vas* canvas, OpacityMode opacityMode) :
66 Canvas2DLayerBridge(context, canvas, opacityMode) 66 Canvas2DLayerBridge(context, canvas, opacityMode)
67 { } 67 { }
68 }; 68 };
69 69
70 } // namespace 70 } // namespace
71 71
72 class Canvas2DLayerBridgeTest : public Test { 72 class Canvas2DLayerBridgeTest : public Test {
73 protected: 73 protected:
74 void fullLifecycleTest() 74 void fullLifecycleTest()
75 { 75 {
76 RefPtr<GraphicsContext3D> mainContext = GraphicsContext3D::createGraphic sContextFromWebContext(adoptPtr(new MockCanvasContext)); 76 RefPtr<GraphicsContext3D> mainContext = GraphicsContext3D::createGraphic sContextFromWebContext(adoptPtr(new MockCanvasContext));
77 77
78 MockCanvasContext& mainMock = *static_cast<MockCanvasContext*>(mainConte xt->webContext()); 78 MockCanvasContext& mainMock = *static_cast<MockCanvasContext*>(mainConte xt->webContext());
79 79
80 SkImage::Info info = { 80 SkImage::Info info = {
81 300, 81 300,
82 150, 82 150,
83 SkImage::kPMColor_ColorType, 83 SkImage::kPMColor_ColorType,
84 SkImage::kPremul_AlphaType, 84 SkImage::kPremul_AlphaType,
85 }; 85 };
86 SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(SkSurface ::NewRaster(info))); 86 SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(SkSurface ::NewRaster(info)));
87 87
88 ::testing::Mock::VerifyAndClearExpectations(&mainMock); 88 ::testing::Mock::VerifyAndClearExpectations(&mainMock);
89 89
90 OwnPtr<Canvas2DLayerBridge> bridge = FakeCanvas2DLayerBridge::create(mai nContext.release(), canvas.get(), Canvas2DLayerBridge::NonOpaque); 90 Canvas2DLayerBridgePtr bridge = FakeCanvas2DLayerBridge::create(mainCont ext.release(), canvas.get(), Canvas2DLayerBridge::NonOpaque);
91 91
92 ::testing::Mock::VerifyAndClearExpectations(&mainMock); 92 ::testing::Mock::VerifyAndClearExpectations(&mainMock);
93 93
94 EXPECT_CALL(mainMock, flush()); 94 EXPECT_CALL(mainMock, flush());
95 unsigned textureId = bridge->backBufferTexture(); 95 unsigned textureId = bridge->backBufferTexture();
96 EXPECT_EQ(textureId, 0u); 96 EXPECT_EQ(textureId, 0u);
97 97
98 ::testing::Mock::VerifyAndClearExpectations(&mainMock); 98 ::testing::Mock::VerifyAndClearExpectations(&mainMock);
99 99
100 bridge.clear(); 100 bridge.clear();
101 101
102 ::testing::Mock::VerifyAndClearExpectations(&mainMock); 102 ::testing::Mock::VerifyAndClearExpectations(&mainMock);
103 } 103 }
104 }; 104 };
105 105
106 namespace { 106 namespace {
107 107
108 TEST_F(Canvas2DLayerBridgeTest, testFullLifecycleSingleThreaded) 108 TEST_F(Canvas2DLayerBridgeTest, testFullLifecycleSingleThreaded)
109 { 109 {
110 fullLifecycleTest(); 110 fullLifecycleTest();
111 } 111 }
112 112
113 } // namespace 113 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698