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

Side by Side Diff: cc/trees/layer_tree_host_unittest_animation.cc

Issue 12965007: Fix cpplint errors in cc/(animation|input|layers|trees|test)/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased 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 | 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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "cc/animation/animation_curve.h" 7 #include "cc/animation/animation_curve.h"
8 #include "cc/animation/layer_animation_controller.h" 8 #include "cc/animation/layer_animation_controller.h"
9 #include "cc/animation/timing_function.h" 9 #include "cc/animation/timing_function.h"
10 #include "cc/layers/layer.h" 10 #include "cc/layers/layer.h"
11 #include "cc/layers/layer_impl.h" 11 #include "cc/layers/layer_impl.h"
12 #include "cc/test/fake_content_layer.h" 12 #include "cc/test/fake_content_layer.h"
13 #include "cc/test/fake_content_layer_client.h" 13 #include "cc/test/fake_content_layer_client.h"
14 #include "cc/test/layer_tree_test.h" 14 #include "cc/test/layer_tree_test.h"
15 15
16 namespace cc { 16 namespace cc {
17 namespace { 17 namespace {
18 18
19 class LayerTreeHostAnimationTest : public LayerTreeTest { 19 class LayerTreeHostAnimationTest : public LayerTreeTest {
20 public: 20 public:
21 virtual void SetupTree() OVERRIDE { 21 virtual void SetupTree() OVERRIDE {
22 LayerTreeTest::SetupTree(); 22 LayerTreeTest::SetupTree();
23 layer_tree_host()->root_layer()->set_layer_animation_delegate(this); 23 layer_tree_host()->root_layer()->set_layer_animation_delegate(this);
24 } 24 }
25 }; 25 };
26 26
27 // Makes sure that SetNeedsAnimate does not cause the CommitRequested() state to 27 // Makes sure that SetNeedsAnimate does not cause the CommitRequested() state to
28 // be set. 28 // be set.
29 class LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested : 29 class LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested
30 public LayerTreeHostAnimationTest { 30 : public LayerTreeHostAnimationTest {
31 public: 31 public:
32 LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested() 32 LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested()
33 : num_commits_(0) {} 33 : num_commits_(0) {}
34 34
35 virtual void BeginTest() OVERRIDE { 35 virtual void BeginTest() OVERRIDE {
36 PostSetNeedsCommitToMainThread(); 36 PostSetNeedsCommitToMainThread();
37 } 37 }
38 38
39 virtual void Animate(base::TimeTicks monotonic_time) OVERRIDE { 39 virtual void Animate(base::TimeTicks monotonic_time) OVERRIDE {
40 // We skip the first commit becasue its the commit that populates the 40 // We skip the first commit becasue its the commit that populates the
(...skipping 29 matching lines...) Expand all
70 }; 70 };
71 71
72 MULTI_THREAD_TEST_F( 72 MULTI_THREAD_TEST_F(
73 LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested) 73 LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested)
74 74
75 // Trigger a frame with SetNeedsCommit. Then, inside the resulting animate 75 // Trigger a frame with SetNeedsCommit. Then, inside the resulting animate
76 // callback, requet another frame using SetNeedsAnimate. End the test when 76 // callback, requet another frame using SetNeedsAnimate. End the test when
77 // animate gets called yet-again, indicating that the proxy is correctly 77 // animate gets called yet-again, indicating that the proxy is correctly
78 // handling the case where SetNeedsAnimate() is called inside the begin frame 78 // handling the case where SetNeedsAnimate() is called inside the begin frame
79 // flow. 79 // flow.
80 class LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback : 80 class LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback
81 public LayerTreeHostAnimationTest { 81 : public LayerTreeHostAnimationTest {
82 public: 82 public:
83 LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback() 83 LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback()
84 : num_animates_(0) {} 84 : num_animates_(0) {}
85 85
86 virtual void BeginTest() OVERRIDE { 86 virtual void BeginTest() OVERRIDE {
87 PostSetNeedsCommitToMainThread(); 87 PostSetNeedsCommitToMainThread();
88 } 88 }
89 89
90 virtual void Animate(base::TimeTicks) OVERRIDE { 90 virtual void Animate(base::TimeTicks) OVERRIDE {
91 if (!num_animates_) { 91 if (!num_animates_) {
92 layer_tree_host()->SetNeedsAnimate(); 92 layer_tree_host()->SetNeedsAnimate();
93 num_animates_++; 93 num_animates_++;
94 return; 94 return;
95 } 95 }
96 EndTest(); 96 EndTest();
97 } 97 }
98 98
99 virtual void AfterTest() OVERRIDE {} 99 virtual void AfterTest() OVERRIDE {}
100 100
101 private: 101 private:
102 int num_animates_; 102 int num_animates_;
103 }; 103 };
104 104
105 MULTI_THREAD_TEST_F( 105 MULTI_THREAD_TEST_F(
106 LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback) 106 LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback)
107 107
108 // Add a layer animation and confirm that 108 // Add a layer animation and confirm that
109 // LayerTreeHostImpl::updateAnimationState does get called and continues to 109 // LayerTreeHostImpl::updateAnimationState does get called and continues to
110 // get called. 110 // get called.
111 class LayerTreeHostAnimationTestAddAnimation : 111 class LayerTreeHostAnimationTestAddAnimation
112 public LayerTreeHostAnimationTest { 112 : public LayerTreeHostAnimationTest {
113 public: 113 public:
114 LayerTreeHostAnimationTestAddAnimation() 114 LayerTreeHostAnimationTestAddAnimation()
115 : num_animates_(0) 115 : num_animates_(0)
116 , received_animation_started_notification_(false) 116 , received_animation_started_notification_(false)
117 , start_time_(0.0) { 117 , start_time_(0.0) {
118 } 118 }
119 119
120 virtual void BeginTest() OVERRIDE { 120 virtual void BeginTest() OVERRIDE {
121 PostAddInstantAnimationToMainThread(); 121 PostAddInstantAnimationToMainThread();
122 } 122 }
(...skipping 29 matching lines...) Expand all
152 private: 152 private:
153 int num_animates_; 153 int num_animates_;
154 bool received_animation_started_notification_; 154 bool received_animation_started_notification_;
155 double start_time_; 155 double start_time_;
156 }; 156 };
157 157
158 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestAddAnimation) 158 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestAddAnimation)
159 159
160 // Add a layer animation to a layer, but continually fail to draw. Confirm that 160 // Add a layer animation to a layer, but continually fail to draw. Confirm that
161 // after a while, we do eventually force a draw. 161 // after a while, we do eventually force a draw.
162 class LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws : 162 class LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws
163 public LayerTreeHostAnimationTest { 163 : public LayerTreeHostAnimationTest {
164 public: 164 public:
165 LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws() 165 LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws()
166 : started_animating_(false) {} 166 : started_animating_(false) {}
167 167
168 virtual void BeginTest() OVERRIDE { 168 virtual void BeginTest() OVERRIDE {
169 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); 169 PostAddAnimationToMainThread(layer_tree_host()->root_layer());
170 } 170 }
171 171
172 virtual void AnimateLayers( 172 virtual void AnimateLayers(
173 LayerTreeHostImpl* host_impl, 173 LayerTreeHostImpl* host_impl,
174 base::TimeTicks monotonic_time) OVERRIDE { 174 base::TimeTicks monotonic_time) OVERRIDE {
175 started_animating_ = true; 175 started_animating_ = true;
176 } 176 }
177 177
178 virtual void DrawLayersOnThread(LayerTreeHostImpl*) OVERRIDE { 178 virtual void DrawLayersOnThread(LayerTreeHostImpl* tree_impl) OVERRIDE {
179 if (started_animating_) 179 if (started_animating_)
180 EndTest(); 180 EndTest();
181 } 181 }
182 182
183 virtual bool PrepareToDrawOnThread( 183 virtual bool PrepareToDrawOnThread(
184 LayerTreeHostImpl* host_impl, 184 LayerTreeHostImpl* host_impl,
185 LayerTreeHostImpl::FrameData* frame, 185 LayerTreeHostImpl::FrameData* frame,
186 bool result) OVERRIDE { 186 bool result) OVERRIDE {
187 return false; 187 return false;
188 } 188 }
189 189
190 virtual void AfterTest() OVERRIDE {} 190 virtual void AfterTest() OVERRIDE {}
191 191
192 private: 192 private:
193 bool started_animating_; 193 bool started_animating_;
194 }; 194 };
195 195
196 // Starvation can only be an issue with the MT compositor. 196 // Starvation can only be an issue with the MT compositor.
197 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws) 197 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws)
198 198
199 // Ensures that animations continue to be ticked when we are backgrounded. 199 // Ensures that animations continue to be ticked when we are backgrounded.
200 class LayerTreeHostAnimationTestTickAnimationWhileBackgrounded : 200 class LayerTreeHostAnimationTestTickAnimationWhileBackgrounded
201 public LayerTreeHostAnimationTest { 201 : public LayerTreeHostAnimationTest {
202 public: 202 public:
203 LayerTreeHostAnimationTestTickAnimationWhileBackgrounded() 203 LayerTreeHostAnimationTestTickAnimationWhileBackgrounded()
204 : num_animates_(0) {} 204 : num_animates_(0) {}
205 205
206 virtual void BeginTest() OVERRIDE { 206 virtual void BeginTest() OVERRIDE {
207 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); 207 PostAddAnimationToMainThread(layer_tree_host()->root_layer());
208 } 208 }
209 209
210 // Use WillAnimateLayers to set visible false before the animation runs and 210 // Use WillAnimateLayers to set visible false before the animation runs and
211 // causes a commit, so we block the second visible animate in single-thread 211 // causes a commit, so we block the second visible animate in single-thread
(...skipping 16 matching lines...) Expand all
228 virtual void AfterTest() OVERRIDE {} 228 virtual void AfterTest() OVERRIDE {}
229 229
230 private: 230 private:
231 int num_animates_; 231 int num_animates_;
232 }; 232 };
233 233
234 SINGLE_AND_MULTI_THREAD_TEST_F( 234 SINGLE_AND_MULTI_THREAD_TEST_F(
235 LayerTreeHostAnimationTestTickAnimationWhileBackgrounded) 235 LayerTreeHostAnimationTestTickAnimationWhileBackgrounded)
236 236
237 // Ensures that animations continue to be ticked when we are backgrounded. 237 // Ensures that animations continue to be ticked when we are backgrounded.
238 class LayerTreeHostAnimationTestAddAnimationWithTimingFunction : 238 class LayerTreeHostAnimationTestAddAnimationWithTimingFunction
239 public LayerTreeHostAnimationTest { 239 : public LayerTreeHostAnimationTest {
240 public: 240 public:
241 LayerTreeHostAnimationTestAddAnimationWithTimingFunction() {} 241 LayerTreeHostAnimationTestAddAnimationWithTimingFunction() {}
242 242
243 virtual void BeginTest() OVERRIDE { 243 virtual void BeginTest() OVERRIDE {
244 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); 244 PostAddAnimationToMainThread(layer_tree_host()->root_layer());
245 } 245 }
246 246
247 virtual void AnimateLayers( 247 virtual void AnimateLayers(
248 LayerTreeHostImpl* host_impl, 248 LayerTreeHostImpl* host_impl,
249 base::TimeTicks monotonic_time) OVERRIDE { 249 base::TimeTicks monotonic_time) OVERRIDE {
(...skipping 27 matching lines...) Expand all
277 } 277 }
278 278
279 virtual void AfterTest() OVERRIDE {} 279 virtual void AfterTest() OVERRIDE {}
280 }; 280 };
281 281
282 SINGLE_AND_MULTI_THREAD_TEST_F( 282 SINGLE_AND_MULTI_THREAD_TEST_F(
283 LayerTreeHostAnimationTestAddAnimationWithTimingFunction) 283 LayerTreeHostAnimationTestAddAnimationWithTimingFunction)
284 284
285 // Ensures that main thread animations have their start times synchronized with 285 // Ensures that main thread animations have their start times synchronized with
286 // impl thread animations. 286 // impl thread animations.
287 class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes : 287 class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes
288 public LayerTreeHostAnimationTest { 288 : public LayerTreeHostAnimationTest {
289 public: 289 public:
290 LayerTreeHostAnimationTestSynchronizeAnimationStartTimes() 290 LayerTreeHostAnimationTestSynchronizeAnimationStartTimes()
291 : main_start_time_(-1.0), 291 : main_start_time_(-1.0),
292 impl_start_time_(-1.0) {} 292 impl_start_time_(-1.0) {}
293 293
294 virtual void BeginTest() OVERRIDE { 294 virtual void BeginTest() OVERRIDE {
295 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); 295 PostAddAnimationToMainThread(layer_tree_host()->root_layer());
296 } 296 }
297 297
298 virtual void notifyAnimationStarted(double time) OVERRIDE { 298 virtual void notifyAnimationStarted(double time) OVERRIDE {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 330
331 private: 331 private:
332 double main_start_time_; 332 double main_start_time_;
333 double impl_start_time_; 333 double impl_start_time_;
334 }; 334 };
335 335
336 SINGLE_AND_MULTI_THREAD_TEST_F( 336 SINGLE_AND_MULTI_THREAD_TEST_F(
337 LayerTreeHostAnimationTestSynchronizeAnimationStartTimes) 337 LayerTreeHostAnimationTestSynchronizeAnimationStartTimes)
338 338
339 // Ensures that notify animation finished is called. 339 // Ensures that notify animation finished is called.
340 class LayerTreeHostAnimationTestAnimationFinishedEvents : 340 class LayerTreeHostAnimationTestAnimationFinishedEvents
341 public LayerTreeHostAnimationTest { 341 : public LayerTreeHostAnimationTest {
342 public: 342 public:
343 LayerTreeHostAnimationTestAnimationFinishedEvents() {} 343 LayerTreeHostAnimationTestAnimationFinishedEvents() {}
344 344
345 virtual void BeginTest() OVERRIDE { 345 virtual void BeginTest() OVERRIDE {
346 PostAddInstantAnimationToMainThread(); 346 PostAddInstantAnimationToMainThread();
347 } 347 }
348 348
349 virtual void notifyAnimationFinished(double time) OVERRIDE { 349 virtual void notifyAnimationFinished(double time) OVERRIDE {
350 LayerAnimationController* controller = 350 LayerAnimationController* controller =
351 layer_tree_host()->root_layer()->layer_animation_controller(); 351 layer_tree_host()->root_layer()->layer_animation_controller();
352 Animation* animation = 352 Animation* animation =
353 controller->GetAnimation(0, Animation::Opacity); 353 controller->GetAnimation(0, Animation::Opacity);
354 if (animation) 354 if (animation)
355 controller->RemoveAnimation(animation->id()); 355 controller->RemoveAnimation(animation->id());
356 EndTest(); 356 EndTest();
357 } 357 }
358 358
359 virtual void AfterTest() OVERRIDE {} 359 virtual void AfterTest() OVERRIDE {}
360 }; 360 };
361 361
362 SINGLE_AND_MULTI_THREAD_TEST_F( 362 SINGLE_AND_MULTI_THREAD_TEST_F(
363 LayerTreeHostAnimationTestAnimationFinishedEvents) 363 LayerTreeHostAnimationTestAnimationFinishedEvents)
364 364
365 // Ensures that when opacity is being animated, this value does not cause the 365 // Ensures that when opacity is being animated, this value does not cause the
366 // subtree to be skipped. 366 // subtree to be skipped.
367 class LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity : 367 class LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity
368 public LayerTreeHostAnimationTest { 368 : public LayerTreeHostAnimationTest {
369 public: 369 public:
370 LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity() 370 LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity()
371 : update_check_layer_(FakeContentLayer::Create(&client_)) { 371 : update_check_layer_(FakeContentLayer::Create(&client_)) {
372 } 372 }
373 373
374 virtual void SetupTree() OVERRIDE { 374 virtual void SetupTree() OVERRIDE {
375 update_check_layer_->SetOpacity(0.f); 375 update_check_layer_->SetOpacity(0.f);
376 layer_tree_host()->SetRootLayer(update_check_layer_); 376 layer_tree_host()->SetRootLayer(update_check_layer_);
377 LayerTreeHostAnimationTest::SetupTree(); 377 LayerTreeHostAnimationTest::SetupTree();
378 } 378 }
379 379
380 virtual void BeginTest() OVERRIDE { 380 virtual void BeginTest() OVERRIDE {
381 PostAddAnimationToMainThread(update_check_layer_.get()); 381 PostAddAnimationToMainThread(update_check_layer_.get());
382 } 382 }
383 383
384 virtual void CommitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE { 384 virtual void CommitCompleteOnThread(LayerTreeHostImpl* tree_impl) OVERRIDE {
385 EndTest(); 385 EndTest();
386 } 386 }
387 387
388 virtual void AfterTest() OVERRIDE { 388 virtual void AfterTest() OVERRIDE {
389 // Update() should have been called once, proving that the layer was not 389 // Update() should have been called once, proving that the layer was not
390 // skipped. 390 // skipped.
391 EXPECT_EQ(1, update_check_layer_->update_count()); 391 EXPECT_EQ(1, update_check_layer_->update_count());
392 392
393 // clear update_check_layer_ so LayerTreeHost dies. 393 // clear update_check_layer_ so LayerTreeHost dies.
394 update_check_layer_ = NULL; 394 update_check_layer_ = NULL;
395 } 395 }
396 396
397 private: 397 private:
398 FakeContentLayerClient client_; 398 FakeContentLayerClient client_;
399 scoped_refptr<FakeContentLayer> update_check_layer_; 399 scoped_refptr<FakeContentLayer> update_check_layer_;
400 }; 400 };
401 401
402 MULTI_THREAD_TEST_F( 402 MULTI_THREAD_TEST_F(
403 LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity) 403 LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity)
404 404
405 // Layers added to tree with existing active animations should have the 405 // Layers added to tree with existing active animations should have the
406 // animation correctly recognized. 406 // animation correctly recognized.
407 class LayerTreeHostAnimationTestLayerAddedWithAnimation : 407 class LayerTreeHostAnimationTestLayerAddedWithAnimation
408 public LayerTreeHostAnimationTest { 408 : public LayerTreeHostAnimationTest {
409 public: 409 public:
410 LayerTreeHostAnimationTestLayerAddedWithAnimation() {} 410 LayerTreeHostAnimationTestLayerAddedWithAnimation() {}
411 411
412 virtual void BeginTest() OVERRIDE { 412 virtual void BeginTest() OVERRIDE {
413 PostSetNeedsCommitToMainThread(); 413 PostSetNeedsCommitToMainThread();
414 } 414 }
415 415
416 virtual void DidCommit() OVERRIDE { 416 virtual void DidCommit() OVERRIDE {
417 if (layer_tree_host()->commit_number() == 1) { 417 if (layer_tree_host()->commit_number() == 1) {
418 scoped_refptr<Layer> layer = Layer::Create(); 418 scoped_refptr<Layer> layer = Layer::Create();
(...skipping 16 matching lines...) Expand all
435 base::TimeTicks monotonic_time) OVERRIDE { 435 base::TimeTicks monotonic_time) OVERRIDE {
436 EndTest(); 436 EndTest();
437 } 437 }
438 438
439 virtual void AfterTest() OVERRIDE {} 439 virtual void AfterTest() OVERRIDE {}
440 }; 440 };
441 441
442 SINGLE_AND_MULTI_THREAD_TEST_F( 442 SINGLE_AND_MULTI_THREAD_TEST_F(
443 LayerTreeHostAnimationTestLayerAddedWithAnimation) 443 LayerTreeHostAnimationTestLayerAddedWithAnimation)
444 444
445 class LayerTreeHostAnimationTestCompositeAndReadbackAnimateCount : 445 class LayerTreeHostAnimationTestCompositeAndReadbackAnimateCount
446 public LayerTreeHostAnimationTest { 446 : public LayerTreeHostAnimationTest {
447 public: 447 public:
448 LayerTreeHostAnimationTestCompositeAndReadbackAnimateCount() 448 LayerTreeHostAnimationTestCompositeAndReadbackAnimateCount()
449 : animated_commit_(-1) { 449 : animated_commit_(-1) {
450 } 450 }
451 451
452 virtual void Animate(base::TimeTicks) OVERRIDE { 452 virtual void Animate(base::TimeTicks) OVERRIDE {
453 // We shouldn't animate on the CompositeAndReadback-forced commit, but we 453 // We shouldn't animate on the CompositeAndReadback-forced commit, but we
454 // should for the SetNeedsCommit-triggered commit. 454 // should for the SetNeedsCommit-triggered commit.
455 animated_commit_ = layer_tree_host()->commit_number(); 455 animated_commit_ = layer_tree_host()->commit_number();
456 EXPECT_NE(2, animated_commit_); 456 EXPECT_NE(2, animated_commit_);
(...skipping 28 matching lines...) Expand all
485 virtual void AfterTest() OVERRIDE { 485 virtual void AfterTest() OVERRIDE {
486 EXPECT_EQ(3, animated_commit_); 486 EXPECT_EQ(3, animated_commit_);
487 } 487 }
488 488
489 private: 489 private:
490 int animated_commit_; 490 int animated_commit_;
491 }; 491 };
492 492
493 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestCompositeAndReadbackAnimateCount) 493 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestCompositeAndReadbackAnimateCount)
494 494
495 class LayerTreeHostAnimationTestContinuousAnimate : 495 class LayerTreeHostAnimationTestContinuousAnimate
496 public LayerTreeHostAnimationTest { 496 : public LayerTreeHostAnimationTest {
497 public: 497 public:
498 LayerTreeHostAnimationTestContinuousAnimate() 498 LayerTreeHostAnimationTestContinuousAnimate()
499 : num_commit_complete_(0), 499 : num_commit_complete_(0),
500 num_draw_layers_(0) { 500 num_draw_layers_(0) {
501 } 501 }
502 502
503 virtual void BeginTest() OVERRIDE { 503 virtual void BeginTest() OVERRIDE {
504 PostSetNeedsCommitToMainThread(); 504 PostSetNeedsCommitToMainThread();
505 } 505 }
506 506
507 virtual void Animate(base::TimeTicks) OVERRIDE { 507 virtual void Animate(base::TimeTicks) OVERRIDE {
508 if (num_draw_layers_ == 2) 508 if (num_draw_layers_ == 2)
509 return; 509 return;
510 layer_tree_host()->SetNeedsAnimate(); 510 layer_tree_host()->SetNeedsAnimate();
511 } 511 }
512 512
513 virtual void Layout() OVERRIDE { 513 virtual void Layout() OVERRIDE {
514 layer_tree_host()->root_layer()->SetNeedsDisplay(); 514 layer_tree_host()->root_layer()->SetNeedsDisplay();
515 } 515 }
516 516
517 virtual void CommitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE { 517 virtual void CommitCompleteOnThread(LayerTreeHostImpl* tree_impl) OVERRIDE {
518 if (num_draw_layers_ == 1) 518 if (num_draw_layers_ == 1)
519 num_commit_complete_++; 519 num_commit_complete_++;
520 } 520 }
521 521
522 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 522 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
523 num_draw_layers_++; 523 num_draw_layers_++;
524 if (num_draw_layers_ == 2) 524 if (num_draw_layers_ == 2)
525 EndTest(); 525 EndTest();
526 } 526 }
527 527
528 virtual void AfterTest() OVERRIDE { 528 virtual void AfterTest() OVERRIDE {
529 // Check that we didn't commit twice between first and second draw. 529 // Check that we didn't commit twice between first and second draw.
530 EXPECT_EQ(1, num_commit_complete_); 530 EXPECT_EQ(1, num_commit_complete_);
531 } 531 }
532 532
533 private: 533 private:
534 int num_commit_complete_; 534 int num_commit_complete_;
535 int num_draw_layers_; 535 int num_draw_layers_;
536 }; 536 };
537 537
538 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate) 538 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate)
539 539
540 } // namespace 540 } // namespace
541 } // namespace cc 541 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_delegated.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698