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

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

Issue 135183016: Revert of Pinch/Zoom Infrastructure & Plumbing CL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 "cc/animation/scrollbar_animation_controller_linear_fade.h" 5 #include "cc/animation/scrollbar_animation_controller_linear_fade.h"
6 6
7 #include "cc/layers/solid_color_scrollbar_layer_impl.h" 7 #include "cc/layers/painted_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 ScrollbarAnimationControllerLinearFadeTest : public testing::Test { 15 class ScrollbarAnimationControllerLinearFadeTest : public testing::Test {
16 public: 16 public:
17 ScrollbarAnimationControllerLinearFadeTest() : host_impl_(&proxy_) {} 17 ScrollbarAnimationControllerLinearFadeTest() : host_impl_(&proxy_) {}
18 18
19 protected: 19 protected:
20 virtual void SetUp() { 20 virtual void SetUp() {
21 const int kThumbThickness = 10; 21 scroll_layer_ = LayerImpl::Create(host_impl_.active_tree(), 1);
22 const bool kIsLeftSideVerticalScrollbar = false; 22 scrollbar_layer_ = PaintedScrollbarLayerImpl::Create(
23 const bool kIsOverlayScrollbar = true; // Allow opacity animations. 23 host_impl_.active_tree(), 2, HORIZONTAL);
24 24
25 scoped_ptr<LayerImpl> scroll_layer = 25 scroll_layer_->SetMaxScrollOffset(gfx::Vector2d(50, 50));
26 LayerImpl::Create(host_impl_.active_tree(), 1); 26 scroll_layer_->SetBounds(gfx::Size(50, 50));
27 scrollbar_layer_ = 27 scroll_layer_->SetHorizontalScrollbarLayer(scrollbar_layer_.get());
28 SolidColorScrollbarLayerImpl::Create(host_impl_.active_tree(),
29 2,
30 HORIZONTAL,
31 kThumbThickness,
32 kIsLeftSideVerticalScrollbar,
33 kIsOverlayScrollbar);
34 clip_layer_ = LayerImpl::Create(host_impl_.active_tree(), 3);
35 scroll_layer->SetScrollClipLayer(clip_layer_->id());
36 LayerImpl* scroll_layer_ptr = scroll_layer.get();
37 clip_layer_->AddChild(scroll_layer.Pass());
38
39 scrollbar_layer_->SetClipLayerById(clip_layer_->id());
40 scrollbar_layer_->SetScrollLayerById(scroll_layer_ptr->id());
41 clip_layer_->SetBounds(gfx::Size(100, 100));
42 scroll_layer_ptr->SetBounds(gfx::Size(50, 50));
43 28
44 scrollbar_controller_ = ScrollbarAnimationControllerLinearFade::Create( 29 scrollbar_controller_ = ScrollbarAnimationControllerLinearFade::Create(
45 scroll_layer_ptr, 30 scroll_layer_.get(),
46 base::TimeDelta::FromSeconds(2), 31 base::TimeDelta::FromSeconds(2),
47 base::TimeDelta::FromSeconds(3)); 32 base::TimeDelta::FromSeconds(3));
48 } 33 }
49 34
50 FakeImplProxy proxy_; 35 FakeImplProxy proxy_;
51 FakeLayerTreeHostImpl host_impl_; 36 FakeLayerTreeHostImpl host_impl_;
52 scoped_ptr<ScrollbarAnimationControllerLinearFade> scrollbar_controller_; 37 scoped_ptr<ScrollbarAnimationControllerLinearFade> scrollbar_controller_;
53 scoped_ptr<LayerImpl> clip_layer_; 38 scoped_ptr<LayerImpl> scroll_layer_;
54 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar_layer_; 39 scoped_ptr<PaintedScrollbarLayerImpl> scrollbar_layer_;
55 }; 40 };
56 41
57 TEST_F(ScrollbarAnimationControllerLinearFadeTest, HiddenInBegin) { 42 TEST_F(ScrollbarAnimationControllerLinearFadeTest, HiddenInBegin) {
58 scrollbar_controller_->Animate(base::TimeTicks()); 43 scrollbar_controller_->Animate(base::TimeTicks());
59 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); 44 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity());
60 } 45 }
61 46
62 TEST_F(ScrollbarAnimationControllerLinearFadeTest, 47 TEST_F(ScrollbarAnimationControllerLinearFadeTest,
63 HiddenAfterNonScrollingGesture) { 48 HiddenAfterNonScrollingGesture) {
64 scrollbar_controller_->DidScrollGestureBegin(); 49 scrollbar_controller_->DidScrollGestureBegin();
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); 237 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity());
253 238
254 time += base::TimeDelta::FromSeconds(1); 239 time += base::TimeDelta::FromSeconds(1);
255 scrollbar_controller_->DidScrollGestureEnd(time); 240 scrollbar_controller_->DidScrollGestureEnd(time);
256 EXPECT_TRUE(scrollbar_controller_->IsAnimating()); 241 EXPECT_TRUE(scrollbar_controller_->IsAnimating());
257 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); 242 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity());
258 } 243 }
259 244
260 } // namespace 245 } // namespace
261 } // namespace cc 246 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/scrollbar_animation_controller_linear_fade.cc ('k') | cc/animation/scrollbar_animation_controller_thinning.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698