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

Side by Side Diff: Source/web/tests/Canvas2DLayerBridgeTest.cpp

Issue 104023007: Refactoring ImageBuffer to decouple it from Canvas2DLayerBridge (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase mayhem 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
« no previous file with comments | « Source/web/WebMediaPlayerClientImpl.cpp ('k') | Source/web/tests/Canvas2DLayerManagerTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 namespace { 47 namespace {
48 48
49 class MockCanvasContext : public MockWebGraphicsContext3D { 49 class MockCanvasContext : public MockWebGraphicsContext3D {
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 Canvas2DLayerBridgePtr {
57 public: 57 public:
58 static PassRefPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D> context, PassRefPtr<SkDeferredCanvas> canvas, OpacityMode opacityMode) 58 Canvas2DLayerBridgePtr(PassRefPtr<Canvas2DLayerBridge> layerBridge)
59 : m_layerBridge(layerBridge) { }
60
61 ~Canvas2DLayerBridgePtr()
59 { 62 {
60 return adoptRef(static_cast<Canvas2DLayerBridge*>(new FakeCanvas2DLayerB ridge(context, canvas, opacityMode))); 63 m_layerBridge->beginDestruction();
61 } 64 }
62 protected: 65
63 FakeCanvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, PassRefPtr<Sk DeferredCanvas> canvas, OpacityMode opacityMode) : 66 Canvas2DLayerBridge* operator->() { return m_layerBridge.get(); }
64 Canvas2DLayerBridge(context, canvas, 0, opacityMode) 67 Canvas2DLayerBridge* get() { return m_layerBridge.get(); }
65 { } 68
69 private:
70 RefPtr<Canvas2DLayerBridge> m_layerBridge;
66 }; 71 };
67 72
68 } // namespace 73 } // namespace
69 74
70 class Canvas2DLayerBridgeTest : public Test { 75 class Canvas2DLayerBridgeTest : public Test {
71 protected: 76 protected:
72 void fullLifecycleTest() 77 void fullLifecycleTest()
73 { 78 {
74 RefPtr<GraphicsContext3D> mainContext = GraphicsContext3D::createGraphic sContextFromWebContext(adoptPtr(new MockCanvasContext)); 79 RefPtr<GraphicsContext3D> mainContext = GraphicsContext3D::createGraphic sContextFromWebContext(adoptPtr(new MockCanvasContext));
75 80
76 MockCanvasContext& mainMock = *static_cast<MockCanvasContext*>(mainConte xt->webContext()); 81 MockCanvasContext& mainMock = *static_cast<MockCanvasContext*>(mainConte xt->webContext());
77 82
78 RefPtr<SkDeferredCanvas> canvas = adoptRef(SkDeferredCanvas::Create(SkSu rface::NewRasterPMColor(300, 150))); 83 OwnPtr<SkDeferredCanvas> canvas = adoptPtr(SkDeferredCanvas::Create(SkSu rface::NewRasterPMColor(300, 150)));
79 84
80 ::testing::Mock::VerifyAndClearExpectations(&mainMock); 85 ::testing::Mock::VerifyAndClearExpectations(&mainMock);
81 86
82 Canvas2DLayerBridgePtr bridge = FakeCanvas2DLayerBridge::create(mainCont ext.release(), canvas.release(), Canvas2DLayerBridge::NonOpaque); 87 {
88 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(mainC ontext.release(), canvas.release(), 0, NonOpaque)));
83 89
84 ::testing::Mock::VerifyAndClearExpectations(&mainMock); 90 ::testing::Mock::VerifyAndClearExpectations(&mainMock);
85 91
86 EXPECT_CALL(mainMock, flush()); 92 EXPECT_CALL(mainMock, flush());
87 unsigned textureId = bridge->backBufferTexture(); 93 unsigned textureId = bridge->getBackingTexture();
88 EXPECT_EQ(textureId, 0u); 94 EXPECT_EQ(textureId, 0u);
89 95
90 ::testing::Mock::VerifyAndClearExpectations(&mainMock); 96 ::testing::Mock::VerifyAndClearExpectations(&mainMock);
91 97 } // bridge goes out of scope here
92 bridge.clear();
93 98
94 ::testing::Mock::VerifyAndClearExpectations(&mainMock); 99 ::testing::Mock::VerifyAndClearExpectations(&mainMock);
95 } 100 }
96 }; 101 };
97 102
98 namespace { 103 namespace {
99 104
100 TEST_F(Canvas2DLayerBridgeTest, testFullLifecycleSingleThreaded) 105 TEST_F(Canvas2DLayerBridgeTest, testFullLifecycleSingleThreaded)
101 { 106 {
102 fullLifecycleTest(); 107 fullLifecycleTest();
103 } 108 }
104 109
105 } // namespace 110 } // namespace
OLDNEW
« no previous file with comments | « Source/web/WebMediaPlayerClientImpl.cpp ('k') | Source/web/tests/Canvas2DLayerManagerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698