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

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

Issue 1700653002: CC Animation: Expose TargetProperty enum to be aliased in Blink Platform. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch 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 #include "cc/test/animation_timelines_test_common.h" 5 #include "cc/test/animation_timelines_test_common.h"
6 6
7 #include "cc/animation/animation_events.h" 7 #include "cc/animation/animation_events.h"
8 #include "cc/animation/animation_id_provider.h" 8 #include "cc/animation/animation_id_provider.h"
9 #include "cc/animation/animation_player.h" 9 #include "cc/animation/animation_player.h"
10 #include "cc/animation/animation_registrar.h" 10 #include "cc/animation/animation_registrar.h"
(...skipping 13 matching lines...) Expand all
24 ClearMutatedProperties(); 24 ClearMutatedProperties();
25 } 25 }
26 26
27 void TestLayer::ClearMutatedProperties() { 27 void TestLayer::ClearMutatedProperties() {
28 transform_x_ = 0; 28 transform_x_ = 0;
29 transform_y_ = 0; 29 transform_y_ = 0;
30 30
31 opacity_ = 0; 31 opacity_ = 0;
32 brightness_ = 0; 32 brightness_ = 0;
33 33
34 for (int i = 0; i <= Animation::LAST_TARGET_PROPERTY; ++i) 34 for (int i = 0; i <= AnimationTargetProperty::LAST_TARGET_PROPERTY; ++i)
35 mutated_properties_[i] = false; 35 mutated_properties_[i] = false;
36 } 36 }
37 37
38 TestHostClient::TestHostClient(ThreadInstance thread_instance) 38 TestHostClient::TestHostClient(ThreadInstance thread_instance)
39 : host_(AnimationHost::Create(thread_instance)), 39 : host_(AnimationHost::Create(thread_instance)),
40 mutators_need_commit_(false) { 40 mutators_need_commit_(false) {
41 host_->SetMutatorHostClient(this); 41 host_->SetMutatorHostClient(this);
42 host_->SetSupportsScrollAnimations(true); 42 host_->SetSupportsScrollAnimations(true);
43 } 43 }
44 44
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 ? layers_in_active_tree_ 125 ? layers_in_active_tree_
126 : layers_in_pending_tree_; 126 : layers_in_pending_tree_;
127 auto kv = layers_in_tree.find(layer_id); 127 auto kv = layers_in_tree.find(layer_id);
128 DCHECK(kv != layers_in_tree.end()); 128 DCHECK(kv != layers_in_tree.end());
129 layers_in_tree.erase(kv); 129 layers_in_tree.erase(kv);
130 } 130 }
131 131
132 bool TestHostClient::IsPropertyMutated( 132 bool TestHostClient::IsPropertyMutated(
133 int layer_id, 133 int layer_id,
134 LayerTreeType tree_type, 134 LayerTreeType tree_type,
135 Animation::TargetProperty property) const { 135 AnimationTargetProperty::Enum property) const {
136 TestLayer* layer = FindTestLayer(layer_id, tree_type); 136 TestLayer* layer = FindTestLayer(layer_id, tree_type);
137 return layer->is_property_mutated(property); 137 return layer->is_property_mutated(property);
138 } 138 }
139 139
140 void TestHostClient::ExpectFilterPropertyMutated(int layer_id, 140 void TestHostClient::ExpectFilterPropertyMutated(int layer_id,
141 LayerTreeType tree_type, 141 LayerTreeType tree_type,
142 float brightness) const { 142 float brightness) const {
143 TestLayer* layer = FindTestLayer(layer_id, tree_type); 143 TestLayer* layer = FindTestLayer(layer_id, tree_type);
144 EXPECT_TRUE(layer->is_property_mutated(Animation::OPACITY)); 144 EXPECT_TRUE(layer->is_property_mutated(AnimationTargetProperty::OPACITY));
145 EXPECT_EQ(brightness, layer->brightness()); 145 EXPECT_EQ(brightness, layer->brightness());
146 } 146 }
147 147
148 void TestHostClient::ExpectOpacityPropertyMutated(int layer_id, 148 void TestHostClient::ExpectOpacityPropertyMutated(int layer_id,
149 LayerTreeType tree_type, 149 LayerTreeType tree_type,
150 float opacity) const { 150 float opacity) const {
151 TestLayer* layer = FindTestLayer(layer_id, tree_type); 151 TestLayer* layer = FindTestLayer(layer_id, tree_type);
152 EXPECT_TRUE(layer->is_property_mutated(Animation::OPACITY)); 152 EXPECT_TRUE(layer->is_property_mutated(AnimationTargetProperty::OPACITY));
153 EXPECT_EQ(opacity, layer->opacity()); 153 EXPECT_EQ(opacity, layer->opacity());
154 } 154 }
155 155
156 void TestHostClient::ExpectTransformPropertyMutated(int layer_id, 156 void TestHostClient::ExpectTransformPropertyMutated(int layer_id,
157 LayerTreeType tree_type, 157 LayerTreeType tree_type,
158 int transform_x, 158 int transform_x,
159 int transform_y) const { 159 int transform_y) const {
160 TestLayer* layer = FindTestLayer(layer_id, tree_type); 160 TestLayer* layer = FindTestLayer(layer_id, tree_type);
161 EXPECT_TRUE(layer->is_property_mutated(Animation::OPACITY)); 161 EXPECT_TRUE(layer->is_property_mutated(AnimationTargetProperty::OPACITY));
162 EXPECT_EQ(transform_x, layer->transform_x()); 162 EXPECT_EQ(transform_x, layer->transform_x());
163 EXPECT_EQ(transform_y, layer->transform_y()); 163 EXPECT_EQ(transform_y, layer->transform_y());
164 } 164 }
165 165
166 TestLayer* TestHostClient::FindTestLayer(int layer_id, 166 TestLayer* TestHostClient::FindTestLayer(int layer_id,
167 LayerTreeType tree_type) const { 167 LayerTreeType tree_type) const {
168 const LayerIdToTestLayer& layers_in_tree = tree_type == LayerTreeType::ACTIVE 168 const LayerIdToTestLayer& layers_in_tree = tree_type == LayerTreeType::ACTIVE
169 ? layers_in_active_tree_ 169 ? layers_in_active_tree_
170 : layers_in_pending_tree_; 170 : layers_in_pending_tree_;
171 auto kv = layers_in_tree.find(layer_id); 171 auto kv = layers_in_tree.find(layer_id);
172 DCHECK(kv != layers_in_tree.end()); 172 DCHECK(kv != layers_in_tree.end());
173 DCHECK(kv->second); 173 DCHECK(kv->second);
174 return kv->second.get(); 174 return kv->second.get();
175 } 175 }
176 176
177 TestAnimationDelegate::TestAnimationDelegate() 177 TestAnimationDelegate::TestAnimationDelegate()
178 : started_(false), finished_(false) { 178 : started_(false), finished_(false) {
179 } 179 }
180 180
181 void TestAnimationDelegate::NotifyAnimationStarted( 181 void TestAnimationDelegate::NotifyAnimationStarted(
182 base::TimeTicks monotonic_time, 182 base::TimeTicks monotonic_time,
183 Animation::TargetProperty target_property, 183 AnimationTargetProperty::Enum target_property,
184 int group) { 184 int group) {
185 started_ = true; 185 started_ = true;
186 } 186 }
187 void TestAnimationDelegate::NotifyAnimationFinished( 187 void TestAnimationDelegate::NotifyAnimationFinished(
188 base::TimeTicks monotonic_time, 188 base::TimeTicks monotonic_time,
189 Animation::TargetProperty target_property, 189 AnimationTargetProperty::Enum target_property,
190 int group) { 190 int group) {
191 finished_ = true; 191 finished_ = true;
192 } 192 }
193 193
194 AnimationTimelinesTest::AnimationTimelinesTest() 194 AnimationTimelinesTest::AnimationTimelinesTest()
195 : client_(ThreadInstance::MAIN), 195 : client_(ThreadInstance::MAIN),
196 client_impl_(ThreadInstance::IMPL), 196 client_impl_(ThreadInstance::IMPL),
197 host_(nullptr), 197 host_(nullptr),
198 host_impl_(nullptr), 198 host_impl_(nullptr),
199 timeline_id_(AnimationIdProvider::NextTimelineId()), 199 timeline_id_(AnimationIdProvider::NextTimelineId()),
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 return element_animations ? element_animations->players_list().head()->value() 260 return element_animations ? element_animations->players_list().head()->value()
261 : nullptr; 261 : nullptr;
262 } 262 }
263 263
264 int AnimationTimelinesTest::NextTestLayerId() { 264 int AnimationTimelinesTest::NextTestLayerId() {
265 next_test_layer_id_++; 265 next_test_layer_id_++;
266 return next_test_layer_id_; 266 return next_test_layer_id_;
267 } 267 }
268 268
269 } // namespace cc 269 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698