OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_ | 5 #ifndef CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_ |
6 #define CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_ | 6 #define CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_ |
7 | 7 |
8 #include <unordered_map> | 8 #include <unordered_map> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 static scoped_ptr<TestLayer> Create(); | 22 static scoped_ptr<TestLayer> Create(); |
23 | 23 |
24 void ClearMutatedProperties(); | 24 void ClearMutatedProperties(); |
25 | 25 |
26 int transform_x() const { return transform_x_; } | 26 int transform_x() const { return transform_x_; } |
27 int transform_y() const { return transform_y_; } | 27 int transform_y() const { return transform_y_; } |
28 | 28 |
29 void set_transform(int transform_x, int transform_y) { | 29 void set_transform(int transform_x, int transform_y) { |
30 transform_x_ = transform_x; | 30 transform_x_ = transform_x; |
31 transform_y_ = transform_y; | 31 transform_y_ = transform_y; |
32 mutated_properties_[Animation::TRANSFORM] = true; | 32 mutated_properties_[TargetProperty::TRANSFORM] = true; |
33 } | 33 } |
34 | 34 |
35 float opacity() const { return opacity_; } | 35 float opacity() const { return opacity_; } |
36 void set_opacity(float opacity) { | 36 void set_opacity(float opacity) { |
37 opacity_ = opacity; | 37 opacity_ = opacity; |
38 mutated_properties_[Animation::OPACITY] = true; | 38 mutated_properties_[TargetProperty::OPACITY] = true; |
39 } | 39 } |
40 | 40 |
41 float brightness() const { return brightness_; } | 41 float brightness() const { return brightness_; } |
42 void set_brightness(float brightness) { | 42 void set_brightness(float brightness) { |
43 brightness_ = brightness; | 43 brightness_ = brightness; |
44 mutated_properties_[Animation::FILTER] = true; | 44 mutated_properties_[TargetProperty::FILTER] = true; |
45 } | 45 } |
46 | 46 |
47 gfx::ScrollOffset scroll_offset() const { return scroll_offset_; } | 47 gfx::ScrollOffset scroll_offset() const { return scroll_offset_; } |
48 void set_scroll_offset(const gfx::ScrollOffset& scroll_offset) { | 48 void set_scroll_offset(const gfx::ScrollOffset& scroll_offset) { |
49 scroll_offset_ = scroll_offset; | 49 scroll_offset_ = scroll_offset; |
50 mutated_properties_[Animation::SCROLL_OFFSET] = true; | 50 mutated_properties_[TargetProperty::SCROLL_OFFSET] = true; |
51 } | 51 } |
52 | 52 |
53 bool is_property_mutated(Animation::TargetProperty property) const { | 53 bool is_property_mutated(TargetProperty::Type property) const { |
54 return mutated_properties_[property]; | 54 return mutated_properties_[property]; |
55 } | 55 } |
56 | 56 |
57 private: | 57 private: |
58 TestLayer(); | 58 TestLayer(); |
59 | 59 |
60 int transform_x_; | 60 int transform_x_; |
61 int transform_y_; | 61 int transform_y_; |
62 | 62 |
63 float opacity_; | 63 float opacity_; |
64 float brightness_; | 64 float brightness_; |
65 gfx::ScrollOffset scroll_offset_; | 65 gfx::ScrollOffset scroll_offset_; |
66 | 66 |
67 bool mutated_properties_[Animation::LAST_TARGET_PROPERTY + 1]; | 67 bool mutated_properties_[TargetProperty::LAST_TARGET_PROPERTY + 1]; |
68 }; | 68 }; |
69 | 69 |
70 class TestHostClient : public MutatorHostClient { | 70 class TestHostClient : public MutatorHostClient { |
71 public: | 71 public: |
72 explicit TestHostClient(ThreadInstance thread_instance); | 72 explicit TestHostClient(ThreadInstance thread_instance); |
73 ~TestHostClient(); | 73 ~TestHostClient(); |
74 | 74 |
75 void ClearMutatedProperties(); | 75 void ClearMutatedProperties(); |
76 | 76 |
77 bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const override; | 77 bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const override; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 void RegisterLayer(int layer_id, LayerTreeType tree_type); | 110 void RegisterLayer(int layer_id, LayerTreeType tree_type); |
111 void UnregisterLayer(int layer_id, LayerTreeType tree_type); | 111 void UnregisterLayer(int layer_id, LayerTreeType tree_type); |
112 | 112 |
113 AnimationHost* host() { | 113 AnimationHost* host() { |
114 DCHECK(host_); | 114 DCHECK(host_); |
115 return host_.get(); | 115 return host_.get(); |
116 } | 116 } |
117 | 117 |
118 bool IsPropertyMutated(int layer_id, | 118 bool IsPropertyMutated(int layer_id, |
119 LayerTreeType tree_type, | 119 LayerTreeType tree_type, |
120 Animation::TargetProperty property) const; | 120 TargetProperty::Type property) const; |
121 | 121 |
122 void ExpectFilterPropertyMutated(int layer_id, | 122 void ExpectFilterPropertyMutated(int layer_id, |
123 LayerTreeType tree_type, | 123 LayerTreeType tree_type, |
124 float brightness) const; | 124 float brightness) const; |
125 void ExpectOpacityPropertyMutated(int layer_id, | 125 void ExpectOpacityPropertyMutated(int layer_id, |
126 LayerTreeType tree_type, | 126 LayerTreeType tree_type, |
127 float opacity) const; | 127 float opacity) const; |
128 void ExpectTransformPropertyMutated(int layer_id, | 128 void ExpectTransformPropertyMutated(int layer_id, |
129 LayerTreeType tree_type, | 129 LayerTreeType tree_type, |
130 int transform_x, | 130 int transform_x, |
131 int transform_y) const; | 131 int transform_y) const; |
132 | 132 |
133 TestLayer* FindTestLayer(int layer_id, LayerTreeType tree_type) const; | 133 TestLayer* FindTestLayer(int layer_id, LayerTreeType tree_type) const; |
134 | 134 |
135 private: | 135 private: |
136 scoped_ptr<AnimationHost> host_; | 136 scoped_ptr<AnimationHost> host_; |
137 | 137 |
138 using LayerIdToTestLayer = std::unordered_map<int, scoped_ptr<TestLayer>>; | 138 using LayerIdToTestLayer = std::unordered_map<int, scoped_ptr<TestLayer>>; |
139 LayerIdToTestLayer layers_in_active_tree_; | 139 LayerIdToTestLayer layers_in_active_tree_; |
140 LayerIdToTestLayer layers_in_pending_tree_; | 140 LayerIdToTestLayer layers_in_pending_tree_; |
141 | 141 |
142 bool mutators_need_commit_; | 142 bool mutators_need_commit_; |
143 }; | 143 }; |
144 | 144 |
145 class TestAnimationDelegate : public AnimationDelegate { | 145 class TestAnimationDelegate : public AnimationDelegate { |
146 public: | 146 public: |
147 TestAnimationDelegate(); | 147 TestAnimationDelegate(); |
148 | 148 |
149 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 149 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
150 Animation::TargetProperty target_property, | 150 TargetProperty::Type target_property, |
151 int group) override; | 151 int group) override; |
152 void NotifyAnimationFinished(base::TimeTicks monotonic_time, | 152 void NotifyAnimationFinished(base::TimeTicks monotonic_time, |
153 Animation::TargetProperty target_property, | 153 TargetProperty::Type target_property, |
154 int group) override; | 154 int group) override; |
155 void NotifyAnimationAborted(base::TimeTicks monotonic_time, | 155 void NotifyAnimationAborted(base::TimeTicks monotonic_time, |
156 Animation::TargetProperty target_property, | 156 TargetProperty::Type target_property, |
157 int group) override {} | 157 int group) override {} |
158 bool started_; | 158 bool started_; |
159 bool finished_; | 159 bool finished_; |
160 }; | 160 }; |
161 | 161 |
162 class AnimationTimelinesTest : public testing::Test { | 162 class AnimationTimelinesTest : public testing::Test { |
163 public: | 163 public: |
164 AnimationTimelinesTest(); | 164 AnimationTimelinesTest(); |
165 ~AnimationTimelinesTest() override; | 165 ~AnimationTimelinesTest() override; |
166 | 166 |
(...skipping 28 matching lines...) Expand all Loading... |
195 scoped_refptr<AnimationTimeline> timeline_; | 195 scoped_refptr<AnimationTimeline> timeline_; |
196 scoped_refptr<AnimationPlayer> player_; | 196 scoped_refptr<AnimationPlayer> player_; |
197 | 197 |
198 scoped_refptr<AnimationTimeline> timeline_impl_; | 198 scoped_refptr<AnimationTimeline> timeline_impl_; |
199 scoped_refptr<AnimationPlayer> player_impl_; | 199 scoped_refptr<AnimationPlayer> player_impl_; |
200 }; | 200 }; |
201 | 201 |
202 } // namespace cc | 202 } // namespace cc |
203 | 203 |
204 #endif // CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_ | 204 #endif // CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_ |
OLD | NEW |