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

Side by Side Diff: cc/animation/scrollbar_animation_controller_thinning_unittest.cc

Issue 23983047: Pinch/Zoom Infrastructure & Plumbing CL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add fix for empty scroll-layer bounds. Created 6 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/animation/scrollbar_animation_controller_thinning.h" 5 #include "cc/animation/scrollbar_animation_controller_thinning.h"
6 6
7 #include "cc/layers/solid_color_scrollbar_layer_impl.h" 7 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
8 #include "cc/test/fake_impl_proxy.h" 8 #include "cc/test/fake_impl_proxy.h"
9 #include "cc/test/fake_layer_tree_host_impl.h" 9 #include "cc/test/fake_layer_tree_host_impl.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace cc { 12 namespace cc {
13 namespace { 13 namespace {
14 14
15 class ScrollbarAnimationControllerThinningTest : public testing::Test { 15 class ScrollbarAnimationControllerThinningTest : public testing::Test {
16 public: 16 public:
17 ScrollbarAnimationControllerThinningTest() : host_impl_(&proxy_) {} 17 ScrollbarAnimationControllerThinningTest() : host_impl_(&proxy_) {}
18 18
19 protected: 19 protected:
20 virtual void SetUp() { 20 virtual void SetUp() {
21 scroll_layer_ = LayerImpl::Create(host_impl_.active_tree(), 1); 21 scoped_ptr<LayerImpl> scroll_layer =
22 LayerImpl::Create(host_impl_.active_tree(), 1);
23 clip_layer_ = LayerImpl::Create(host_impl_.active_tree(), 3);
24 scroll_layer->SetScrollClipLayer(clip_layer_->id());
25 LayerImpl* scroll_layer_ptr = scroll_layer.get();
26 clip_layer_->AddChild(scroll_layer.Pass());
27
22 const int kId = 2; 28 const int kId = 2;
23 const int kThumbThickness = 10; 29 const int kThumbThickness = 10;
24 const bool kIsLeftSideVerticalScrollbar = false; 30 const bool kIsLeftSideVerticalScrollbar = false;
31 const bool kIsOverlayScrollbar = true;
25 scrollbar_layer_ = SolidColorScrollbarLayerImpl::Create( 32 scrollbar_layer_ = SolidColorScrollbarLayerImpl::Create(
26 host_impl_.active_tree(), kId, HORIZONTAL, kThumbThickness, 33 host_impl_.active_tree(), kId, HORIZONTAL, kThumbThickness,
27 kIsLeftSideVerticalScrollbar); 34 kIsLeftSideVerticalScrollbar, kIsOverlayScrollbar);
28 35
29 scroll_layer_->SetMaxScrollOffset(gfx::Vector2d(50, 50)); 36 scrollbar_layer_->SetClipLayerById(clip_layer_->id());
30 scroll_layer_->SetBounds(gfx::Size(50, 50)); 37 scrollbar_layer_->SetScrollLayerById(scroll_layer_ptr->id());
31 scroll_layer_->SetHorizontalScrollbarLayer(scrollbar_layer_.get()); 38 clip_layer_->SetBounds(gfx::Size(100, 100));
39 scroll_layer_ptr->SetBounds(gfx::Size(50, 50));
32 40
33 scrollbar_controller_ = ScrollbarAnimationControllerThinning::CreateForTest( 41 scrollbar_controller_ = ScrollbarAnimationControllerThinning::CreateForTest(
34 scroll_layer_.get(), 42 scroll_layer_ptr,
35 base::TimeDelta::FromSeconds(2), 43 base::TimeDelta::FromSeconds(2),
36 base::TimeDelta::FromSeconds(3)); 44 base::TimeDelta::FromSeconds(3));
37 } 45 }
38 46
39 FakeImplProxy proxy_; 47 FakeImplProxy proxy_;
40 FakeLayerTreeHostImpl host_impl_; 48 FakeLayerTreeHostImpl host_impl_;
41 scoped_ptr<ScrollbarAnimationControllerThinning> scrollbar_controller_; 49 scoped_ptr<ScrollbarAnimationControllerThinning> scrollbar_controller_;
42 scoped_ptr<LayerImpl> scroll_layer_; 50 scoped_ptr<LayerImpl> clip_layer_;
43 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar_layer_; 51 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar_layer_;
44 }; 52 };
45 53
46 // Check initialization of scrollbar. 54 // Check initialization of scrollbar.
47 TEST_F(ScrollbarAnimationControllerThinningTest, Idle) { 55 TEST_F(ScrollbarAnimationControllerThinningTest, Idle) {
48 scrollbar_controller_->Animate(base::TimeTicks()); 56 scrollbar_controller_->Animate(base::TimeTicks());
49 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->opacity()); 57 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->opacity());
50 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor()); 58 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor());
51 } 59 }
52 60
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 331
324 time += base::TimeDelta::FromSeconds(1); 332 time += base::TimeDelta::FromSeconds(1);
325 scrollbar_controller_->Animate(time); 333 scrollbar_controller_->Animate(time);
326 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->opacity()); 334 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->opacity());
327 // The thickness now gets big again. 335 // The thickness now gets big again.
328 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 336 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
329 } 337 }
330 338
331 } // namespace 339 } // namespace
332 } // namespace cc 340 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698