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

Side by Side Diff: cc/scrollbar_animation_controller_linear_fade_unittest.cc

Issue 12408028: cc: Delay start of scrollbar animation setNeedsRedraw. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to 188682 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
« no previous file with comments | « cc/scrollbar_animation_controller_linear_fade.cc ('k') | cc/single_thread_proxy.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 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/scrollbar_animation_controller_linear_fade.h" 5 #include "cc/scrollbar_animation_controller_linear_fade.h"
6 6
7 #include "cc/scrollbar_layer_impl.h" 7 #include "cc/scrollbar_layer_impl.h"
8 #include "cc/single_thread_proxy.h" 8 #include "cc/single_thread_proxy.h"
9 #include "cc/test/fake_impl_proxy.h" 9 #include "cc/test/fake_impl_proxy.h"
10 #include "cc/test/fake_layer_tree_host_impl.h" 10 #include "cc/test/fake_layer_tree_host_impl.h"
(...skipping 14 matching lines...) Expand all
25 virtual void SetUp() 25 virtual void SetUp()
26 { 26 {
27 m_scrollLayer = LayerImpl::Create(m_hostImpl.active_tree(), 1); 27 m_scrollLayer = LayerImpl::Create(m_hostImpl.active_tree(), 1);
28 scoped_ptr<ScrollbarGeometryFixedThumb> geometry(ScrollbarGeometryFixedT humb::create(FakeWebScrollbarThemeGeometry::create(false))); 28 scoped_ptr<ScrollbarGeometryFixedThumb> geometry(ScrollbarGeometryFixedT humb::create(FakeWebScrollbarThemeGeometry::create(false)));
29 m_scrollbarLayer = ScrollbarLayerImpl::Create(m_hostImpl.active_tree(), 2, geometry.Pass()); 29 m_scrollbarLayer = ScrollbarLayerImpl::Create(m_hostImpl.active_tree(), 2, geometry.Pass());
30 30
31 m_scrollLayer->SetMaxScrollOffset(gfx::Vector2d(50, 50)); 31 m_scrollLayer->SetMaxScrollOffset(gfx::Vector2d(50, 50));
32 m_scrollLayer->SetBounds(gfx::Size(50, 50)); 32 m_scrollLayer->SetBounds(gfx::Size(50, 50));
33 m_scrollLayer->SetHorizontalScrollbarLayer(m_scrollbarLayer.get()); 33 m_scrollLayer->SetHorizontalScrollbarLayer(m_scrollbarLayer.get());
34 34
35 m_scrollbarController = ScrollbarAnimationControllerLinearFade::create(m _scrollLayer.get(), 2, 3); 35 m_scrollbarController = ScrollbarAnimationControllerLinearFade::create(m _scrollLayer.get(), base::TimeDelta::FromSeconds(2), base::TimeDelta::FromSecond s(3));
36 } 36 }
37 37
38 FakeImplProxy m_proxy; 38 FakeImplProxy m_proxy;
39 FakeLayerTreeHostImpl m_hostImpl; 39 FakeLayerTreeHostImpl m_hostImpl;
40 scoped_ptr<ScrollbarAnimationControllerLinearFade> m_scrollbarController; 40 scoped_ptr<ScrollbarAnimationControllerLinearFade> m_scrollbarController;
41 scoped_ptr<LayerImpl> m_scrollLayer; 41 scoped_ptr<LayerImpl> m_scrollLayer;
42 scoped_ptr<ScrollbarLayerImpl> m_scrollbarLayer; 42 scoped_ptr<ScrollbarLayerImpl> m_scrollbarLayer;
43 43
44 }; 44 };
45 45
46 TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyHiddenInBegin) 46 TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyHiddenInBegin)
47 { 47 {
48 m_scrollbarController->animate(base::TimeTicks()); 48 m_scrollbarController->animate(base::TimeTicks());
49 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); 49 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity());
50 } 50 }
51 51
52 TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByScroll) 52 TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByScrollGesture)
53 { 53 {
54 base::TimeTicks time; 54 base::TimeTicks time;
55 time += base::TimeDelta::FromSeconds(1); 55 time += base::TimeDelta::FromSeconds(1);
56 m_scrollbarController->didUpdateScrollOffset(time); 56 m_scrollbarController->didScrollGestureBegin();
57 EXPECT_TRUE(m_scrollbarController->isScrollGestureInProgress());
58 EXPECT_FALSE(m_scrollbarController->isAnimating());
59 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
60
61 time += base::TimeDelta::FromSeconds(100);
57 m_scrollbarController->animate(time); 62 m_scrollbarController->animate(time);
58 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 63 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
64 m_scrollbarController->didScrollGestureEnd(time);
65
66 EXPECT_FALSE(m_scrollbarController->isScrollGestureInProgress());
67 EXPECT_TRUE(m_scrollbarController->isAnimating());
68 EXPECT_EQ(2, m_scrollbarController->delayBeforeStart(time).InSeconds());
59 69
60 time += base::TimeDelta::FromSeconds(1); 70 time += base::TimeDelta::FromSeconds(1);
61 m_scrollbarController->animate(time); 71 m_scrollbarController->animate(time);
62 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
63 m_scrollbarController->didUpdateScrollOffset(time);
64
65 time += base::TimeDelta::FromSeconds(1);
66 m_scrollbarController->animate(time);
67 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 72 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
68 73
69 time += base::TimeDelta::FromSeconds(1); 74 time += base::TimeDelta::FromSeconds(1);
70 m_scrollbarController->animate(time); 75 m_scrollbarController->animate(time);
71 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 76 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
72 77
73 time += base::TimeDelta::FromSeconds(1); 78 time += base::TimeDelta::FromSeconds(1);
74 m_scrollbarController->animate(time); 79 m_scrollbarController->animate(time);
75 EXPECT_FLOAT_EQ(2.0f / 3.0f, m_scrollbarLayer->opacity()); 80 EXPECT_FLOAT_EQ(2.0f / 3.0f, m_scrollbarLayer->opacity());
76 81
77 time += base::TimeDelta::FromSeconds(1); 82 time += base::TimeDelta::FromSeconds(1);
78 m_scrollbarController->animate(time); 83 m_scrollbarController->animate(time);
79 EXPECT_FLOAT_EQ(1.0f / 3.0f, m_scrollbarLayer->opacity()); 84 EXPECT_FLOAT_EQ(1.0f / 3.0f, m_scrollbarLayer->opacity());
80 85
81 time += base::TimeDelta::FromSeconds(1); 86 time += base::TimeDelta::FromSeconds(1);
82 m_scrollbarController->didUpdateScrollOffset(time); 87
88 m_scrollbarController->didScrollGestureBegin();
89 m_scrollbarController->didScrollGestureEnd(time);
90
83 time += base::TimeDelta::FromSeconds(1); 91 time += base::TimeDelta::FromSeconds(1);
84 m_scrollbarController->animate(time); 92 m_scrollbarController->animate(time);
85 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 93 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
86 94
87 time += base::TimeDelta::FromSeconds(1); 95 time += base::TimeDelta::FromSeconds(1);
88 m_scrollbarController->animate(time); 96 m_scrollbarController->animate(time);
89 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 97 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
90 98
91 time += base::TimeDelta::FromSeconds(1); 99 time += base::TimeDelta::FromSeconds(1);
92 m_scrollbarController->animate(time); 100 m_scrollbarController->animate(time);
93 EXPECT_FLOAT_EQ(2.0f / 3.0f, m_scrollbarLayer->opacity()); 101 EXPECT_FLOAT_EQ(2.0f / 3.0f, m_scrollbarLayer->opacity());
94 102
95 time += base::TimeDelta::FromSeconds(1); 103 time += base::TimeDelta::FromSeconds(1);
96 m_scrollbarController->animate(time); 104 m_scrollbarController->animate(time);
97 EXPECT_FLOAT_EQ(1.0f / 3.0f, m_scrollbarLayer->opacity()); 105 EXPECT_FLOAT_EQ(1.0f / 3.0f, m_scrollbarLayer->opacity());
98 106
99 time += base::TimeDelta::FromSeconds(1); 107 time += base::TimeDelta::FromSeconds(1);
100 m_scrollbarController->animate(time); 108 m_scrollbarController->animate(time);
101 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); 109 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity());
102 } 110 }
103 111
104 TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyForceAwakenByPinch) 112 TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByProgrammaticScr oll)
105 { 113 {
106 base::TimeTicks time; 114 base::TimeTicks time;
107 m_scrollbarController->didPinchGestureUpdate(time); 115 time += base::TimeDelta::FromSeconds(1);
116 m_scrollbarController->didProgrammaticallyUpdateScroll(time);
117 EXPECT_FALSE(m_scrollbarController->isScrollGestureInProgress());
118 EXPECT_TRUE(m_scrollbarController->isAnimating());
119 EXPECT_EQ(2, m_scrollbarController->delayBeforeStart(time).InSeconds());
108 m_scrollbarController->animate(time); 120 m_scrollbarController->animate(time);
109 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 121 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
110 122
111 time += base::TimeDelta::FromSeconds(1); 123 time += base::TimeDelta::FromSeconds(1);
112 m_scrollbarController->animate(time); 124 m_scrollbarController->animate(time);
113 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 125 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
126 m_scrollbarController->didProgrammaticallyUpdateScroll(time);
114 127
115 time += base::TimeDelta::FromSeconds(1); 128 time += base::TimeDelta::FromSeconds(1);
116 m_scrollbarController->animate(time); 129 m_scrollbarController->animate(time);
117 m_scrollbarController->didUpdateScrollOffset(time);
118 m_scrollbarController->animate(time);
119 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
120
121 time += base::TimeDelta::FromSeconds(1);
122 m_scrollbarController->animate(time);
123 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 130 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
124 131
125 time += base::TimeDelta::FromSeconds(1); 132 time += base::TimeDelta::FromSeconds(1);
126 m_scrollbarController->animate(time); 133 m_scrollbarController->animate(time);
127 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 134 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
128 135
129 time += base::TimeDelta::FromSeconds(1); 136 time += base::TimeDelta::FromSeconds(1);
130 m_scrollbarController->animate(time); 137 m_scrollbarController->animate(time);
138 EXPECT_FLOAT_EQ(2.0f / 3.0f, m_scrollbarLayer->opacity());
139
140 time += base::TimeDelta::FromSeconds(1);
141 m_scrollbarController->animate(time);
142 EXPECT_FLOAT_EQ(1.0f / 3.0f, m_scrollbarLayer->opacity());
143
144 time += base::TimeDelta::FromSeconds(1);
145 m_scrollbarController->didProgrammaticallyUpdateScroll(time);
146 time += base::TimeDelta::FromSeconds(1);
147 m_scrollbarController->animate(time);
131 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 148 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
132 149
133 time += base::TimeDelta::FromSeconds(1);
134 m_scrollbarController->animate(time);
135 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
136
137 time += base::TimeDelta::FromSeconds(1);
138 m_scrollbarController->didPinchGestureEnd(time);
139 m_scrollbarController->animate(time);
140 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
141
142 time += base::TimeDelta::FromSeconds(1); 150 time += base::TimeDelta::FromSeconds(1);
143 m_scrollbarController->animate(time); 151 m_scrollbarController->animate(time);
144 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 152 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
145 153
146 time += base::TimeDelta::FromSeconds(2); 154 time += base::TimeDelta::FromSeconds(1);
147 m_scrollbarController->animate(time); 155 m_scrollbarController->animate(time);
148 EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity()); 156 EXPECT_FLOAT_EQ(2.0f / 3.0f, m_scrollbarLayer->opacity());
149 157
150 time += base::TimeDelta::FromSeconds(1); 158 time += base::TimeDelta::FromSeconds(1);
151 m_scrollbarController->animate(time); 159 m_scrollbarController->animate(time);
152 EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity()); 160 EXPECT_FLOAT_EQ(1.0f / 3.0f, m_scrollbarLayer->opacity());
153 161
154 time += base::TimeDelta::FromSeconds(1); 162 time += base::TimeDelta::FromSeconds(1);
155 m_scrollbarController->animate(time); 163 m_scrollbarController->animate(time);
156 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); 164 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity());
157
158 } 165 }
159 166
160 } // namespace 167 } // namespace
161 } // namespace cc 168 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scrollbar_animation_controller_linear_fade.cc ('k') | cc/single_thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698