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

Side by Side Diff: cc/layer_tree_host_unittest.cc

Issue 11550035: Implement pinch-zoom scaling for main-frame scrollbars and pinch-zoom overlay scrollbars. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporate device scale factor, default to 0 totalSize when no root scroll layer. Created 7 years, 9 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
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 "cc/layer_tree_host.h" 5 #include "cc/layer_tree_host.h"
6 6
7 #include "base/synchronization/lock.h" 7 #include "base/synchronization/lock.h"
8 #include "cc/content_layer.h" 8 #include "cc/content_layer.h"
9 #include "cc/content_layer_client.h" 9 #include "cc/content_layer_client.h"
10 #include "cc/frame_rate_controller.h" 10 #include "cc/frame_rate_controller.h"
11 #include "cc/layer_impl.h" 11 #include "cc/layer_impl.h"
12 #include "cc/layer_tree_host_impl.h" 12 #include "cc/layer_tree_host_impl.h"
13 #include "cc/layer_tree_impl.h" 13 #include "cc/layer_tree_impl.h"
14 #include "cc/output_surface.h" 14 #include "cc/output_surface.h"
15 #include "cc/picture_layer.h" 15 #include "cc/picture_layer.h"
16 #include "cc/prioritized_resource.h" 16 #include "cc/prioritized_resource.h"
17 #include "cc/prioritized_resource_manager.h" 17 #include "cc/prioritized_resource_manager.h"
18 #include "cc/resource_update_queue.h" 18 #include "cc/resource_update_queue.h"
19 #include "cc/scrollbar_layer.h"
19 #include "cc/single_thread_proxy.h" 20 #include "cc/single_thread_proxy.h"
20 #include "cc/test/fake_content_layer.h" 21 #include "cc/test/fake_content_layer.h"
21 #include "cc/test/fake_content_layer_client.h" 22 #include "cc/test/fake_content_layer_client.h"
22 #include "cc/test/fake_layer_tree_host_client.h" 23 #include "cc/test/fake_layer_tree_host_client.h"
23 #include "cc/test/fake_output_surface.h" 24 #include "cc/test/fake_output_surface.h"
24 #include "cc/test/fake_proxy.h" 25 #include "cc/test/fake_proxy.h"
25 #include "cc/test/fake_scrollbar_layer.h" 26 #include "cc/test/fake_scrollbar_layer.h"
26 #include "cc/test/geometry_test_utils.h" 27 #include "cc/test/geometry_test_utils.h"
27 #include "cc/test/layer_tree_test_common.h" 28 #include "cc/test/layer_tree_test_common.h"
28 #include "cc/test/occlusion_tracker_test_common.h" 29 #include "cc/test/occlusion_tracker_test_common.h"
(...skipping 2158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2187 private: 2188 private:
2188 FakeContentLayerClient m_client; 2189 FakeContentLayerClient m_client;
2189 scoped_refptr<FakeContentLayer> m_rootLayer; 2190 scoped_refptr<FakeContentLayer> m_rootLayer;
2190 scoped_refptr<FakeContentLayer> m_childLayer1; 2191 scoped_refptr<FakeContentLayer> m_childLayer1;
2191 scoped_refptr<FakeContentLayer> m_childLayer2; 2192 scoped_refptr<FakeContentLayer> m_childLayer2;
2192 int m_numCommits; 2193 int m_numCommits;
2193 }; 2194 };
2194 2195
2195 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestShutdownWithOnlySomeResourcesEvi cted) 2196 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestShutdownWithOnlySomeResourcesEvi cted)
2196 2197
2198 class LayerTreeHostTestPinchZoomScrollbarCreation : public LayerTreeHostTest {
2199 public:
2200 LayerTreeHostTestPinchZoomScrollbarCreation()
2201 : m_rootLayer(ContentLayer::create(&m_client))
2202 {
2203 m_settings.usePinchZoomScrollbars = true;
enne (OOO) 2013/03/11 21:08:24 This is inconsistently formatted with the rest of
wjmaclean 2013/03/12 16:13:07 Done.
2204 }
2205
2206 virtual void beginTest() OVERRIDE
2207 {
2208 m_rootLayer->setIsDrawable(true);
2209 m_rootLayer->setBounds(gfx::Size(100, 100));
2210 m_layerTreeHost->setRootLayer(m_rootLayer);
2211 postSetNeedsCommitToMainThread();
2212 }
2213
2214 virtual void didCommit() OVERRIDE
2215 {
2216 // We always expect two pinch-zoom scrollbar layers.
2217 ASSERT_TRUE(2 == m_rootLayer->children().size());
2218
2219 // Pinch-zoom scrollbar layers always have invalid scrollLayerIds.
2220 ScrollbarLayer* layer1 = m_rootLayer->children()[0]->toScrollbarLayer();
2221 ASSERT_TRUE(layer1);
2222 EXPECT_EQ(Layer::s_invalidLayerId, layer1->scrollLayerId());
2223 EXPECT_EQ(0, layer1->opacity());
2224 EXPECT_TRUE(layer1->drawsContent());
2225
2226 ScrollbarLayer* layer2 = m_rootLayer->children()[1]->toScrollbarLayer();
2227 ASSERT_TRUE(layer2);
2228 EXPECT_EQ(Layer::s_invalidLayerId, layer2->scrollLayerId());
2229 EXPECT_EQ(0, layer2->opacity());
2230 EXPECT_TRUE(layer2->drawsContent());
2231
2232 endTest();
2233 }
2234
2235 virtual void afterTest() OVERRIDE
2236 {
2237 }
2238
2239 private:
2240 FakeContentLayerClient m_client;
2241 scoped_refptr<ContentLayer> m_rootLayer;
2242 };
2243
2244 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPinchZoomScrollbarCreation)
2245
2246 class LayerTreeHostTestPinchZoomScrollbarResize : public LayerTreeHostTest {
2247 public:
2248 LayerTreeHostTestPinchZoomScrollbarResize()
2249 : m_rootLayer(ContentLayer::create(&m_client))
2250 , m_numCommits(0)
2251 {
2252 m_settings.usePinchZoomScrollbars = true;
2253 }
2254
2255 virtual void beginTest() OVERRIDE
2256 {
2257 m_rootLayer->setIsDrawable(true);
2258 m_rootLayer->setBounds(gfx::Size(100, 100));
2259 m_layerTreeHost->setRootLayer(m_rootLayer);
2260 m_layerTreeHost->setViewportSize(gfx::Size(100, 100),
2261 gfx::Size(100, 100));
2262 postSetNeedsCommitToMainThread();
2263 }
2264
2265 virtual void didCommit() OVERRIDE
2266 {
2267 m_numCommits++;
2268
2269 ScrollbarLayer* layer1 = m_rootLayer->children()[0]->toScrollbarLayer();
2270 ASSERT_TRUE(layer1);
2271 ScrollbarLayer* layer2 = m_rootLayer->children()[1]->toScrollbarLayer();
2272 ASSERT_TRUE(layer2);
2273
2274 // Get scrollbar thickness from horizontal scrollbar's height.
2275 int thickness = layer1->bounds().height();
2276
2277 if (!layer1->orientation() == WebKit::WebScrollbar::Horizontal)
2278 std::swap(layer1, layer2);
2279
2280 gfx::Size viewportSize = m_layerTreeHost->layoutViewportSize();
2281 EXPECT_EQ(viewportSize.width() - thickness, layer1->bounds().width());
2282 EXPECT_EQ(viewportSize.height() - thickness, layer2->bounds().height());
2283
2284 switch (m_numCommits) {
2285 case 1:
2286 // Resizing the viewport should also resize the pinch-zoom scrollbars.
2287 m_layerTreeHost->setViewportSize(gfx::Size(120, 150),
2288 gfx::Size(120, 150));
2289 break;
2290 case 2:
2291 endTest();
2292 break;
2293 default:
2294 NOTREACHED();
2295 }
2296 }
2297
2298 virtual void afterTest() OVERRIDE
2299 {
2300 }
2301
2302 private:
2303 FakeContentLayerClient m_client;
2304 scoped_refptr<ContentLayer> m_rootLayer;
2305 int m_numCommits;
2306 };
2307
2308 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPinchZoomScrollbarResize)
2309
2197 } // namespace 2310 } // namespace
2198 } // namespace cc 2311 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698