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

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

Issue 2018833002: cc : Delete LayerImpl::opacity (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 "cc/input/scrollbar_animation_controller_linear_fade.h" 5 #include "cc/input/scrollbar_animation_controller_linear_fade.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_task_runner_provider.h" 8 #include "cc/test/fake_impl_task_runner_provider.h"
9 #include "cc/test/fake_layer_tree_host_impl.h" 9 #include "cc/test/fake_layer_tree_host_impl.h"
10 #include "cc/test/geometry_test_utils.h" 10 #include "cc/test/geometry_test_utils.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 protected: 45 protected:
46 void SetUp() override { 46 void SetUp() override {
47 const int kThumbThickness = 10; 47 const int kThumbThickness = 10;
48 const int kTrackStart = 0; 48 const int kTrackStart = 0;
49 const bool kIsLeftSideVerticalScrollbar = false; 49 const bool kIsLeftSideVerticalScrollbar = false;
50 const bool kIsOverlayScrollbar = true; // Allow opacity animations. 50 const bool kIsOverlayScrollbar = true; // Allow opacity animations.
51 51
52 std::unique_ptr<LayerImpl> scroll_layer = 52 std::unique_ptr<LayerImpl> scroll_layer =
53 LayerImpl::Create(host_impl_.active_tree(), 1); 53 LayerImpl::Create(host_impl_.active_tree(), 1);
54 scrollbar_layer_ = SolidColorScrollbarLayerImpl::Create( 54 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
55 host_impl_.active_tree(), 2, orientation(), kThumbThickness, 55 SolidColorScrollbarLayerImpl::Create(
56 kTrackStart, kIsLeftSideVerticalScrollbar, kIsOverlayScrollbar); 56 host_impl_.active_tree(), 2, orientation(), kThumbThickness,
57 clip_layer_ = LayerImpl::Create(host_impl_.active_tree(), 3); 57 kTrackStart, kIsLeftSideVerticalScrollbar, kIsOverlayScrollbar);
58 scrollbar_layer_ = scrollbar.get();
59 scrollbar_layer_->test_properties()->force_render_surface = true;
ajuma 2016/05/27 13:35:44 Is this just to force an effect node? If so, how a
jaydasika 2016/05/27 17:50:26 Done.
60 std::unique_ptr<LayerImpl> clip =
61 LayerImpl::Create(host_impl_.active_tree(), 3);
62 clip_layer_ = clip.get();
58 scroll_layer->SetScrollClipLayer(clip_layer_->id()); 63 scroll_layer->SetScrollClipLayer(clip_layer_->id());
59 LayerImpl* scroll_layer_ptr = scroll_layer.get(); 64 LayerImpl* scroll_layer_ptr = scroll_layer.get();
60 clip_layer_->AddChild(std::move(scroll_layer)); 65 scroll_layer->AddChild(std::move(scrollbar));
66 clip->AddChild(std::move(scroll_layer));
67 host_impl_.active_tree()->SetRootLayer(std::move(clip));
61 68
62 scrollbar_layer_->SetScrollLayerId(scroll_layer_ptr->id()); 69 scrollbar_layer_->SetScrollLayerId(scroll_layer_ptr->id());
63 clip_layer_->SetBounds(gfx::Size(100, 100)); 70 clip_layer_->SetBounds(gfx::Size(100, 100));
64 scroll_layer_ptr->SetBounds(gfx::Size(200, 200)); 71 scroll_layer_ptr->SetBounds(gfx::Size(200, 200));
72 host_impl_.active_tree()->BuildPropertyTreesForTesting();
65 73
66 scrollbar_controller_ = ScrollbarAnimationControllerLinearFade::Create( 74 scrollbar_controller_ = ScrollbarAnimationControllerLinearFade::Create(
67 scroll_layer_ptr->id(), this, base::TimeDelta::FromSeconds(2), 75 scroll_layer_ptr->id(), this, base::TimeDelta::FromSeconds(2),
68 base::TimeDelta::FromSeconds(5), base::TimeDelta::FromSeconds(3)); 76 base::TimeDelta::FromSeconds(5), base::TimeDelta::FromSeconds(3));
69 } 77 }
70 78
71 virtual ScrollbarOrientation orientation() const { return HORIZONTAL; } 79 virtual ScrollbarOrientation orientation() const { return HORIZONTAL; }
72 80
73 FakeImplTaskRunnerProvider task_runner_provider_; 81 FakeImplTaskRunnerProvider task_runner_provider_;
74 TestSharedBitmapManager shared_bitmap_manager_; 82 TestSharedBitmapManager shared_bitmap_manager_;
75 TestTaskGraphRunner task_graph_runner_; 83 TestTaskGraphRunner task_graph_runner_;
76 FakeLayerTreeHostImpl host_impl_; 84 FakeLayerTreeHostImpl host_impl_;
77 std::unique_ptr<ScrollbarAnimationControllerLinearFade> scrollbar_controller_; 85 std::unique_ptr<ScrollbarAnimationControllerLinearFade> scrollbar_controller_;
78 std::unique_ptr<LayerImpl> clip_layer_; 86 LayerImpl* clip_layer_;
79 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_layer_; 87 SolidColorScrollbarLayerImpl* scrollbar_layer_;
80 88
81 base::Closure start_fade_; 89 base::Closure start_fade_;
82 base::TimeDelta delay_; 90 base::TimeDelta delay_;
83 bool did_request_redraw_; 91 bool did_request_redraw_;
84 bool did_request_animate_; 92 bool did_request_animate_;
85 }; 93 };
86 94
87 class VerticalScrollbarAnimationControllerLinearFadeTest 95 class VerticalScrollbarAnimationControllerLinearFadeTest
88 : public ScrollbarAnimationControllerLinearFadeTest { 96 : public ScrollbarAnimationControllerLinearFadeTest {
89 protected: 97 protected:
90 ScrollbarOrientation orientation() const override { return VERTICAL; } 98 ScrollbarOrientation orientation() const override { return VERTICAL; }
91 }; 99 };
92 100
93 TEST_F(ScrollbarAnimationControllerLinearFadeTest, DelayAnimationOnResize) { 101 TEST_F(ScrollbarAnimationControllerLinearFadeTest, DelayAnimationOnResize) {
94 scrollbar_layer_->SetOpacity(0.0f); 102 scrollbar_layer_->OnOpacityAnimated(0.0f);
95 scrollbar_controller_->DidScrollBegin(); 103 scrollbar_controller_->DidScrollBegin();
96 scrollbar_controller_->DidScrollUpdate(true); 104 scrollbar_controller_->DidScrollUpdate(true);
97 scrollbar_controller_->DidScrollEnd(); 105 scrollbar_controller_->DidScrollEnd();
98 // Normal Animation delay of 2 seconds. 106 // Normal Animation delay of 2 seconds.
99 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); 107 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
100 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(2)); 108 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(2));
101 109
102 scrollbar_layer_->SetOpacity(0.0f); 110 scrollbar_layer_->OnOpacityAnimated(0.0f);
103 scrollbar_controller_->DidScrollUpdate(true); 111 scrollbar_controller_->DidScrollUpdate(true);
104 // Delay animation on resize to 5 seconds. 112 // Delay animation on resize to 5 seconds.
105 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); 113 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
106 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(5)); 114 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(5));
107 } 115 }
108 116
109 TEST_F(ScrollbarAnimationControllerLinearFadeTest, HiddenInBegin) { 117 TEST_F(ScrollbarAnimationControllerLinearFadeTest, HiddenInBegin) {
110 scrollbar_layer_->SetOpacity(0.0f); 118 scrollbar_layer_->OnOpacityAnimated(0.0f);
111 scrollbar_controller_->Animate(base::TimeTicks()); 119 scrollbar_controller_->Animate(base::TimeTicks());
112 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); 120 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
113 } 121 }
114 122
115 TEST_F(ScrollbarAnimationControllerLinearFadeTest, 123 TEST_F(ScrollbarAnimationControllerLinearFadeTest,
116 HiddenAfterNonScrollingGesture) { 124 HiddenAfterNonScrollingGesture) {
117 scrollbar_layer_->SetOpacity(0.0f); 125 scrollbar_layer_->OnOpacityAnimated(0.0f);
118 scrollbar_controller_->DidScrollBegin(); 126 scrollbar_controller_->DidScrollBegin();
119 127
120 base::TimeTicks time; 128 base::TimeTicks time;
121 time += base::TimeDelta::FromSeconds(100); 129 time += base::TimeDelta::FromSeconds(100);
122 scrollbar_controller_->Animate(time); 130 scrollbar_controller_->Animate(time);
123 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); 131 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
124 scrollbar_controller_->DidScrollEnd(); 132 scrollbar_controller_->DidScrollEnd();
125 133
126 EXPECT_TRUE(start_fade_.Equals(base::Closure())); 134 EXPECT_TRUE(start_fade_.Equals(base::Closure()));
127 135
128 time += base::TimeDelta::FromSeconds(100); 136 time += base::TimeDelta::FromSeconds(100);
129 scrollbar_controller_->Animate(time); 137 scrollbar_controller_->Animate(time);
130 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); 138 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
131 } 139 }
132 140
133 TEST_F(ScrollbarAnimationControllerLinearFadeTest, HideOnResize) { 141 TEST_F(ScrollbarAnimationControllerLinearFadeTest, HideOnResize) {
134 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); 142 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
135 ASSERT_TRUE(scroll_layer); 143 ASSERT_TRUE(scroll_layer);
136 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); 144 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds());
137 145
138 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); 146 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation());
139 147
140 // Shrink along X axis, horizontal scrollbar should appear. 148 // Shrink along X axis, horizontal scrollbar should appear.
141 clip_layer_->SetBounds(gfx::Size(100, 200)); 149 clip_layer_->SetBounds(gfx::Size(100, 200));
142 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); 150 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds());
143 151
144 scrollbar_controller_->DidScrollBegin(); 152 scrollbar_controller_->DidScrollBegin();
145 153
146 scrollbar_controller_->DidScrollUpdate(false); 154 scrollbar_controller_->DidScrollUpdate(false);
147 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); 155 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
148 156
149 scrollbar_controller_->DidScrollEnd(); 157 scrollbar_controller_->DidScrollEnd();
150 158
151 // Shrink along Y axis and expand along X, horizontal scrollbar 159 // Shrink along Y axis and expand along X, horizontal scrollbar
152 // should disappear. 160 // should disappear.
153 clip_layer_->SetBounds(gfx::Size(200, 100)); 161 clip_layer_->SetBounds(gfx::Size(200, 100));
154 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); 162 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds());
155 163
156 scrollbar_controller_->DidScrollBegin(); 164 scrollbar_controller_->DidScrollBegin();
157 165
158 scrollbar_controller_->DidScrollUpdate(false); 166 scrollbar_controller_->DidScrollUpdate(false);
159 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); 167 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
160 168
161 scrollbar_controller_->DidScrollEnd(); 169 scrollbar_controller_->DidScrollEnd();
162 } 170 }
163 171
164 TEST_F(VerticalScrollbarAnimationControllerLinearFadeTest, HideOnResize) { 172 TEST_F(VerticalScrollbarAnimationControllerLinearFadeTest, HideOnResize) {
165 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); 173 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
166 ASSERT_TRUE(scroll_layer); 174 ASSERT_TRUE(scroll_layer);
167 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); 175 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds());
168 176
169 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); 177 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation());
170 178
171 // Shrink along X axis, vertical scrollbar should remain invisible. 179 // Shrink along X axis, vertical scrollbar should remain invisible.
172 clip_layer_->SetBounds(gfx::Size(100, 200)); 180 clip_layer_->SetBounds(gfx::Size(100, 200));
173 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); 181 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds());
174 182
175 scrollbar_controller_->DidScrollBegin(); 183 scrollbar_controller_->DidScrollBegin();
176 184
177 scrollbar_controller_->DidScrollUpdate(false); 185 scrollbar_controller_->DidScrollUpdate(false);
178 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); 186 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
179 187
180 scrollbar_controller_->DidScrollEnd(); 188 scrollbar_controller_->DidScrollEnd();
181 189
182 // Shrink along Y axis and expand along X, vertical scrollbar should appear. 190 // Shrink along Y axis and expand along X, vertical scrollbar should appear.
183 clip_layer_->SetBounds(gfx::Size(200, 100)); 191 clip_layer_->SetBounds(gfx::Size(200, 100));
184 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); 192 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds());
185 193
186 scrollbar_controller_->DidScrollBegin(); 194 scrollbar_controller_->DidScrollBegin();
187 195
188 scrollbar_controller_->DidScrollUpdate(false); 196 scrollbar_controller_->DidScrollUpdate(false);
189 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); 197 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
190 198
191 scrollbar_controller_->DidScrollEnd(); 199 scrollbar_controller_->DidScrollEnd();
192 } 200 }
193 201
194 TEST_F(ScrollbarAnimationControllerLinearFadeTest, 202 TEST_F(ScrollbarAnimationControllerLinearFadeTest,
195 HideOnUserNonScrollableHorz) { 203 HideOnUserNonScrollableHorz) {
196 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); 204 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation());
197 205
198 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); 206 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
199 ASSERT_TRUE(scroll_layer); 207 ASSERT_TRUE(scroll_layer);
200 scroll_layer->set_user_scrollable_horizontal(false); 208 scroll_layer->set_user_scrollable_horizontal(false);
201 209
202 scrollbar_controller_->DidScrollBegin(); 210 scrollbar_controller_->DidScrollBegin();
203 211
204 scrollbar_controller_->DidScrollUpdate(false); 212 scrollbar_controller_->DidScrollUpdate(false);
205 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); 213 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
206 214
207 scrollbar_controller_->DidScrollEnd(); 215 scrollbar_controller_->DidScrollEnd();
208 } 216 }
209 217
210 TEST_F(ScrollbarAnimationControllerLinearFadeTest, 218 TEST_F(ScrollbarAnimationControllerLinearFadeTest,
211 ShowOnUserNonScrollableVert) { 219 ShowOnUserNonScrollableVert) {
212 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); 220 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation());
213 221
214 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); 222 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
215 ASSERT_TRUE(scroll_layer); 223 ASSERT_TRUE(scroll_layer);
216 scroll_layer->set_user_scrollable_vertical(false); 224 scroll_layer->set_user_scrollable_vertical(false);
217 225
218 scrollbar_controller_->DidScrollBegin(); 226 scrollbar_controller_->DidScrollBegin();
219 227
220 scrollbar_controller_->DidScrollUpdate(false); 228 scrollbar_controller_->DidScrollUpdate(false);
221 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); 229 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
222 230
223 scrollbar_controller_->DidScrollEnd(); 231 scrollbar_controller_->DidScrollEnd();
224 } 232 }
225 233
226 TEST_F(VerticalScrollbarAnimationControllerLinearFadeTest, 234 TEST_F(VerticalScrollbarAnimationControllerLinearFadeTest,
227 HideOnUserNonScrollableVert) { 235 HideOnUserNonScrollableVert) {
228 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); 236 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation());
229 237
230 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); 238 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
231 ASSERT_TRUE(scroll_layer); 239 ASSERT_TRUE(scroll_layer);
232 scroll_layer->set_user_scrollable_vertical(false); 240 scroll_layer->set_user_scrollable_vertical(false);
233 241
234 scrollbar_controller_->DidScrollBegin(); 242 scrollbar_controller_->DidScrollBegin();
235 243
236 scrollbar_controller_->DidScrollUpdate(false); 244 scrollbar_controller_->DidScrollUpdate(false);
237 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); 245 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
238 246
239 scrollbar_controller_->DidScrollEnd(); 247 scrollbar_controller_->DidScrollEnd();
240 } 248 }
241 249
242 TEST_F(VerticalScrollbarAnimationControllerLinearFadeTest, 250 TEST_F(VerticalScrollbarAnimationControllerLinearFadeTest,
243 ShowOnUserNonScrollableHorz) { 251 ShowOnUserNonScrollableHorz) {
244 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); 252 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation());
245 253
246 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); 254 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
247 ASSERT_TRUE(scroll_layer); 255 ASSERT_TRUE(scroll_layer);
248 scroll_layer->set_user_scrollable_horizontal(false); 256 scroll_layer->set_user_scrollable_horizontal(false);
249 257
250 scrollbar_controller_->DidScrollBegin(); 258 scrollbar_controller_->DidScrollBegin();
251 259
252 scrollbar_controller_->DidScrollUpdate(false); 260 scrollbar_controller_->DidScrollUpdate(false);
253 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); 261 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
254 262
255 scrollbar_controller_->DidScrollEnd(); 263 scrollbar_controller_->DidScrollEnd();
256 } 264 }
257 265
258 TEST_F(ScrollbarAnimationControllerLinearFadeTest, AwakenByScrollingGesture) { 266 TEST_F(ScrollbarAnimationControllerLinearFadeTest, AwakenByScrollingGesture) {
259 base::TimeTicks time; 267 base::TimeTicks time;
260 time += base::TimeDelta::FromSeconds(1); 268 time += base::TimeDelta::FromSeconds(1);
261 scrollbar_controller_->DidScrollBegin(); 269 scrollbar_controller_->DidScrollBegin();
262 EXPECT_FALSE(did_request_animate_); 270 EXPECT_FALSE(did_request_animate_);
263 271
264 scrollbar_controller_->DidScrollUpdate(false); 272 scrollbar_controller_->DidScrollUpdate(false);
265 EXPECT_FALSE(did_request_animate_); 273 EXPECT_FALSE(did_request_animate_);
266 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); 274 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
267 275
268 EXPECT_TRUE(start_fade_.Equals(base::Closure())); 276 EXPECT_TRUE(start_fade_.Equals(base::Closure()));
269 277
270 time += base::TimeDelta::FromSeconds(100); 278 time += base::TimeDelta::FromSeconds(100);
271 279
272 scrollbar_controller_->Animate(time); 280 scrollbar_controller_->Animate(time);
273 EXPECT_FALSE(did_request_animate_); 281 EXPECT_FALSE(did_request_animate_);
274 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); 282 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
275 scrollbar_controller_->DidScrollEnd(); 283 scrollbar_controller_->DidScrollEnd();
276 EXPECT_FALSE(did_request_animate_); 284 EXPECT_FALSE(did_request_animate_);
277 start_fade_.Run(); 285 start_fade_.Run();
278 EXPECT_TRUE(did_request_animate_); 286 EXPECT_TRUE(did_request_animate_);
279 did_request_animate_ = false; 287 did_request_animate_ = false;
280 288
281 time += base::TimeDelta::FromSeconds(2); 289 time += base::TimeDelta::FromSeconds(2);
282 scrollbar_controller_->Animate(time); 290 scrollbar_controller_->Animate(time);
283 EXPECT_TRUE(did_request_animate_); 291 EXPECT_TRUE(did_request_animate_);
284 did_request_animate_ = false; 292 did_request_animate_ = false;
285 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); 293 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
286 294
287 time += base::TimeDelta::FromSeconds(1); 295 time += base::TimeDelta::FromSeconds(1);
288 scrollbar_controller_->Animate(time); 296 scrollbar_controller_->Animate(time);
289 EXPECT_TRUE(did_request_animate_); 297 EXPECT_TRUE(did_request_animate_);
290 did_request_animate_ = false; 298 did_request_animate_ = false;
291 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->opacity()); 299 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity());
292 300
293 time += base::TimeDelta::FromSeconds(1); 301 time += base::TimeDelta::FromSeconds(1);
294 scrollbar_controller_->Animate(time); 302 scrollbar_controller_->Animate(time);
295 EXPECT_TRUE(did_request_animate_); 303 EXPECT_TRUE(did_request_animate_);
296 did_request_animate_ = false; 304 did_request_animate_ = false;
297 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->opacity()); 305 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity());
298 306
299 time += base::TimeDelta::FromSeconds(1); 307 time += base::TimeDelta::FromSeconds(1);
300 308
301 scrollbar_controller_->DidScrollBegin(); 309 scrollbar_controller_->DidScrollBegin();
302 scrollbar_controller_->DidScrollUpdate(false); 310 scrollbar_controller_->DidScrollUpdate(false);
303 scrollbar_controller_->DidScrollEnd(); 311 scrollbar_controller_->DidScrollEnd();
304 312
305 start_fade_.Run(); 313 start_fade_.Run();
306 EXPECT_TRUE(did_request_animate_); 314 EXPECT_TRUE(did_request_animate_);
307 did_request_animate_ = false; 315 did_request_animate_ = false;
308 316
309 time += base::TimeDelta::FromSeconds(2); 317 time += base::TimeDelta::FromSeconds(2);
310 scrollbar_controller_->Animate(time); 318 scrollbar_controller_->Animate(time);
311 EXPECT_TRUE(did_request_animate_); 319 EXPECT_TRUE(did_request_animate_);
312 did_request_animate_ = false; 320 did_request_animate_ = false;
313 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); 321 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
314 322
315 time += base::TimeDelta::FromSeconds(1); 323 time += base::TimeDelta::FromSeconds(1);
316 scrollbar_controller_->Animate(time); 324 scrollbar_controller_->Animate(time);
317 EXPECT_TRUE(did_request_animate_); 325 EXPECT_TRUE(did_request_animate_);
318 did_request_animate_ = false; 326 did_request_animate_ = false;
319 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->opacity()); 327 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity());
320 328
321 time += base::TimeDelta::FromSeconds(1); 329 time += base::TimeDelta::FromSeconds(1);
322 scrollbar_controller_->Animate(time); 330 scrollbar_controller_->Animate(time);
323 EXPECT_TRUE(did_request_animate_); 331 EXPECT_TRUE(did_request_animate_);
324 did_request_animate_ = false; 332 did_request_animate_ = false;
325 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->opacity()); 333 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity());
326 334
327 time += base::TimeDelta::FromSeconds(1); 335 time += base::TimeDelta::FromSeconds(1);
328 scrollbar_controller_->Animate(time); 336 scrollbar_controller_->Animate(time);
329 EXPECT_FALSE(did_request_animate_); 337 EXPECT_FALSE(did_request_animate_);
330 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); 338 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
331 } 339 }
332 340
333 TEST_F(ScrollbarAnimationControllerLinearFadeTest, AwakenByProgrammaticScroll) { 341 TEST_F(ScrollbarAnimationControllerLinearFadeTest, AwakenByProgrammaticScroll) {
334 base::TimeTicks time; 342 base::TimeTicks time;
335 time += base::TimeDelta::FromSeconds(1); 343 time += base::TimeDelta::FromSeconds(1);
336 scrollbar_controller_->DidScrollUpdate(false); 344 scrollbar_controller_->DidScrollUpdate(false);
337 EXPECT_FALSE(did_request_animate_); 345 EXPECT_FALSE(did_request_animate_);
338 346
339 start_fade_.Run(); 347 start_fade_.Run();
340 EXPECT_TRUE(did_request_animate_); 348 EXPECT_TRUE(did_request_animate_);
341 did_request_animate_ = false; 349 did_request_animate_ = false;
342 scrollbar_controller_->Animate(time); 350 scrollbar_controller_->Animate(time);
343 EXPECT_TRUE(did_request_animate_); 351 EXPECT_TRUE(did_request_animate_);
344 did_request_animate_ = false; 352 did_request_animate_ = false;
345 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); 353 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
346 354
347 time += base::TimeDelta::FromSeconds(1); 355 time += base::TimeDelta::FromSeconds(1);
348 scrollbar_controller_->Animate(time); 356 scrollbar_controller_->Animate(time);
349 EXPECT_TRUE(did_request_animate_); 357 EXPECT_TRUE(did_request_animate_);
350 did_request_animate_ = false; 358 did_request_animate_ = false;
351 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->opacity()); 359 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity());
352 scrollbar_controller_->DidScrollUpdate(false); 360 scrollbar_controller_->DidScrollUpdate(false);
353 EXPECT_FALSE(did_request_animate_); 361 EXPECT_FALSE(did_request_animate_);
354 362
355 start_fade_.Run(); 363 start_fade_.Run();
356 EXPECT_TRUE(did_request_animate_); 364 EXPECT_TRUE(did_request_animate_);
357 did_request_animate_ = false; 365 did_request_animate_ = false;
358 time += base::TimeDelta::FromSeconds(2); 366 time += base::TimeDelta::FromSeconds(2);
359 scrollbar_controller_->Animate(time); 367 scrollbar_controller_->Animate(time);
360 EXPECT_TRUE(did_request_animate_); 368 EXPECT_TRUE(did_request_animate_);
361 did_request_animate_ = false; 369 did_request_animate_ = false;
362 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); 370 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
363 371
364 time += base::TimeDelta::FromSeconds(1); 372 time += base::TimeDelta::FromSeconds(1);
365 scrollbar_controller_->Animate(time); 373 scrollbar_controller_->Animate(time);
366 EXPECT_TRUE(did_request_animate_); 374 EXPECT_TRUE(did_request_animate_);
367 did_request_animate_ = false; 375 did_request_animate_ = false;
368 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->opacity()); 376 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity());
369 377
370 time += base::TimeDelta::FromSeconds(1); 378 time += base::TimeDelta::FromSeconds(1);
371 scrollbar_controller_->Animate(time); 379 scrollbar_controller_->Animate(time);
372 EXPECT_TRUE(did_request_animate_); 380 EXPECT_TRUE(did_request_animate_);
373 did_request_animate_ = false; 381 did_request_animate_ = false;
374 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->opacity()); 382 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity());
375 383
376 time += base::TimeDelta::FromSeconds(1); 384 time += base::TimeDelta::FromSeconds(1);
377 scrollbar_controller_->DidScrollUpdate(false); 385 scrollbar_controller_->DidScrollUpdate(false);
378 start_fade_.Run(); 386 start_fade_.Run();
379 time += base::TimeDelta::FromSeconds(1); 387 time += base::TimeDelta::FromSeconds(1);
380 scrollbar_controller_->Animate(time); 388 scrollbar_controller_->Animate(time);
381 EXPECT_TRUE(did_request_animate_); 389 EXPECT_TRUE(did_request_animate_);
382 did_request_animate_ = false; 390 did_request_animate_ = false;
383 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); 391 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
384 392
385 time += base::TimeDelta::FromSeconds(1); 393 time += base::TimeDelta::FromSeconds(1);
386 scrollbar_controller_->Animate(time); 394 scrollbar_controller_->Animate(time);
387 EXPECT_TRUE(did_request_animate_); 395 EXPECT_TRUE(did_request_animate_);
388 did_request_animate_ = false; 396 did_request_animate_ = false;
389 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->opacity()); 397 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity());
390 398
391 time += base::TimeDelta::FromSeconds(1); 399 time += base::TimeDelta::FromSeconds(1);
392 scrollbar_controller_->Animate(time); 400 scrollbar_controller_->Animate(time);
393 EXPECT_TRUE(did_request_animate_); 401 EXPECT_TRUE(did_request_animate_);
394 did_request_animate_ = false; 402 did_request_animate_ = false;
395 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->opacity()); 403 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity());
396 404
397 time += base::TimeDelta::FromSeconds(1); 405 time += base::TimeDelta::FromSeconds(1);
398 scrollbar_controller_->Animate(time); 406 scrollbar_controller_->Animate(time);
399 EXPECT_FALSE(did_request_animate_); 407 EXPECT_FALSE(did_request_animate_);
400 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); 408 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
401 } 409 }
402 410
403 TEST_F(ScrollbarAnimationControllerLinearFadeTest, 411 TEST_F(ScrollbarAnimationControllerLinearFadeTest,
404 AnimationPreservedByNonScrollingGesture) { 412 AnimationPreservedByNonScrollingGesture) {
405 base::TimeTicks time; 413 base::TimeTicks time;
406 time += base::TimeDelta::FromSeconds(1); 414 time += base::TimeDelta::FromSeconds(1);
407 scrollbar_controller_->DidScrollUpdate(false); 415 scrollbar_controller_->DidScrollUpdate(false);
408 start_fade_.Run(); 416 start_fade_.Run();
409 EXPECT_TRUE(did_request_animate_); 417 EXPECT_TRUE(did_request_animate_);
410 did_request_animate_ = false; 418 did_request_animate_ = false;
411 scrollbar_controller_->Animate(time); 419 scrollbar_controller_->Animate(time);
412 EXPECT_TRUE(did_request_animate_); 420 EXPECT_TRUE(did_request_animate_);
413 did_request_animate_ = false; 421 did_request_animate_ = false;
414 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); 422 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
415 423
416 time += base::TimeDelta::FromSeconds(1); 424 time += base::TimeDelta::FromSeconds(1);
417 scrollbar_controller_->Animate(time); 425 scrollbar_controller_->Animate(time);
418 EXPECT_TRUE(did_request_animate_); 426 EXPECT_TRUE(did_request_animate_);
419 did_request_animate_ = false; 427 did_request_animate_ = false;
420 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->opacity()); 428 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity());
421 429
422 scrollbar_controller_->DidScrollBegin(); 430 scrollbar_controller_->DidScrollBegin();
423 EXPECT_FALSE(did_request_animate_); 431 EXPECT_FALSE(did_request_animate_);
424 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->opacity()); 432 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity());
425 433
426 time += base::TimeDelta::FromSeconds(1); 434 time += base::TimeDelta::FromSeconds(1);
427 scrollbar_controller_->Animate(time); 435 scrollbar_controller_->Animate(time);
428 EXPECT_TRUE(did_request_animate_); 436 EXPECT_TRUE(did_request_animate_);
429 did_request_animate_ = false; 437 did_request_animate_ = false;
430 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->opacity()); 438 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity());
431 439
432 scrollbar_controller_->DidScrollEnd(); 440 scrollbar_controller_->DidScrollEnd();
433 EXPECT_FALSE(did_request_animate_); 441 EXPECT_FALSE(did_request_animate_);
434 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->opacity()); 442 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity());
435 443
436 time += base::TimeDelta::FromSeconds(1); 444 time += base::TimeDelta::FromSeconds(1);
437 scrollbar_controller_->Animate(time); 445 scrollbar_controller_->Animate(time);
438 EXPECT_FALSE(did_request_animate_); 446 EXPECT_FALSE(did_request_animate_);
439 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); 447 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
440 } 448 }
441 449
442 TEST_F(ScrollbarAnimationControllerLinearFadeTest, 450 TEST_F(ScrollbarAnimationControllerLinearFadeTest,
443 AnimationOverriddenByScrollingGesture) { 451 AnimationOverriddenByScrollingGesture) {
444 base::TimeTicks time; 452 base::TimeTicks time;
445 time += base::TimeDelta::FromSeconds(1); 453 time += base::TimeDelta::FromSeconds(1);
446 scrollbar_controller_->DidScrollUpdate(false); 454 scrollbar_controller_->DidScrollUpdate(false);
447 EXPECT_FALSE(did_request_animate_); 455 EXPECT_FALSE(did_request_animate_);
448 start_fade_.Run(); 456 start_fade_.Run();
449 EXPECT_TRUE(did_request_animate_); 457 EXPECT_TRUE(did_request_animate_);
450 did_request_animate_ = false; 458 did_request_animate_ = false;
451 scrollbar_controller_->Animate(time); 459 scrollbar_controller_->Animate(time);
452 EXPECT_TRUE(did_request_animate_); 460 EXPECT_TRUE(did_request_animate_);
453 did_request_animate_ = false; 461 did_request_animate_ = false;
454 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); 462 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
455 463
456 time += base::TimeDelta::FromSeconds(1); 464 time += base::TimeDelta::FromSeconds(1);
457 scrollbar_controller_->Animate(time); 465 scrollbar_controller_->Animate(time);
458 EXPECT_TRUE(did_request_animate_); 466 EXPECT_TRUE(did_request_animate_);
459 did_request_animate_ = false; 467 did_request_animate_ = false;
460 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->opacity()); 468 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity());
461 469
462 scrollbar_controller_->DidScrollBegin(); 470 scrollbar_controller_->DidScrollBegin();
463 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->opacity()); 471 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity());
464 472
465 time += base::TimeDelta::FromSeconds(1); 473 time += base::TimeDelta::FromSeconds(1);
466 scrollbar_controller_->Animate(time); 474 scrollbar_controller_->Animate(time);
467 EXPECT_TRUE(did_request_animate_); 475 EXPECT_TRUE(did_request_animate_);
468 did_request_animate_ = false; 476 did_request_animate_ = false;
469 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->opacity()); 477 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity());
470 478
471 time += base::TimeDelta::FromSeconds(1); 479 time += base::TimeDelta::FromSeconds(1);
472 scrollbar_controller_->DidScrollUpdate(false); 480 scrollbar_controller_->DidScrollUpdate(false);
473 EXPECT_FALSE(did_request_animate_); 481 EXPECT_FALSE(did_request_animate_);
474 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); 482 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity());
475 483
476 time += base::TimeDelta::FromSeconds(1); 484 time += base::TimeDelta::FromSeconds(1);
477 scrollbar_controller_->DidScrollEnd(); 485 scrollbar_controller_->DidScrollEnd();
478 EXPECT_FALSE(did_request_animate_); 486 EXPECT_FALSE(did_request_animate_);
479 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); 487 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity());
480 } 488 }
481 489
482 } // namespace 490 } // namespace
483 } // namespace cc 491 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698