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

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

Issue 579863004: CC: Add fill mode to compositor animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile Created 6 years, 3 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/animation/animation.cc ('k') | cc/animation/layer_animation_controller.cc » ('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/animation/animation.h" 5 #include "cc/animation/animation.h"
6 6
7 #include "cc/test/animation_test_common.h" 7 #include "cc/test/animation_test_common.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 scoped_ptr<Animation> anim(CreateAnimation(3, 1, -1)); 659 scoped_ptr<Animation> anim(CreateAnimation(3, 1, -1));
660 anim->set_direction(Animation::Alternate); 660 anim->set_direction(Animation::Alternate);
661 anim->set_iteration_start(1); 661 anim->set_iteration_start(1);
662 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 662 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0)));
663 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 663 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0)));
664 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 664 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0)));
665 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.0))); 665 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.0)));
666 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.5))); 666 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.5)));
667 } 667 }
668 668
669 TEST(AnimationTest, InEffectFillMode) {
670 scoped_ptr<Animation> anim(CreateAnimation(1));
671 anim->set_fill_mode(Animation::FillModeNone);
672 EXPECT_FALSE(anim->InEffect(TicksFromSecondsF(-1.0)));
673 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(0.0)));
674 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(1.0)));
675
676 anim->set_fill_mode(Animation::FillModeForwards);
677 EXPECT_FALSE(anim->InEffect(TicksFromSecondsF(-1.0)));
678 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(0.0)));
679 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(1.0)));
680
681 anim->set_fill_mode(Animation::FillModeBackwards);
682 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(-1.0)));
683 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(0.0)));
684 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(1.0)));
685
686 anim->set_fill_mode(Animation::FillModeBoth);
687 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(-1.0)));
688 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(0.0)));
689 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(1.0)));
690 }
691
692 TEST(AnimationTest, InEffectFillModePlayback) {
693 scoped_ptr<Animation> anim(CreateAnimation(1, 1, -1));
694 anim->set_fill_mode(Animation::FillModeNone);
695 EXPECT_FALSE(anim->InEffect(TicksFromSecondsF(-1.0)));
696 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(0.0)));
697 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(1.0)));
698
699 anim->set_fill_mode(Animation::FillModeForwards);
700 EXPECT_FALSE(anim->InEffect(TicksFromSecondsF(-1.0)));
701 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(0.0)));
702 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(1.0)));
703
704 anim->set_fill_mode(Animation::FillModeBackwards);
705 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(-1.0)));
706 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(0.0)));
707 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(1.0)));
708
709 anim->set_fill_mode(Animation::FillModeBoth);
710 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(-1.0)));
711 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(0.0)));
712 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(1.0)));
713 }
714
669 } // namespace 715 } // namespace
670 } // namespace cc 716 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/animation.cc ('k') | cc/animation/layer_animation_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698