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

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

Issue 104023007: Refactoring ImageBuffer to decouple it from Canvas2DLayerBridge (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: build fixes for win+mac Created 7 years 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 class MockCanvasContext : public FakeWebGraphicsContext3D { 49 class MockCanvasContext : public FakeWebGraphicsContext3D {
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 55
56 class FakeCanvas2DLayerBridge : public Canvas2DLayerBridge { 56 class FakeCanvas2DLayerBridge : public Canvas2DLayerBridge {
57 public: 57 public:
58 static PassRefPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D> context, PassRefPtr<SkDeferredCanvas> canvas, OpacityMode opacityMode) 58 static PassRefPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D> context, PassOwnPtr<SkDeferredCanvas> canvas, OpacityMode opacityMode)
59 { 59 {
60 return adoptRef(static_cast<Canvas2DLayerBridge*>(new FakeCanvas2DLayerB ridge(context, canvas, opacityMode))); 60 return adoptRef(static_cast<Canvas2DLayerBridge*>(new FakeCanvas2DLayerB ridge(context, canvas, opacityMode)));
61 } 61 }
62 protected: 62 protected:
63 FakeCanvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, PassRefPtr<Sk DeferredCanvas> canvas, OpacityMode opacityMode) : 63 FakeCanvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, PassOwnPtr<Sk DeferredCanvas> canvas, OpacityMode opacityMode) :
64 Canvas2DLayerBridge(context, canvas, 0, opacityMode) 64 Canvas2DLayerBridge(context, canvas, 0, opacityMode)
65 { } 65 { }
66 }; 66 };
67 67
68 } // namespace 68 } // namespace
69 69
70 class Canvas2DLayerBridgeTest : public Test { 70 class Canvas2DLayerBridgeTest : public Test {
71 protected: 71 protected:
72 void fullLifecycleTest() 72 void fullLifecycleTest()
73 { 73 {
74 RefPtr<GraphicsContext3D> mainContext = GraphicsContext3D::createGraphic sContextFromWebContext(adoptPtr(new MockCanvasContext)); 74 RefPtr<GraphicsContext3D> mainContext = GraphicsContext3D::createGraphic sContextFromWebContext(adoptPtr(new MockCanvasContext));
75 75
76 MockCanvasContext& mainMock = *static_cast<MockCanvasContext*>(mainConte xt->webContext()); 76 MockCanvasContext& mainMock = *static_cast<MockCanvasContext*>(mainConte xt->webContext());
77 77
78 RefPtr<SkDeferredCanvas> canvas = adoptRef(SkDeferredCanvas::Create(SkSu rface::NewRasterPMColor(300, 150))); 78 OwnPtr<SkDeferredCanvas> canvas = adoptPtr(SkDeferredCanvas::Create(SkSu rface::NewRasterPMColor(300, 150)));
79 79
80 ::testing::Mock::VerifyAndClearExpectations(&mainMock); 80 ::testing::Mock::VerifyAndClearExpectations(&mainMock);
81 81
82 Canvas2DLayerBridgePtr bridge = FakeCanvas2DLayerBridge::create(mainCont ext.release(), canvas.release(), Canvas2DLayerBridge::NonOpaque); 82 RefPtr<Canvas2DLayerBridge> bridge = FakeCanvas2DLayerBridge::create(mai nContext.release(), canvas.release(), NonOpaque);
83 83
84 ::testing::Mock::VerifyAndClearExpectations(&mainMock); 84 ::testing::Mock::VerifyAndClearExpectations(&mainMock);
85 85
86 EXPECT_CALL(mainMock, flush()); 86 EXPECT_CALL(mainMock, flush());
87 unsigned textureId = bridge->backBufferTexture(); 87 unsigned textureId = bridge->getBackingTexture();
88 EXPECT_EQ(textureId, 0u); 88 EXPECT_EQ(textureId, 0u);
89 89
90 ::testing::Mock::VerifyAndClearExpectations(&mainMock); 90 ::testing::Mock::VerifyAndClearExpectations(&mainMock);
91 91
92 bridge->destroy();
92 bridge.clear(); 93 bridge.clear();
93 94
94 ::testing::Mock::VerifyAndClearExpectations(&mainMock); 95 ::testing::Mock::VerifyAndClearExpectations(&mainMock);
95 } 96 }
96 }; 97 };
97 98
98 namespace { 99 namespace {
99 100
100 TEST_F(Canvas2DLayerBridgeTest, testFullLifecycleSingleThreaded) 101 TEST_F(Canvas2DLayerBridgeTest, testFullLifecycleSingleThreaded)
101 { 102 {
102 fullLifecycleTest(); 103 fullLifecycleTest();
103 } 104 }
104 105
105 } // namespace 106 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698