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

Side by Side Diff: cc/trees/layer_tree_impl_unittest.cc

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | cc/trees/layer_tree_settings.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/trees/layer_tree_impl.h" 5 #include "cc/trees/layer_tree_impl.h"
6 6
7 #include "cc/layers/heads_up_display_layer_impl.h" 7 #include "cc/layers/heads_up_display_layer_impl.h"
8 #include "cc/layers/layer.h" 8 #include "cc/layers/layer.h"
9 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
9 #include "cc/test/fake_impl_proxy.h" 10 #include "cc/test/fake_impl_proxy.h"
10 #include "cc/test/fake_layer_tree_host_impl.h" 11 #include "cc/test/fake_layer_tree_host_impl.h"
11 #include "cc/test/fake_output_surface.h" 12 #include "cc/test/fake_output_surface.h"
12 #include "cc/test/geometry_test_utils.h" 13 #include "cc/test/geometry_test_utils.h"
13 #include "cc/test/layer_tree_host_common_test.h" 14 #include "cc/test/layer_tree_host_common_test.h"
14 #include "cc/test/test_shared_bitmap_manager.h" 15 #include "cc/test/test_shared_bitmap_manager.h"
15 #include "cc/trees/layer_tree_host_impl.h" 16 #include "cc/trees/layer_tree_host_impl.h"
16 #include "ui/gfx/geometry/size_conversions.h" 17 #include "ui/gfx/geometry/size_conversions.h"
17 18
18 namespace cc { 19 namespace cc {
19 namespace { 20 namespace {
20 21
21 class LayerTreeImplTest : public LayerTreeHostCommonTest { 22 class LayerTreeImplTest : public LayerTreeHostCommonTest {
22 public: 23 public:
23 LayerTreeImplTest() { 24 LayerTreeImplTest() {
24 LayerTreeSettings settings; 25 LayerTreeSettings settings;
25 settings.layer_transforms_should_scale_layer_contents = true; 26 settings.layer_transforms_should_scale_layer_contents = true;
27 settings.scrollbar_show_scale_threshold = 1.1f;
26 host_impl_.reset( 28 host_impl_.reset(
27 new FakeLayerTreeHostImpl(settings, &proxy_, &shared_bitmap_manager_)); 29 new FakeLayerTreeHostImpl(settings, &proxy_, &shared_bitmap_manager_));
28 EXPECT_TRUE(host_impl_->InitializeRenderer(FakeOutputSurface::Create3d())); 30 EXPECT_TRUE(host_impl_->InitializeRenderer(FakeOutputSurface::Create3d()));
29 } 31 }
30 32
31 FakeLayerTreeHostImpl& host_impl() { return *host_impl_; } 33 FakeLayerTreeHostImpl& host_impl() { return *host_impl_; }
32 34
33 LayerImpl* root_layer() { return host_impl_->active_tree()->root_layer(); } 35 LayerImpl* root_layer() { return host_impl_->active_tree()->root_layer(); }
34 36
35 const LayerImplList& RenderSurfaceLayerList() const { 37 const LayerImplList& RenderSurfaceLayerList() const {
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 test_point); 1366 test_point);
1365 EXPECT_FALSE(result_layer); 1367 EXPECT_FALSE(result_layer);
1366 1368
1367 test_point = gfx::Point(-1, -1); 1369 test_point = gfx::Point(-1, -1);
1368 result_layer = 1370 result_layer =
1369 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( 1371 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
1370 test_point); 1372 test_point);
1371 EXPECT_FALSE(result_layer); 1373 EXPECT_FALSE(result_layer);
1372 } 1374 }
1373 1375
1376 TEST_F(LayerTreeImplTest, MakeScrollbarsInvisibleNearMinPageScale) {
1377 const int kThumbThickness = 10;
1378 const int kTrackStart = 0;
1379 const bool kIsLeftSideVerticalScrollbar = false;
1380 const bool kIsOverlayScrollbar = true;
1381
1382 LayerTreeImpl* active_tree = host_impl().active_tree();
1383
1384 scoped_ptr<LayerImpl> scroll_layer = LayerImpl::Create(active_tree, 1);
1385 scoped_ptr<SolidColorScrollbarLayerImpl> vertical_scrollbar_layer =
1386 SolidColorScrollbarLayerImpl::Create(active_tree,
1387 2,
1388 VERTICAL,
1389 kThumbThickness,
1390 kTrackStart,
1391 kIsLeftSideVerticalScrollbar,
1392 kIsOverlayScrollbar);
1393 scoped_ptr<SolidColorScrollbarLayerImpl> horizontal_scrollbar_layer =
1394 SolidColorScrollbarLayerImpl::Create(active_tree,
1395 3,
1396 HORIZONTAL,
1397 kThumbThickness,
1398 kTrackStart,
1399 kIsLeftSideVerticalScrollbar,
1400 kIsOverlayScrollbar);
1401
1402 scoped_ptr<LayerImpl> clip_layer = LayerImpl::Create(active_tree, 4);
1403 scoped_ptr<LayerImpl> page_scale_layer = LayerImpl::Create(active_tree, 5);
1404
1405 scroll_layer->SetScrollClipLayer(clip_layer->id());
1406
1407 LayerImpl* scroll_layer_ptr = scroll_layer.get();
1408 LayerImpl* page_scale_layer_ptr = page_scale_layer.get();
1409
1410 clip_layer->AddChild(page_scale_layer.Pass());
1411 page_scale_layer_ptr->AddChild(scroll_layer.Pass());
1412
1413 vertical_scrollbar_layer->SetScrollLayerAndClipLayerByIds(
1414 scroll_layer_ptr->id(),
1415 clip_layer->id());
1416 horizontal_scrollbar_layer->SetScrollLayerAndClipLayerByIds(
1417 scroll_layer_ptr->id(),
1418 clip_layer->id());
1419
1420 active_tree->PushPageScaleFromMainThread(1.0f, 1.0f, 4.0f);
1421 active_tree->SetViewportLayersFromIds(
1422 Layer::INVALID_ID, // Overscroll
1423 page_scale_layer_ptr->id(),
1424 scroll_layer_ptr->id(),
1425 Layer::INVALID_ID); // Outer Scroll
1426
1427 EXPECT_TRUE(vertical_scrollbar_layer->hide_layer_and_subtree());
1428 EXPECT_TRUE(horizontal_scrollbar_layer->hide_layer_and_subtree());
1429
1430 active_tree->PushPageScaleFromMainThread(1.05f, 1.0f, 4.0f);
1431 EXPECT_TRUE(vertical_scrollbar_layer->hide_layer_and_subtree());
1432 EXPECT_TRUE(horizontal_scrollbar_layer->hide_layer_and_subtree());
1433
1434 active_tree->PushPageScaleFromMainThread(1.1f, 1.0f, 4.0f);
1435 EXPECT_FALSE(vertical_scrollbar_layer->hide_layer_and_subtree());
1436 EXPECT_FALSE(horizontal_scrollbar_layer->hide_layer_and_subtree());
1437
1438 active_tree->PushPageScaleFromMainThread(1.5f, 1.0f, 4.0f);
1439 EXPECT_FALSE(vertical_scrollbar_layer->hide_layer_and_subtree());
1440 EXPECT_FALSE(horizontal_scrollbar_layer->hide_layer_and_subtree());
1441 }
1442
1374 TEST_F(LayerTreeImplTest, 1443 TEST_F(LayerTreeImplTest,
1375 HitCheckingTouchHandlerRegionsForSinglePositionedLayer) { 1444 HitCheckingTouchHandlerRegionsForSinglePositionedLayer) {
1376 scoped_ptr<LayerImpl> root = 1445 scoped_ptr<LayerImpl> root =
1377 LayerImpl::Create(host_impl().active_tree(), 12345); 1446 LayerImpl::Create(host_impl().active_tree(), 12345);
1378 1447
1379 gfx::Transform identity_matrix; 1448 gfx::Transform identity_matrix;
1380 Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); 1449 Region touch_handler_region(gfx::Rect(10, 10, 50, 50));
1381 gfx::Point3F transform_origin; 1450 gfx::Point3F transform_origin;
1382 // this layer is positioned, and hit testing should correctly know where the 1451 // this layer is positioned, and hit testing should correctly know where the
1383 // layer is located. 1452 // layer is located.
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
2088 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); 2157 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers());
2089 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); 2158 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1);
2090 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); 2159 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2));
2091 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); 2160 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3));
2092 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); 2161 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4));
2093 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); 2162 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers());
2094 } 2163 }
2095 2164
2096 } // namespace 2165 } // namespace
2097 } // namespace cc 2166 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | cc/trees/layer_tree_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698