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