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

Side by Side Diff: cc/test/animation_timelines_test_common.h

Issue 1698813002: CC Animation: Expose TargetProperty enum to be aliased in Blink Platform. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use custom hash in unordered_set. Created 4 years, 10 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 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
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_[ToIndex(AnimationTargetProperty::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_[ToIndex(AnimationTargetProperty::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_[ToIndex(AnimationTargetProperty::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_[ToIndex(AnimationTargetProperty::SCROLL_OFFSET)] = true;
51 } 51 }
52 52
53 bool is_property_mutated(Animation::TargetProperty property) const { 53 bool is_property_mutated(AnimationTargetProperty property) const {
54 return mutated_properties_[property]; 54 return mutated_properties_[ToIndex(property)];
55 } 55 }
56 56
57 private: 57 private:
58 TestLayer(); 58 TestLayer();
59 59
60 static int ToIndex(AnimationTargetProperty property) {
61 return static_cast<int>(property);
62 }
63
60 int transform_x_; 64 int transform_x_;
61 int transform_y_; 65 int transform_y_;
62 66
63 float opacity_; 67 float opacity_;
64 float brightness_; 68 float brightness_;
65 gfx::ScrollOffset scroll_offset_; 69 gfx::ScrollOffset scroll_offset_;
66 70
67 bool mutated_properties_[Animation::LAST_TARGET_PROPERTY + 1]; 71 static const int kLastTargetProperty =
72 static_cast<int>(AnimationTargetProperty::LAST_TARGET_PROPERTY);
73 bool mutated_properties_[kLastTargetProperty + 1];
68 }; 74 };
69 75
70 class TestHostClient : public MutatorHostClient { 76 class TestHostClient : public MutatorHostClient {
71 public: 77 public:
72 explicit TestHostClient(ThreadInstance thread_instance); 78 explicit TestHostClient(ThreadInstance thread_instance);
73 ~TestHostClient(); 79 ~TestHostClient();
74 80
75 void ClearMutatedProperties(); 81 void ClearMutatedProperties();
76 82
77 bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const override; 83 bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const override;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 void RegisterLayer(int layer_id, LayerTreeType tree_type); 116 void RegisterLayer(int layer_id, LayerTreeType tree_type);
111 void UnregisterLayer(int layer_id, LayerTreeType tree_type); 117 void UnregisterLayer(int layer_id, LayerTreeType tree_type);
112 118
113 AnimationHost* host() { 119 AnimationHost* host() {
114 DCHECK(host_); 120 DCHECK(host_);
115 return host_.get(); 121 return host_.get();
116 } 122 }
117 123
118 bool IsPropertyMutated(int layer_id, 124 bool IsPropertyMutated(int layer_id,
119 LayerTreeType tree_type, 125 LayerTreeType tree_type,
120 Animation::TargetProperty property) const; 126 AnimationTargetProperty property) const;
121 127
122 void ExpectFilterPropertyMutated(int layer_id, 128 void ExpectFilterPropertyMutated(int layer_id,
123 LayerTreeType tree_type, 129 LayerTreeType tree_type,
124 float brightness) const; 130 float brightness) const;
125 void ExpectOpacityPropertyMutated(int layer_id, 131 void ExpectOpacityPropertyMutated(int layer_id,
126 LayerTreeType tree_type, 132 LayerTreeType tree_type,
127 float opacity) const; 133 float opacity) const;
128 void ExpectTransformPropertyMutated(int layer_id, 134 void ExpectTransformPropertyMutated(int layer_id,
129 LayerTreeType tree_type, 135 LayerTreeType tree_type,
130 int transform_x, 136 int transform_x,
131 int transform_y) const; 137 int transform_y) const;
132 138
133 TestLayer* FindTestLayer(int layer_id, LayerTreeType tree_type) const; 139 TestLayer* FindTestLayer(int layer_id, LayerTreeType tree_type) const;
134 140
135 private: 141 private:
136 scoped_ptr<AnimationHost> host_; 142 scoped_ptr<AnimationHost> host_;
137 143
138 using LayerIdToTestLayer = std::unordered_map<int, scoped_ptr<TestLayer>>; 144 using LayerIdToTestLayer = std::unordered_map<int, scoped_ptr<TestLayer>>;
139 LayerIdToTestLayer layers_in_active_tree_; 145 LayerIdToTestLayer layers_in_active_tree_;
140 LayerIdToTestLayer layers_in_pending_tree_; 146 LayerIdToTestLayer layers_in_pending_tree_;
141 147
142 bool mutators_need_commit_; 148 bool mutators_need_commit_;
143 }; 149 };
144 150
145 class TestAnimationDelegate : public AnimationDelegate { 151 class TestAnimationDelegate : public AnimationDelegate {
146 public: 152 public:
147 TestAnimationDelegate(); 153 TestAnimationDelegate();
148 154
149 void NotifyAnimationStarted(base::TimeTicks monotonic_time, 155 void NotifyAnimationStarted(base::TimeTicks monotonic_time,
150 Animation::TargetProperty target_property, 156 AnimationTargetProperty target_property,
151 int group) override; 157 int group) override;
152 void NotifyAnimationFinished(base::TimeTicks monotonic_time, 158 void NotifyAnimationFinished(base::TimeTicks monotonic_time,
153 Animation::TargetProperty target_property, 159 AnimationTargetProperty target_property,
154 int group) override; 160 int group) override;
155 void NotifyAnimationAborted(base::TimeTicks monotonic_time, 161 void NotifyAnimationAborted(base::TimeTicks monotonic_time,
156 Animation::TargetProperty target_property, 162 AnimationTargetProperty target_property,
157 int group) override {} 163 int group) override {}
158 bool started_; 164 bool started_;
159 bool finished_; 165 bool finished_;
160 }; 166 };
161 167
162 class AnimationTimelinesTest : public testing::Test { 168 class AnimationTimelinesTest : public testing::Test {
163 public: 169 public:
164 AnimationTimelinesTest(); 170 AnimationTimelinesTest();
165 ~AnimationTimelinesTest() override; 171 ~AnimationTimelinesTest() override;
166 172
(...skipping 28 matching lines...) Expand all
195 scoped_refptr<AnimationTimeline> timeline_; 201 scoped_refptr<AnimationTimeline> timeline_;
196 scoped_refptr<AnimationPlayer> player_; 202 scoped_refptr<AnimationPlayer> player_;
197 203
198 scoped_refptr<AnimationTimeline> timeline_impl_; 204 scoped_refptr<AnimationTimeline> timeline_impl_;
199 scoped_refptr<AnimationPlayer> player_impl_; 205 scoped_refptr<AnimationPlayer> player_impl_;
200 }; 206 };
201 207
202 } // namespace cc 208 } // namespace cc
203 209
204 #endif // CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_ 210 #endif // CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698