OLD | NEW |
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 m_layerBridge->beginDestruction(); | 63 m_layerBridge->beginDestruction(); |
64 } | 64 } |
65 | 65 |
66 Canvas2DLayerBridge* operator->() { return m_layerBridge.get(); } | 66 Canvas2DLayerBridge* operator->() { return m_layerBridge.get(); } |
67 Canvas2DLayerBridge* get() { return m_layerBridge.get(); } | 67 Canvas2DLayerBridge* get() { return m_layerBridge.get(); } |
68 | 68 |
69 private: | 69 private: |
70 RefPtr<Canvas2DLayerBridge> m_layerBridge; | 70 RefPtr<Canvas2DLayerBridge> m_layerBridge; |
71 }; | 71 }; |
72 | 72 |
| 73 class FakeCanvas2DLayerBridgeClient : public Canvas2DLayerBridgeClient { |
| 74 public: |
| 75 virtual ~FakeCanvas2DLayerBridgeClient() { } |
| 76 virtual bool hidden() const OVERRIDE { return false; } |
| 77 }; |
| 78 |
73 } // namespace | 79 } // namespace |
74 | 80 |
75 class Canvas2DLayerBridgeTest : public Test { | 81 class Canvas2DLayerBridgeTest : public Test { |
76 protected: | 82 protected: |
77 void fullLifecycleTest() | 83 void fullLifecycleTest() |
78 { | 84 { |
79 RefPtr<GraphicsContext3D> mainContext = GraphicsContext3D::createGraphic
sContextFromWebContext(adoptPtr(new MockCanvasContext)); | 85 RefPtr<GraphicsContext3D> mainContext = GraphicsContext3D::createGraphic
sContextFromWebContext(adoptPtr(new MockCanvasContext)); |
80 | 86 |
81 MockCanvasContext& mainMock = *static_cast<MockCanvasContext*>(mainConte
xt->webContext()); | 87 MockCanvasContext& mainMock = *static_cast<MockCanvasContext*>(mainConte
xt->webContext()); |
82 | 88 |
83 OwnPtr<SkDeferredCanvas> canvas = adoptPtr(SkDeferredCanvas::Create(SkSu
rface::NewRasterPMColor(300, 150))); | 89 OwnPtr<SkDeferredCanvas> canvas = adoptPtr(SkDeferredCanvas::Create(SkSu
rface::NewRasterPMColor(300, 150))); |
84 | 90 |
85 ::testing::Mock::VerifyAndClearExpectations(&mainMock); | 91 ::testing::Mock::VerifyAndClearExpectations(&mainMock); |
86 | 92 |
87 { | 93 { |
88 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(mainC
ontext.release(), canvas.release(), 0, NonOpaque))); | 94 FakeCanvas2DLayerBridgeClient client; |
| 95 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(&clie
nt, mainContext.release(), canvas.release(), 0, NonOpaque))); |
89 | 96 |
90 ::testing::Mock::VerifyAndClearExpectations(&mainMock); | 97 ::testing::Mock::VerifyAndClearExpectations(&mainMock); |
91 | 98 |
92 EXPECT_CALL(mainMock, flush()); | 99 EXPECT_CALL(mainMock, flush()); |
93 unsigned textureId = bridge->getBackingTexture(); | 100 unsigned textureId = bridge->getBackingTexture(); |
94 EXPECT_EQ(textureId, 0u); | 101 EXPECT_EQ(textureId, 0u); |
95 | 102 |
96 ::testing::Mock::VerifyAndClearExpectations(&mainMock); | 103 ::testing::Mock::VerifyAndClearExpectations(&mainMock); |
97 } // bridge goes out of scope here | 104 } // bridge goes out of scope here |
98 | 105 |
99 ::testing::Mock::VerifyAndClearExpectations(&mainMock); | 106 ::testing::Mock::VerifyAndClearExpectations(&mainMock); |
100 } | 107 } |
101 }; | 108 }; |
102 | 109 |
103 namespace { | 110 namespace { |
104 | 111 |
105 TEST_F(Canvas2DLayerBridgeTest, testFullLifecycleSingleThreaded) | 112 TEST_F(Canvas2DLayerBridgeTest, testFullLifecycleSingleThreaded) |
106 { | 113 { |
107 fullLifecycleTest(); | 114 fullLifecycleTest(); |
108 } | 115 } |
109 | 116 |
110 } // namespace | 117 } // namespace |
OLD | NEW |