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

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

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 #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 <= kLastTargetProperty; ++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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 host_->UnregisterLayer(layer_id, tree_type); 122 host_->UnregisterLayer(layer_id, tree_type);
123 123
124 LayerIdToTestLayer& layers_in_tree = tree_type == LayerTreeType::ACTIVE 124 LayerIdToTestLayer& layers_in_tree = tree_type == LayerTreeType::ACTIVE
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(int layer_id,
133 int layer_id, 133 LayerTreeType tree_type,
134 LayerTreeType tree_type, 134 AnimationTargetProperty property) const {
135 Animation::TargetProperty property) const {
136 TestLayer* layer = FindTestLayer(layer_id, tree_type); 135 TestLayer* layer = FindTestLayer(layer_id, tree_type);
137 return layer->is_property_mutated(property); 136 return layer->is_property_mutated(property);
138 } 137 }
139 138
140 void TestHostClient::ExpectFilterPropertyMutated(int layer_id, 139 void TestHostClient::ExpectFilterPropertyMutated(int layer_id,
141 LayerTreeType tree_type, 140 LayerTreeType tree_type,
142 float brightness) const { 141 float brightness) const {
143 TestLayer* layer = FindTestLayer(layer_id, tree_type); 142 TestLayer* layer = FindTestLayer(layer_id, tree_type);
144 EXPECT_TRUE(layer->is_property_mutated(Animation::OPACITY)); 143 EXPECT_TRUE(layer->is_property_mutated(AnimationTargetProperty::OPACITY));
145 EXPECT_EQ(brightness, layer->brightness()); 144 EXPECT_EQ(brightness, layer->brightness());
146 } 145 }
147 146
148 void TestHostClient::ExpectOpacityPropertyMutated(int layer_id, 147 void TestHostClient::ExpectOpacityPropertyMutated(int layer_id,
149 LayerTreeType tree_type, 148 LayerTreeType tree_type,
150 float opacity) const { 149 float opacity) const {
151 TestLayer* layer = FindTestLayer(layer_id, tree_type); 150 TestLayer* layer = FindTestLayer(layer_id, tree_type);
152 EXPECT_TRUE(layer->is_property_mutated(Animation::OPACITY)); 151 EXPECT_TRUE(layer->is_property_mutated(AnimationTargetProperty::OPACITY));
153 EXPECT_EQ(opacity, layer->opacity()); 152 EXPECT_EQ(opacity, layer->opacity());
154 } 153 }
155 154
156 void TestHostClient::ExpectTransformPropertyMutated(int layer_id, 155 void TestHostClient::ExpectTransformPropertyMutated(int layer_id,
157 LayerTreeType tree_type, 156 LayerTreeType tree_type,
158 int transform_x, 157 int transform_x,
159 int transform_y) const { 158 int transform_y) const {
160 TestLayer* layer = FindTestLayer(layer_id, tree_type); 159 TestLayer* layer = FindTestLayer(layer_id, tree_type);
161 EXPECT_TRUE(layer->is_property_mutated(Animation::OPACITY)); 160 EXPECT_TRUE(layer->is_property_mutated(AnimationTargetProperty::OPACITY));
162 EXPECT_EQ(transform_x, layer->transform_x()); 161 EXPECT_EQ(transform_x, layer->transform_x());
163 EXPECT_EQ(transform_y, layer->transform_y()); 162 EXPECT_EQ(transform_y, layer->transform_y());
164 } 163 }
165 164
166 TestLayer* TestHostClient::FindTestLayer(int layer_id, 165 TestLayer* TestHostClient::FindTestLayer(int layer_id,
167 LayerTreeType tree_type) const { 166 LayerTreeType tree_type) const {
168 const LayerIdToTestLayer& layers_in_tree = tree_type == LayerTreeType::ACTIVE 167 const LayerIdToTestLayer& layers_in_tree = tree_type == LayerTreeType::ACTIVE
169 ? layers_in_active_tree_ 168 ? layers_in_active_tree_
170 : layers_in_pending_tree_; 169 : layers_in_pending_tree_;
171 auto kv = layers_in_tree.find(layer_id); 170 auto kv = layers_in_tree.find(layer_id);
172 DCHECK(kv != layers_in_tree.end()); 171 DCHECK(kv != layers_in_tree.end());
173 DCHECK(kv->second); 172 DCHECK(kv->second);
174 return kv->second.get(); 173 return kv->second.get();
175 } 174 }
176 175
177 TestAnimationDelegate::TestAnimationDelegate() 176 TestAnimationDelegate::TestAnimationDelegate()
178 : started_(false), finished_(false) { 177 : started_(false), finished_(false) {
179 } 178 }
180 179
181 void TestAnimationDelegate::NotifyAnimationStarted( 180 void TestAnimationDelegate::NotifyAnimationStarted(
182 base::TimeTicks monotonic_time, 181 base::TimeTicks monotonic_time,
183 Animation::TargetProperty target_property, 182 AnimationTargetProperty target_property,
184 int group) { 183 int group) {
185 started_ = true; 184 started_ = true;
186 } 185 }
187 void TestAnimationDelegate::NotifyAnimationFinished( 186 void TestAnimationDelegate::NotifyAnimationFinished(
188 base::TimeTicks monotonic_time, 187 base::TimeTicks monotonic_time,
189 Animation::TargetProperty target_property, 188 AnimationTargetProperty target_property,
190 int group) { 189 int group) {
191 finished_ = true; 190 finished_ = true;
192 } 191 }
193 192
194 AnimationTimelinesTest::AnimationTimelinesTest() 193 AnimationTimelinesTest::AnimationTimelinesTest()
195 : client_(ThreadInstance::MAIN), 194 : client_(ThreadInstance::MAIN),
196 client_impl_(ThreadInstance::IMPL), 195 client_impl_(ThreadInstance::IMPL),
197 host_(nullptr), 196 host_(nullptr),
198 host_impl_(nullptr), 197 host_impl_(nullptr),
199 timeline_id_(AnimationIdProvider::NextTimelineId()), 198 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() 259 return element_animations ? element_animations->players_list().head()->value()
261 : nullptr; 260 : nullptr;
262 } 261 }
263 262
264 int AnimationTimelinesTest::NextTestLayerId() { 263 int AnimationTimelinesTest::NextTestLayerId() {
265 next_test_layer_id_++; 264 next_test_layer_id_++;
266 return next_test_layer_id_; 265 return next_test_layer_id_;
267 } 266 }
268 267
269 } // namespace cc 268 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698