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

Side by Side Diff: cc/CCLayerTreeHostImplTest.cpp

Issue 10907075: Roll cc snapshot up to 127605 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months 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 | « cc/CCLayerTreeHostImpl.cpp ('k') | cc/CCLayerTreeHostTest.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 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "CCLayerTreeHostImpl.h" 7 #include "CCLayerTreeHostImpl.h"
8 8
9 #include "CCAnimationTestCommon.h" 9 #include "CCAnimationTestCommon.h"
10 #include "CCGeometryTestUtils.h" 10 #include "CCGeometryTestUtils.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 using ::testing::Return; 43 using ::testing::Return;
44 using ::testing::AnyNumber; 44 using ::testing::AnyNumber;
45 using ::testing::AtLeast; 45 using ::testing::AtLeast;
46 using ::testing::_; 46 using ::testing::_;
47 47
48 namespace { 48 namespace {
49 49
50 class CCLayerTreeHostImplTest : public testing::Test, public CCLayerTreeHostImpl Client { 50 class CCLayerTreeHostImplTest : public testing::Test, public CCLayerTreeHostImpl Client {
51 public: 51 public:
52 CCLayerTreeHostImplTest() 52 CCLayerTreeHostImplTest()
53 : m_didRequestCommit(false) 53 : m_onCanDrawStateChangedCalled(false)
54 , m_didRequestCommit(false)
54 , m_didRequestRedraw(false) 55 , m_didRequestRedraw(false)
55 { 56 {
56 CCLayerTreeSettings settings; 57 CCLayerTreeSettings settings;
57 settings.minimumOcclusionTrackingSize = IntSize(); 58 settings.minimumOcclusionTrackingSize = IntSize();
58 59
59 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); 60 m_hostImpl = CCLayerTreeHostImpl::create(settings, this);
60 m_hostImpl->initializeRenderer(createContext(), UnthrottledUploader); 61 m_hostImpl->initializeRenderer(createContext(), UnthrottledUploader);
61 m_hostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); 62 m_hostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10));
62 } 63 }
63 64
64 virtual void didLoseContextOnImplThread() OVERRIDE { } 65 virtual void didLoseContextOnImplThread() OVERRIDE { }
65 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } 66 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { }
66 virtual void onVSyncParametersChanged(double, double) OVERRIDE { } 67 virtual void onVSyncParametersChanged(double, double) OVERRIDE { }
68 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState ChangedCalled = true; }
67 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr ue; } 69 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr ue; }
68 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr ue; } 70 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr ue; }
69 virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimat ionEventsVector>, double wallClockTime) OVERRIDE { } 71 virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimat ionEventsVector>, double wallClockTime) OVERRIDE { }
70 72
71 PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, PassOw nPtr<CCGraphicsContext> graphicsContext, PassOwnPtr<CCLayerImpl> rootPtr) 73 PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, PassOw nPtr<CCGraphicsContext> graphicsContext, PassOwnPtr<CCLayerImpl> rootPtr)
72 { 74 {
73 CCSettings::setPartialSwapEnabled(partialSwap); 75 CCSettings::setPartialSwapEnabled(partialSwap);
74 76
75 CCLayerTreeSettings settings; 77 CCLayerTreeSettings settings;
76 settings.minimumOcclusionTrackingSize = IntSize(); 78 settings.minimumOcclusionTrackingSize = IntSize();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 protected: 160 protected:
159 PassOwnPtr<CCGraphicsContext> createContext() 161 PassOwnPtr<CCGraphicsContext> createContext()
160 { 162 {
161 return FakeWebCompositorOutputSurface::create(adoptPtr(new FakeWebGraphi csContext3D)); 163 return FakeWebCompositorOutputSurface::create(adoptPtr(new FakeWebGraphi csContext3D));
162 } 164 }
163 165
164 DebugScopedSetImplThread m_alwaysImplThread; 166 DebugScopedSetImplThread m_alwaysImplThread;
165 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; 167 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked;
166 168
167 OwnPtr<CCLayerTreeHostImpl> m_hostImpl; 169 OwnPtr<CCLayerTreeHostImpl> m_hostImpl;
170 bool m_onCanDrawStateChangedCalled;
168 bool m_didRequestCommit; 171 bool m_didRequestCommit;
169 bool m_didRequestRedraw; 172 bool m_didRequestRedraw;
170 CCScopedSettings m_scopedSettings; 173 CCScopedSettings m_scopedSettings;
171 }; 174 };
172 175
173 class FakeWebGraphicsContext3DMakeCurrentFails : public FakeWebGraphicsContext3D { 176 class FakeWebGraphicsContext3DMakeCurrentFails : public FakeWebGraphicsContext3D {
174 public: 177 public:
175 virtual bool makeContextCurrent() { return false; } 178 virtual bool makeContextCurrent() { return false; }
176 }; 179 };
177 180
181 TEST_F(CCLayerTreeHostImplTest, notifyIfCanDrawChanged)
182 {
183 // Note: It is not possible to disable the renderer once it has been set,
184 // so we do not need to test that disabling the renderer notifies us
185 // that canDraw changed.
186 EXPECT_FALSE(m_hostImpl->canDraw());
187 m_onCanDrawStateChangedCalled = false;
188
189 setupScrollAndContentsLayers(IntSize(100, 100));
190 EXPECT_TRUE(m_hostImpl->canDraw());
191 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
192 m_onCanDrawStateChangedCalled = false;
193
194 // Toggle the root layer to make sure it toggles canDraw
195 m_hostImpl->setRootLayer(adoptPtr<CCLayerImpl>(0));
196 EXPECT_FALSE(m_hostImpl->canDraw());
197 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
198 m_onCanDrawStateChangedCalled = false;
199
200 setupScrollAndContentsLayers(IntSize(100, 100));
201 EXPECT_TRUE(m_hostImpl->canDraw());
202 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
203 m_onCanDrawStateChangedCalled = false;
204
205 // Toggle the device viewport size to make sure it toggles canDraw.
206 m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(0, 0));
207 EXPECT_FALSE(m_hostImpl->canDraw());
208 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
209 m_onCanDrawStateChangedCalled = false;
210
211 m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100));
212 EXPECT_TRUE(m_hostImpl->canDraw());
213 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
214 m_onCanDrawStateChangedCalled = false;
215
216 // Toggle contents textures purged to make sure it toggles canDraw
217 m_hostImpl->releaseContentsTextures();
218 EXPECT_FALSE(m_hostImpl->canDraw());
219 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
220 m_onCanDrawStateChangedCalled = false;
221
222 m_hostImpl->resetContentsTexturesPurged();
223 EXPECT_TRUE(m_hostImpl->canDraw());
224 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
225 m_onCanDrawStateChangedCalled = false;
226 }
227
178 TEST_F(CCLayerTreeHostImplTest, scrollDeltaNoLayers) 228 TEST_F(CCLayerTreeHostImplTest, scrollDeltaNoLayers)
179 { 229 {
180 ASSERT_FALSE(m_hostImpl->rootLayer()); 230 ASSERT_FALSE(m_hostImpl->rootLayer());
181 231
182 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); 232 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
183 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); 233 ASSERT_EQ(scrollInfo->scrolls.size(), 0u);
184 } 234 }
185 235
186 TEST_F(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges) 236 TEST_F(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges)
187 { 237 {
(...skipping 3939 matching lines...) Expand 10 before | Expand all | Expand 10 after
4127 while (removeRenderPassesCases[testCaseIndex].name) { 4177 while (removeRenderPassesCases[testCaseIndex].name) {
4128 RenderPassRemovalTestData testData; 4178 RenderPassRemovalTestData testData;
4129 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS cript, testData, renderer.get()); 4179 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS cript, testData, renderer.get());
4130 CCLayerTreeHostImpl::removeRenderPasses(CCLayerTreeHostImpl::CullRenderP assesWithCachedTextures(*renderer), testData); 4180 CCLayerTreeHostImpl::removeRenderPasses(CCLayerTreeHostImpl::CullRenderP assesWithCachedTextures(*renderer), testData);
4131 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a); 4181 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a);
4132 testCaseIndex++; 4182 testCaseIndex++;
4133 } 4183 }
4134 } 4184 }
4135 4185
4136 } // namespace 4186 } // namespace
OLDNEW
« no previous file with comments | « cc/CCLayerTreeHostImpl.cpp ('k') | cc/CCLayerTreeHostTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698