OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "core/animation/AnimationNode.h" | 32 #include "core/animation/AnimationNode.h" |
33 | 33 |
34 #include <gtest/gtest.h> | 34 #include <gtest/gtest.h> |
35 | 35 |
36 using namespace blink; | 36 using namespace blink; |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 class TestAnimationNodeEventDelegate : public AnimationNode::EventDelegate { | 40 class TestAnimationNodeEventDelegate : public AnimationNode::EventDelegate { |
41 public: | 41 public: |
42 virtual void onEventCondition(const AnimationNode* animationNode) OVERRIDE | 42 virtual void onEventCondition(const AnimationNode* animationNode) override |
43 { | 43 { |
44 m_eventTriggered = true; | 44 m_eventTriggered = true; |
45 | 45 |
46 } | 46 } |
47 void reset() | 47 void reset() |
48 { | 48 { |
49 m_eventTriggered = false; | 49 m_eventTriggered = false; |
50 } | 50 } |
51 bool eventTriggered() { return m_eventTriggered; } | 51 bool eventTriggered() { return m_eventTriggered; } |
52 | 52 |
(...skipping 12 matching lines...) Expand all Loading... |
65 { | 65 { |
66 updateInheritedTime(time, TimingUpdateForAnimationFrame); | 66 updateInheritedTime(time, TimingUpdateForAnimationFrame); |
67 } | 67 } |
68 | 68 |
69 void updateInheritedTime(double time, TimingUpdateReason reason) | 69 void updateInheritedTime(double time, TimingUpdateReason reason) |
70 { | 70 { |
71 m_eventDelegate->reset(); | 71 m_eventDelegate->reset(); |
72 AnimationNode::updateInheritedTime(time, reason); | 72 AnimationNode::updateInheritedTime(time, reason); |
73 } | 73 } |
74 | 74 |
75 virtual void updateChildrenAndEffects() const OVERRIDE { } | 75 virtual void updateChildrenAndEffects() const override { } |
76 void willDetach() { } | 76 void willDetach() { } |
77 TestAnimationNodeEventDelegate* eventDelegate() { return m_eventDelegate.get
(); } | 77 TestAnimationNodeEventDelegate* eventDelegate() { return m_eventDelegate.get
(); } |
78 virtual double calculateTimeToEffectChange(bool forwards, double localTime,
double timeToNextIteration) const OVERRIDE | 78 virtual double calculateTimeToEffectChange(bool forwards, double localTime,
double timeToNextIteration) const override |
79 { | 79 { |
80 m_localTime = localTime; | 80 m_localTime = localTime; |
81 m_timeToNextIteration = timeToNextIteration; | 81 m_timeToNextIteration = timeToNextIteration; |
82 return -1; | 82 return -1; |
83 } | 83 } |
84 double takeLocalTime() | 84 double takeLocalTime() |
85 { | 85 { |
86 const double result = m_localTime; | 86 const double result = m_localTime; |
87 m_localTime = nullValue(); | 87 m_localTime = nullValue(); |
88 return result; | 88 return result; |
89 } | 89 } |
90 | 90 |
91 double takeTimeToNextIteration() | 91 double takeTimeToNextIteration() |
92 { | 92 { |
93 const double result = m_timeToNextIteration; | 93 const double result = m_timeToNextIteration; |
94 m_timeToNextIteration = nullValue(); | 94 m_timeToNextIteration = nullValue(); |
95 return result; | 95 return result; |
96 } | 96 } |
97 | 97 |
98 virtual void trace(Visitor* visitor) OVERRIDE | 98 virtual void trace(Visitor* visitor) override |
99 { | 99 { |
100 visitor->trace(m_eventDelegate); | 100 visitor->trace(m_eventDelegate); |
101 AnimationNode::trace(visitor); | 101 AnimationNode::trace(visitor); |
102 } | 102 } |
103 | 103 |
104 private: | 104 private: |
105 TestAnimationNode(const Timing& specified, TestAnimationNodeEventDelegate* e
ventDelegate) | 105 TestAnimationNode(const Timing& specified, TestAnimationNodeEventDelegate* e
ventDelegate) |
106 : AnimationNode(specified, adoptPtrWillBeNoop(eventDelegate)) | 106 : AnimationNode(specified, adoptPtrWillBeNoop(eventDelegate)) |
107 , m_eventDelegate(eventDelegate) | 107 , m_eventDelegate(eventDelegate) |
108 { | 108 { |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 EXPECT_TRUE(std::isinf(animationNode->takeTimeToNextIteration())); | 772 EXPECT_TRUE(std::isinf(animationNode->takeTimeToNextIteration())); |
773 | 773 |
774 // Item has finished. | 774 // Item has finished. |
775 animationNode->updateInheritedTime(3.5); | 775 animationNode->updateInheritedTime(3.5); |
776 EXPECT_EQ(AnimationNode::PhaseAfter, animationNode->phase()); | 776 EXPECT_EQ(AnimationNode::PhaseAfter, animationNode->phase()); |
777 EXPECT_EQ(3.5, animationNode->takeLocalTime()); | 777 EXPECT_EQ(3.5, animationNode->takeLocalTime()); |
778 EXPECT_TRUE(std::isinf(animationNode->takeTimeToNextIteration())); | 778 EXPECT_TRUE(std::isinf(animationNode->takeTimeToNextIteration())); |
779 } | 779 } |
780 | 780 |
781 } | 781 } |
OLD | NEW |