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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 180 |
181 DebugScopedSetImplThread m_alwaysImplThread; | 181 DebugScopedSetImplThread m_alwaysImplThread; |
182 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; | 182 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; |
183 | 183 |
184 OwnPtr<CCLayerTreeHostImpl> m_hostImpl; | 184 OwnPtr<CCLayerTreeHostImpl> m_hostImpl; |
185 bool m_didRequestCommit; | 185 bool m_didRequestCommit; |
186 bool m_didRequestRedraw; | 186 bool m_didRequestRedraw; |
187 CCScopedSettings m_scopedSettings; | 187 CCScopedSettings m_scopedSettings; |
188 }; | 188 }; |
189 | 189 |
190 class FakeWebGraphicsContext3DMakeCurrentFails : public FakeWebGraphicsContext3D
{ | |
191 public: | |
192 virtual bool makeContextCurrent() { return false; } | |
193 }; | |
194 | |
195 TEST_F(CCLayerTreeHostImplTest, scrollDeltaNoLayers) | 190 TEST_F(CCLayerTreeHostImplTest, scrollDeltaNoLayers) |
196 { | 191 { |
197 ASSERT_FALSE(m_hostImpl->rootLayer()); | 192 ASSERT_FALSE(m_hostImpl->rootLayer()); |
198 | 193 |
199 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); | 194 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); |
200 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 195 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
201 } | 196 } |
202 | 197 |
203 TEST_F(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges) | 198 TEST_F(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges) |
204 { | 199 { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 EXPECT_TRUE(m_didRequestRedraw); | 266 EXPECT_TRUE(m_didRequestRedraw); |
272 EXPECT_TRUE(m_didRequestCommit); | 267 EXPECT_TRUE(m_didRequestCommit); |
273 } | 268 } |
274 | 269 |
275 TEST_F(CCLayerTreeHostImplTest, scrollWithoutRootLayer) | 270 TEST_F(CCLayerTreeHostImplTest, scrollWithoutRootLayer) |
276 { | 271 { |
277 // We should not crash when trying to scroll an empty layer tree. | 272 // We should not crash when trying to scroll an empty layer tree. |
278 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollIgnored); | 273 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollIgnored); |
279 } | 274 } |
280 | 275 |
281 TEST_F(CCLayerTreeHostImplTest, scrollWithoutRenderer) | |
282 { | |
283 CCLayerTreeSettings settings; | |
284 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); | |
285 | |
286 // Initialization will fail here. | |
287 m_hostImpl->initializeLayerRenderer(FakeWebCompositorOutputSurface::create(a
doptPtr(new FakeWebGraphicsContext3DMakeCurrentFails)), UnthrottledUploader); | |
288 m_hostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | |
289 | |
290 setupScrollAndContentsLayers(IntSize(100, 100)); | |
291 | |
292 // We should not crash when trying to scroll after the renderer initializati
on fails. | |
293 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollIgnored); | |
294 } | |
295 | |
296 TEST_F(CCLayerTreeHostImplTest, replaceTreeWhileScrolling) | 276 TEST_F(CCLayerTreeHostImplTest, replaceTreeWhileScrolling) |
297 { | 277 { |
298 const int scrollLayerId = 1; | 278 const int scrollLayerId = 1; |
299 | 279 |
300 setupScrollAndContentsLayers(IntSize(100, 100)); | 280 setupScrollAndContentsLayers(IntSize(100, 100)); |
301 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); | 281 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); |
302 initializeLayerRendererAndDrawFrame(); | 282 initializeLayerRendererAndDrawFrame(); |
303 | 283 |
304 // We should not crash if the tree is replaced while we are scrolling. | 284 // We should not crash if the tree is replaced while we are scrolling. |
305 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); | 285 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); |
(...skipping 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2124 EXPECT_FALSE(layer1->didLoseContextCalled()); | 2104 EXPECT_FALSE(layer1->didLoseContextCalled()); |
2125 EXPECT_FALSE(layer2->didLoseContextCalled()); | 2105 EXPECT_FALSE(layer2->didLoseContextCalled()); |
2126 | 2106 |
2127 m_hostImpl->initializeLayerRenderer(createContext(), UnthrottledUploader); | 2107 m_hostImpl->initializeLayerRenderer(createContext(), UnthrottledUploader); |
2128 | 2108 |
2129 EXPECT_TRUE(root->didLoseContextCalled()); | 2109 EXPECT_TRUE(root->didLoseContextCalled()); |
2130 EXPECT_TRUE(layer1->didLoseContextCalled()); | 2110 EXPECT_TRUE(layer1->didLoseContextCalled()); |
2131 EXPECT_TRUE(layer2->didLoseContextCalled()); | 2111 EXPECT_TRUE(layer2->didLoseContextCalled()); |
2132 } | 2112 } |
2133 | 2113 |
| 2114 class FakeWebGraphicsContext3DMakeCurrentFails : public FakeWebGraphicsContext3D
{ |
| 2115 public: |
| 2116 virtual bool makeContextCurrent() { return false; } |
| 2117 }; |
| 2118 |
2134 TEST_F(CCLayerTreeHostImplTest, finishAllRenderingAfterContextLost) | 2119 TEST_F(CCLayerTreeHostImplTest, finishAllRenderingAfterContextLost) |
2135 { | 2120 { |
2136 CCLayerTreeSettings settings; | |
2137 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); | |
2138 | |
2139 // The context initialization will fail, but we should still be able to call
finishAllRendering() without any ill effects. | 2121 // The context initialization will fail, but we should still be able to call
finishAllRendering() without any ill effects. |
2140 m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new
FakeWebGraphicsContext3DMakeCurrentFails)), UnthrottledUploader); | 2122 m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new
FakeWebGraphicsContext3DMakeCurrentFails)), UnthrottledUploader); |
2141 m_hostImpl->finishAllRendering(); | 2123 m_hostImpl->finishAllRendering(); |
2142 } | 2124 } |
2143 | 2125 |
2144 // Fake WebGraphicsContext3D that will cause a failure if trying to use a | 2126 // Fake WebGraphicsContext3D that will cause a failure if trying to use a |
2145 // resource that wasn't created by it (resources created by | 2127 // resource that wasn't created by it (resources created by |
2146 // FakeWebGraphicsContext3D have an id of 1). | 2128 // FakeWebGraphicsContext3D have an id of 1). |
2147 class StrictWebGraphicsContext3D : public FakeWebGraphicsContext3D { | 2129 class StrictWebGraphicsContext3D : public FakeWebGraphicsContext3D { |
2148 public: | 2130 public: |
(...skipping 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4003 while (removeRenderPassesCases[testCaseIndex].name) { | 3985 while (removeRenderPassesCases[testCaseIndex].name) { |
4004 RenderPassRemovalTestData testData; | 3986 RenderPassRemovalTestData testData; |
4005 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS
cript, testData, renderer.get()); | 3987 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS
cript, testData, renderer.get()); |
4006 CCLayerTreeHostImpl::removeRenderPasses(CCLayerTreeHostImpl::CullRenderP
assesWithCachedTextures(*renderer), testData); | 3988 CCLayerTreeHostImpl::removeRenderPasses(CCLayerTreeHostImpl::CullRenderP
assesWithCachedTextures(*renderer), testData); |
4007 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); | 3989 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); |
4008 testCaseIndex++; | 3990 testCaseIndex++; |
4009 } | 3991 } |
4010 } | 3992 } |
4011 | 3993 |
4012 } // namespace | 3994 } // namespace |
OLD | NEW |