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

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: Nits, use device_viewport_size, explicit forcing of first paint. 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 2159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2188 private: 2189 private:
2189 FakeContentLayerClient m_client; 2190 FakeContentLayerClient m_client;
2190 scoped_refptr<FakeContentLayer> m_rootLayer; 2191 scoped_refptr<FakeContentLayer> m_rootLayer;
2191 scoped_refptr<FakeContentLayer> m_childLayer1; 2192 scoped_refptr<FakeContentLayer> m_childLayer1;
2192 scoped_refptr<FakeContentLayer> m_childLayer2; 2193 scoped_refptr<FakeContentLayer> m_childLayer2;
2193 int m_numCommits; 2194 int m_numCommits;
2194 }; 2195 };
2195 2196
2196 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestShutdownWithOnlySomeResourcesEvi cted) 2197 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestShutdownWithOnlySomeResourcesEvi cted)
2197 2198
2199 class LayerTreeHostTestPinchZoomScrollbarCreation : public LayerTreeHostTest {
2200 public:
2201 LayerTreeHostTestPinchZoomScrollbarCreation()
2202 : m_rootLayer(ContentLayer::Create(&m_client))
2203 {
2204 m_settings.usePinchZoomScrollbars = true;
2205 }
2206
2207 virtual void beginTest() OVERRIDE
2208 {
2209 m_rootLayer->SetIsDrawable(true);
2210 m_rootLayer->SetBounds(gfx::Size(100, 100));
2211 m_layerTreeHost->setRootLayer(m_rootLayer);
2212 postSetNeedsCommitToMainThread();
2213 }
2214
2215 virtual void didCommit() OVERRIDE
2216 {
2217 // We always expect two pinch-zoom scrollbar layers.
2218 ASSERT_TRUE(2 == m_rootLayer->children().size());
2219
2220 // Pinch-zoom scrollbar layers always have invalid scrollLayerIds.
2221 ScrollbarLayer* layer1 = m_rootLayer->children()[0]->ToScrollbarLayer();
2222 ASSERT_TRUE(layer1);
2223 EXPECT_EQ(Layer::NOTUSED_ID, layer1->scroll_layer_id());
2224 EXPECT_EQ(0, layer1->opacity());
2225 EXPECT_TRUE(layer1->DrawsContent());
2226
2227 ScrollbarLayer* layer2 = m_rootLayer->children()[1]->ToScrollbarLayer();
2228 ASSERT_TRUE(layer2);
2229 EXPECT_EQ(Layer::NOTUSED_ID, layer2->scroll_layer_id());
2230 EXPECT_EQ(0, layer2->opacity());
2231 EXPECT_TRUE(layer2->DrawsContent());
2232
2233 endTest();
2234 }
2235
2236 virtual void afterTest() OVERRIDE
2237 {
2238 }
2239
2240 private:
2241 FakeContentLayerClient m_client;
2242 scoped_refptr<ContentLayer> m_rootLayer;
2243 };
2244
2245 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPinchZoomScrollbarCreation)
2246
2247 class LayerTreeHostTestPinchZoomScrollbarResize : public LayerTreeHostTest {
2248 public:
2249 LayerTreeHostTestPinchZoomScrollbarResize()
2250 : m_rootLayer(ContentLayer::Create(&m_client))
2251 , m_numCommits(0)
2252 {
2253 m_settings.usePinchZoomScrollbars = true;
2254 }
2255
2256 virtual void beginTest() OVERRIDE
2257 {
2258 m_rootLayer->SetIsDrawable(true);
2259 m_rootLayer->SetBounds(gfx::Size(100, 100));
2260 m_layerTreeHost->setRootLayer(m_rootLayer);
2261 m_layerTreeHost->setViewportSize(gfx::Size(100, 100),
2262 gfx::Size(100, 100));
2263 postSetNeedsCommitToMainThread();
2264 }
2265
2266 virtual void didCommit() OVERRIDE
2267 {
2268 m_numCommits++;
2269
2270 ScrollbarLayer* layer1 = m_rootLayer->children()[0]->ToScrollbarLayer();
2271 ASSERT_TRUE(layer1);
2272 ScrollbarLayer* layer2 = m_rootLayer->children()[1]->ToScrollbarLayer();
2273 ASSERT_TRUE(layer2);
2274
2275 // Get scrollbar thickness from horizontal scrollbar's height.
2276 int thickness = layer1->bounds().height();
2277
2278 if (!layer1->Orientation() == WebKit::WebScrollbar::Horizontal)
2279 std::swap(layer1, layer2);
2280
2281 gfx::Size viewportSize = m_layerTreeHost->layoutViewportSize();
2282 EXPECT_EQ(viewportSize.width() - thickness, layer1->bounds().width());
2283 EXPECT_EQ(viewportSize.height() - thickness, layer2->bounds().height());
2284
2285 switch (m_numCommits) {
2286 case 1:
2287 // Resizing the viewport should also resize the pinch-zoom scrollbars.
2288 m_layerTreeHost->setViewportSize(gfx::Size(120, 150),
2289 gfx::Size(120, 150));
2290 break;
2291 case 2:
2292 endTest();
2293 break;
2294 default:
2295 NOTREACHED();
2296 }
2297 }
2298
2299 virtual void afterTest() OVERRIDE
2300 {
2301 }
2302
2303 private:
2304 FakeContentLayerClient m_client;
2305 scoped_refptr<ContentLayer> m_rootLayer;
2306 int m_numCommits;
2307 };
2308
2309 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPinchZoomScrollbarResize)
2310
2198 } // namespace 2311 } // namespace
2199 } // namespace cc 2312 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698