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

Side by Side Diff: cc/CCLayerTreeHostTest.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/CCLayerTreeHostImplTest.cpp ('k') | cc/CCScheduler.h » ('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 "CCLayerTreeHost.h" 7 #include "CCLayerTreeHost.h"
8 8
9 #include "CCGeometryTestUtils.h" 9 #include "CCGeometryTestUtils.h"
10 #include "CCGraphicsContext.h" 10 #include "CCGraphicsContext.h"
11 #include "CCLayerTreeHostImpl.h" 11 #include "CCLayerTreeHostImpl.h"
12 #include "CCOcclusionTrackerTestCommon.h" 12 #include "CCOcclusionTrackerTestCommon.h"
13 #include "CCSettings.h" 13 #include "CCSettings.h"
14 #include "CCSingleThreadProxy.h" 14 #include "CCSingleThreadProxy.h"
15 #include "CCTextureUpdateQueue.h" 15 #include "CCTextureUpdateQueue.h"
16 #include "CCThreadedTest.h" 16 #include "CCThreadedTest.h"
17 #include "CCTimingFunction.h" 17 #include "CCTimingFunction.h"
18 #include "ContentLayerChromium.h" 18 #include "ContentLayerChromium.h"
19 #include "ContentLayerChromiumClient.h" 19 #include "ContentLayerChromiumClient.h"
20 #include "Extensions3DChromium.h" 20 #include "Extensions3DChromium.h"
21 #include "FakeWebCompositorOutputSurface.h" 21 #include "FakeWebCompositorOutputSurface.h"
22 #include <gmock/gmock.h> 22 #include <gmock/gmock.h>
23 #include <public/Platform.h> 23 #include <public/Platform.h>
24 #include <public/WebLayerScrollClient.h>
25 #include <public/WebSize.h>
24 #include <wtf/MainThread.h> 26 #include <wtf/MainThread.h>
25 #include <wtf/OwnArrayPtr.h> 27 #include <wtf/OwnArrayPtr.h>
26 28
27 using namespace WebCore; 29 using namespace WebCore;
28 using namespace WebKit; 30 using namespace WebKit;
29 using namespace WebKitTests; 31 using namespace WebKitTests;
30 32
31 namespace { 33 namespace {
32 34
33 class CCLayerTreeHostTest : public CCThreadedTest { }; 35 class CCLayerTreeHostTest : public CCThreadedTest { };
(...skipping 2151 matching lines...) Expand 10 before | Expand all | Expand 10 after
2185 } 2187 }
2186 2188
2187 virtual void afterTest() OVERRIDE { } 2189 virtual void afterTest() OVERRIDE { }
2188 2190
2189 private: 2191 private:
2190 bool m_addedAnimation; 2192 bool m_addedAnimation;
2191 }; 2193 };
2192 2194
2193 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLayerAddedWithAnimation) 2195 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLayerAddedWithAnimation)
2194 2196
2195 class CCLayerTreeHostTestScrollChildLayer : public CCLayerTreeHostTest, public L ayerChromiumScrollDelegate { 2197 class CCLayerTreeHostTestScrollChildLayer : public CCLayerTreeHostTest, public W ebLayerScrollClient {
2196 public: 2198 public:
2197 CCLayerTreeHostTestScrollChildLayer() 2199 CCLayerTreeHostTestScrollChildLayer()
2198 : m_scrollAmount(2, 1) 2200 : m_scrollAmount(2, 1)
2199 { 2201 {
2200 } 2202 }
2201 2203
2202 virtual void beginTest() OVERRIDE 2204 virtual void beginTest() OVERRIDE
2203 { 2205 {
2204 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); 2206 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10));
2205 m_layerTreeHost->rootLayer()->setBounds(IntSize(10, 10)); 2207 m_layerTreeHost->rootLayer()->setBounds(IntSize(10, 10));
2206 2208
2207 m_rootScrollLayer = ContentLayerChromium::create(&m_mockDelegate); 2209 m_rootScrollLayer = ContentLayerChromium::create(&m_mockDelegate);
2208 m_rootScrollLayer->setBounds(IntSize(10, 10)); 2210 m_rootScrollLayer->setBounds(IntSize(10, 10));
2209 2211
2210 m_rootScrollLayer->setPosition(FloatPoint(0, 0)); 2212 m_rootScrollLayer->setPosition(FloatPoint(0, 0));
2211 m_rootScrollLayer->setAnchorPoint(FloatPoint(0, 0)); 2213 m_rootScrollLayer->setAnchorPoint(FloatPoint(0, 0));
2212 2214
2213 m_rootScrollLayer->setIsDrawable(true); 2215 m_rootScrollLayer->setIsDrawable(true);
2214 m_rootScrollLayer->setScrollable(true); 2216 m_rootScrollLayer->setScrollable(true);
2215 m_rootScrollLayer->setMaxScrollPosition(IntSize(100, 100)); 2217 m_rootScrollLayer->setMaxScrollPosition(IntSize(100, 100));
2216 m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer); 2218 m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer);
2217 m_childLayer = ContentLayerChromium::create(&m_mockDelegate); 2219 m_childLayer = ContentLayerChromium::create(&m_mockDelegate);
2218 m_childLayer->setLayerScrollDelegate(this); 2220 m_childLayer->setLayerScrollClient(this);
2219 m_childLayer->setBounds(IntSize(50, 50)); 2221 m_childLayer->setBounds(IntSize(50, 50));
2220 m_childLayer->setIsDrawable(true); 2222 m_childLayer->setIsDrawable(true);
2221 m_childLayer->setScrollable(true); 2223 m_childLayer->setScrollable(true);
2222 m_childLayer->setMaxScrollPosition(IntSize(100, 100)); 2224 m_childLayer->setMaxScrollPosition(IntSize(100, 100));
2223 2225
2224 m_childLayer->setPosition(FloatPoint(0, 0)); 2226 m_childLayer->setPosition(FloatPoint(0, 0));
2225 m_childLayer->setAnchorPoint(FloatPoint(0, 0)); 2227 m_childLayer->setAnchorPoint(FloatPoint(0, 0));
2226 2228
2227 m_rootScrollLayer->addChild(m_childLayer); 2229 m_rootScrollLayer->addChild(m_childLayer);
2228 postSetNeedsCommitToMainThread(); 2230 postSetNeedsCommitToMainThread();
2229 } 2231 }
2230 2232
2231 virtual void didScroll(const IntSize& scrollDelta) OVERRIDE 2233 virtual void didScroll() OVERRIDE
2232 { 2234 {
2233 m_reportedScrollAmount = scrollDelta; 2235 m_finalScrollPosition = m_childLayer->scrollPosition();
2234 } 2236 }
2235 2237
2236 virtual void applyScrollAndScale(const IntSize& scrollDelta, float) OVERRIDE 2238 virtual void applyScrollAndScale(const IntSize& scrollDelta, float) OVERRIDE
2237 { 2239 {
2238 IntPoint position = m_rootScrollLayer->scrollPosition(); 2240 IntPoint position = m_rootScrollLayer->scrollPosition();
2239 m_rootScrollLayer->setScrollPosition(position + scrollDelta); 2241 m_rootScrollLayer->setScrollPosition(position + scrollDelta);
2240 } 2242 }
2241 2243
2242 virtual void beginCommitOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 2244 virtual void beginCommitOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE
2243 { 2245 {
2244 EXPECT_EQ(m_rootScrollLayer->scrollPosition(), IntPoint()); 2246 EXPECT_EQ(m_rootScrollLayer->scrollPosition(), IntPoint());
2245 if (!m_layerTreeHost->commitNumber()) 2247 if (!m_layerTreeHost->commitNumber())
2246 EXPECT_EQ(m_childLayer->scrollPosition(), IntPoint()); 2248 EXPECT_EQ(m_childLayer->scrollPosition(), IntPoint());
2247 else 2249 else
2248 EXPECT_EQ(m_childLayer->scrollPosition(), IntPoint() + m_scrollAmoun t); 2250 EXPECT_EQ(m_childLayer->scrollPosition(), IntPoint() + m_scrollAmoun t);
2249 } 2251 }
2250 2252
2251 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 2253 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE
2252 { 2254 {
2253 if (impl->sourceAnimationFrameNumber() == 1) { 2255 if (impl->sourceAnimationFrameNumber() == 1) {
2254 EXPECT_EQ(impl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Wh eel), CCInputHandlerClient::ScrollStarted); 2256 EXPECT_EQ(impl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Wh eel), CCInputHandlerClient::ScrollStarted);
2255 impl->scrollBy(IntPoint(), m_scrollAmount); 2257 impl->scrollBy(IntPoint(), m_scrollAmount);
2256 impl->scrollEnd(); 2258 impl->scrollEnd();
2257 } else if (impl->sourceAnimationFrameNumber() == 2) 2259 } else if (impl->sourceAnimationFrameNumber() == 2)
2258 endTest(); 2260 endTest();
2259 } 2261 }
2260 2262
2261 virtual void afterTest() OVERRIDE 2263 virtual void afterTest() OVERRIDE
2262 { 2264 {
2263 EXPECT_EQ(m_scrollAmount, m_reportedScrollAmount); 2265 EXPECT_EQ(IntPoint(m_scrollAmount), m_finalScrollPosition);
2264 } 2266 }
2265 2267
2266 private: 2268 private:
2267 const IntSize m_scrollAmount; 2269 const IntSize m_scrollAmount;
2268 IntSize m_reportedScrollAmount; 2270 IntPoint m_finalScrollPosition;
2269 MockContentLayerChromiumClient m_mockDelegate; 2271 MockContentLayerChromiumClient m_mockDelegate;
2270 RefPtr<LayerChromium> m_childLayer; 2272 RefPtr<LayerChromium> m_childLayer;
2271 RefPtr<LayerChromium> m_rootScrollLayer; 2273 RefPtr<LayerChromium> m_rootScrollLayer;
2272 }; 2274 };
2273 2275
2274 TEST_F(CCLayerTreeHostTestScrollChildLayer, runMultiThread) 2276 TEST_F(CCLayerTreeHostTestScrollChildLayer, runMultiThread)
2275 { 2277 {
2276 runTest(true); 2278 runTest(true);
2277 } 2279 }
2278 2280
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
2806 int m_numChildren; 2808 int m_numChildren;
2807 Vector<RefPtr<ContentLayerChromiumWithUpdateTracking> > m_children; 2809 Vector<RefPtr<ContentLayerChromiumWithUpdateTracking> > m_children;
2808 }; 2810 };
2809 2811
2810 TEST_F(CCLayerTreeHostTestLostContextWhileUpdatingResources, runMultiThread) 2812 TEST_F(CCLayerTreeHostTestLostContextWhileUpdatingResources, runMultiThread)
2811 { 2813 {
2812 runTest(true); 2814 runTest(true);
2813 } 2815 }
2814 2816
2815 } // namespace 2817 } // namespace
OLDNEW
« no previous file with comments | « cc/CCLayerTreeHostImplTest.cpp ('k') | cc/CCScheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698