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

Side by Side Diff: cc/layers/scrollbar_layer_unittest.cc

Issue 2803853007: Ignore rounding error between clip_layer_length_ and scroll_layer_length_ (Closed)
Patch Set: rebase update Created 3 years, 8 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <unordered_map> 7 #include <unordered_map>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "cc/animation/animation_host.h" 11 #include "cc/animation/animation_host.h"
12 #include "cc/input/scrollbar_animation_controller.h" 12 #include "cc/input/scrollbar_animation_controller.h"
13 #include "cc/layers/append_quads_data.h" 13 #include "cc/layers/append_quads_data.h"
14 #include "cc/layers/painted_overlay_scrollbar_layer.h" 14 #include "cc/layers/painted_overlay_scrollbar_layer.h"
15 #include "cc/layers/painted_scrollbar_layer.h" 15 #include "cc/layers/painted_scrollbar_layer.h"
16 #include "cc/layers/painted_scrollbar_layer_impl.h" 16 #include "cc/layers/painted_scrollbar_layer_impl.h"
17 #include "cc/layers/scrollbar_layer_interface.h" 17 #include "cc/layers/scrollbar_layer_interface.h"
18 #include "cc/layers/solid_color_scrollbar_layer.h" 18 #include "cc/layers/solid_color_scrollbar_layer.h"
19 #include "cc/layers/solid_color_scrollbar_layer_impl.h" 19 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
20 #include "cc/quads/solid_color_draw_quad.h" 20 #include "cc/quads/solid_color_draw_quad.h"
21 #include "cc/resources/ui_resource_manager.h" 21 #include "cc/resources/ui_resource_manager.h"
22 #include "cc/test/fake_impl_task_runner_provider.h" 22 #include "cc/test/fake_impl_task_runner_provider.h"
23 #include "cc/test/fake_layer_tree_host.h" 23 #include "cc/test/fake_layer_tree_host.h"
24 #include "cc/test/fake_layer_tree_host_client.h" 24 #include "cc/test/fake_layer_tree_host_client.h"
25 #include "cc/test/fake_layer_tree_host_impl.h" 25 #include "cc/test/fake_layer_tree_host_impl.h"
26 #include "cc/test/fake_painted_scrollbar_layer.h" 26 #include "cc/test/fake_painted_scrollbar_layer.h"
27 #include "cc/test/fake_scrollbar.h" 27 #include "cc/test/fake_scrollbar.h"
28 #include "cc/test/geometry_test_utils.h" 28 #include "cc/test/geometry_test_utils.h"
29 #include "cc/test/layer_test_common.h"
29 #include "cc/test/layer_tree_test.h" 30 #include "cc/test/layer_tree_test.h"
30 #include "cc/test/mock_occlusion_tracker.h" 31 #include "cc/test/mock_occlusion_tracker.h"
31 #include "cc/test/stub_layer_tree_host_single_thread_client.h" 32 #include "cc/test/stub_layer_tree_host_single_thread_client.h"
32 #include "cc/test/test_context_provider.h" 33 #include "cc/test/test_context_provider.h"
33 #include "cc/test/test_task_graph_runner.h" 34 #include "cc/test/test_task_graph_runner.h"
34 #include "cc/test/test_web_graphics_context_3d.h" 35 #include "cc/test/test_web_graphics_context_3d.h"
35 #include "cc/trees/effect_node.h" 36 #include "cc/trees/effect_node.h"
36 #include "cc/trees/layer_tree_host.h" 37 #include "cc/trees/layer_tree_host.h"
37 #include "cc/trees/layer_tree_impl.h" 38 #include "cc/trees/layer_tree_impl.h"
38 #include "cc/trees/occlusion_tracker.h" 39 #include "cc/trees/occlusion_tracker.h"
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 layer_tree_host_->UpdateLayers(); 760 layer_tree_host_->UpdateLayers();
760 host_impl->CreatePendingTree(); 761 host_impl->CreatePendingTree();
761 layer_tree_host_->CommitAndCreatePendingTree(); 762 layer_tree_host_->CommitAndCreatePendingTree();
762 host_impl->ActivateSyncTree(); 763 host_impl->ActivateSyncTree();
763 EffectNode* node = 764 EffectNode* node =
764 host_impl->active_tree()->property_trees()->effect_tree.Node( 765 host_impl->active_tree()->property_trees()->effect_tree.Node(
765 scrollbar_layer->effect_tree_index()); 766 scrollbar_layer->effect_tree_index());
766 EXPECT_EQ(node->opacity, 1.f); 767 EXPECT_EQ(node->opacity, 1.f);
767 } 768 }
768 769
770 TEST_F(ScrollbarLayerTest, SubPixelCanScrollOrientation) {
771 gfx::Size viewport_size(100, 100);
772
773 LayerTestCommon::LayerImplTest impl;
774
775 LayerImpl* clip_layer = impl.AddChildToRoot<LayerImpl>();
776 LayerImpl* scroll_layer = impl.AddChild<LayerImpl>(clip_layer);
777
778 scroll_layer->SetScrollClipLayer(clip_layer->id());
779
780 const int kTrackStart = 0;
781 const int kThumbThickness = 10;
782 const bool kIsLeftSideVerticalScrollbar = false;
783 const bool kIsOverlayScrollbar = false;
784
785 SolidColorScrollbarLayerImpl* scrollbar_layer =
786 impl.AddChild<SolidColorScrollbarLayerImpl>(
787 scroll_layer, HORIZONTAL, kThumbThickness, kTrackStart,
788 kIsLeftSideVerticalScrollbar, kIsOverlayScrollbar);
789
790 scrollbar_layer->SetScrollInfo(scroll_layer->id(),
791 scrollbar_layer->element_id());
792 clip_layer->SetBounds(gfx::Size(100, 100));
793 scroll_layer->SetBounds(gfx::Size(100, 100));
794
795 impl.CalcDrawProps(viewport_size);
796
797 // Fake device scale.
798 impl.host_impl()->active_tree()->SetDeviceScaleFactor(3);
799
800 // Fake clip layer length to scrollbar to mock rounding error.
801 scrollbar_layer->SetClipLayerLength(99.99f);
802
803 EXPECT_FALSE(scrollbar_layer->CanScrollOrientation());
804
805 // Fake clip layer length to scrollbar to 1 device pixel shorter than scroll
806 // layer.
807 scrollbar_layer->SetClipLayerLength(99.65f);
808
809 EXPECT_TRUE(scrollbar_layer->CanScrollOrientation());
810 }
811
769 class ScrollbarLayerSolidColorThumbTest : public testing::Test { 812 class ScrollbarLayerSolidColorThumbTest : public testing::Test {
770 public: 813 public:
771 ScrollbarLayerSolidColorThumbTest() { 814 ScrollbarLayerSolidColorThumbTest() {
772 LayerTreeSettings layer_tree_settings; 815 LayerTreeSettings layer_tree_settings;
773 host_impl_.reset(new FakeLayerTreeHostImpl( 816 host_impl_.reset(new FakeLayerTreeHostImpl(
774 layer_tree_settings, &task_runner_provider_, &task_graph_runner_)); 817 layer_tree_settings, &task_runner_provider_, &task_graph_runner_));
775 818
776 const int kThumbThickness = 3; 819 const int kThumbThickness = 3;
777 const int kTrackStart = 0; 820 const int kTrackStart = 0;
778 const bool kIsLeftSideVerticalScrollbar = false; 821 const bool kIsLeftSideVerticalScrollbar = false;
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); 1291 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f);
1249 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); 1292 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f);
1250 1293
1251 // Horizontal Scrollbars. 1294 // Horizontal Scrollbars.
1252 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); 1295 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f);
1253 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); 1296 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f);
1254 } 1297 }
1255 1298
1256 } // namespace 1299 } // namespace
1257 } // namespace cc 1300 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698