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

Side by Side Diff: cc/animation/layer_animation_controller_unittest.cc

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 years, 9 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
« no previous file with comments | « cc/animation/layer_animation_controller.cc ('k') | cc/cc.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/animation/layer_animation_controller.h" 5 #include "cc/animation/layer_animation_controller.h"
6 6
7 #include "cc/animation/animation.h" 7 #include "cc/animation/animation.h"
8 #include "cc/animation/animation_curve.h" 8 #include "cc/animation/animation_curve.h"
9 #include "cc/animation/animation_delegate.h" 9 #include "cc/animation/animation_delegate.h"
10 #include "cc/animation/animation_registrar.h" 10 #include "cc/animation/animation_registrar.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 controller_impl->AddValueObserver(&dummy_impl); 164 controller_impl->AddValueObserver(&dummy_impl);
165 FakeLayerAnimationValueObserver dummy; 165 FakeLayerAnimationValueObserver dummy;
166 scoped_refptr<LayerAnimationController> controller( 166 scoped_refptr<LayerAnimationController> controller(
167 LayerAnimationController::Create(0)); 167 LayerAnimationController::Create(0));
168 controller->AddValueObserver(&dummy); 168 controller->AddValueObserver(&dummy);
169 scoped_ptr<AnimationEventsVector> events( 169 scoped_ptr<AnimationEventsVector> events(
170 make_scoped_ptr(new AnimationEventsVector)); 170 make_scoped_ptr(new AnimationEventsVector));
171 171
172 controller->SetAnimationRegistrar(registrar.get()); 172 controller->SetAnimationRegistrar(registrar.get());
173 controller_impl->SetAnimationRegistrar(registrar_impl.get()); 173 controller_impl->SetAnimationRegistrar(registrar_impl.get());
174 EXPECT_EQ(1u, registrar->all_animation_controllers().size()); 174 EXPECT_EQ(1u, registrar->all_animation_controllers_for_testing().size());
175 EXPECT_EQ(1u, registrar_impl->all_animation_controllers().size()); 175 EXPECT_EQ(1u, registrar_impl->all_animation_controllers_for_testing().size());
176 176
177 // Initially, both controllers should be inactive. 177 // Initially, both controllers should be inactive.
178 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); 178 EXPECT_EQ(0u, registrar->active_animation_controllers_for_testing().size());
179 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); 179 EXPECT_EQ(0u,
180 registrar_impl->active_animation_controllers_for_testing().size());
180 181
181 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); 182 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false);
182 // The main thread controller should now be active. 183 // The main thread controller should now be active.
183 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); 184 EXPECT_EQ(1u, registrar->active_animation_controllers_for_testing().size());
184 185
185 controller->PushAnimationUpdatesTo(controller_impl.get()); 186 controller->PushAnimationUpdatesTo(controller_impl.get());
186 controller_impl->ActivateAnimations(); 187 controller_impl->ActivateAnimations();
187 // Both controllers should now be active. 188 // Both controllers should now be active.
188 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); 189 EXPECT_EQ(1u, registrar->active_animation_controllers_for_testing().size());
189 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); 190 EXPECT_EQ(1u,
191 registrar_impl->active_animation_controllers_for_testing().size());
190 192
191 controller_impl->Animate(kInitialTickTime); 193 controller_impl->Animate(kInitialTickTime);
192 controller_impl->UpdateState(true, events.get()); 194 controller_impl->UpdateState(true, events.get());
193 EXPECT_EQ(1u, events->size()); 195 EXPECT_EQ(1u, events->size());
194 controller->NotifyAnimationStarted((*events)[0]); 196 controller->NotifyAnimationStarted((*events)[0]);
195 197
196 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); 198 EXPECT_EQ(1u, registrar->active_animation_controllers_for_testing().size());
197 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); 199 EXPECT_EQ(1u,
200 registrar_impl->active_animation_controllers_for_testing().size());
198 201
199 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); 202 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
200 controller->UpdateState(true, nullptr); 203 controller->UpdateState(true, nullptr);
201 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); 204 EXPECT_EQ(1u, registrar->active_animation_controllers_for_testing().size());
202 205
203 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 206 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
204 controller->UpdateState(true, nullptr); 207 controller->UpdateState(true, nullptr);
205 EXPECT_EQ(Animation::FINISHED, 208 EXPECT_EQ(Animation::FINISHED,
206 controller->GetAnimation(Animation::OPACITY)->run_state()); 209 controller->GetAnimation(Animation::OPACITY)->run_state());
207 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); 210 EXPECT_EQ(1u, registrar->active_animation_controllers_for_testing().size());
208 211
209 events.reset(new AnimationEventsVector); 212 events.reset(new AnimationEventsVector);
210 controller_impl->Animate(kInitialTickTime + 213 controller_impl->Animate(kInitialTickTime +
211 TimeDelta::FromMilliseconds(1500)); 214 TimeDelta::FromMilliseconds(1500));
212 controller_impl->UpdateState(true, events.get()); 215 controller_impl->UpdateState(true, events.get());
213 216
214 EXPECT_EQ(Animation::WAITING_FOR_DELETION, 217 EXPECT_EQ(Animation::WAITING_FOR_DELETION,
215 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); 218 controller_impl->GetAnimation(Animation::OPACITY)->run_state());
216 // The impl thread controller should have de-activated. 219 // The impl thread controller should have de-activated.
217 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); 220 EXPECT_EQ(0u,
221 registrar_impl->active_animation_controllers_for_testing().size());
218 222
219 EXPECT_EQ(1u, events->size()); 223 EXPECT_EQ(1u, events->size());
220 controller->NotifyAnimationFinished((*events)[0]); 224 controller->NotifyAnimationFinished((*events)[0]);
221 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); 225 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500));
222 controller->UpdateState(true, nullptr); 226 controller->UpdateState(true, nullptr);
223 227
224 EXPECT_EQ(Animation::WAITING_FOR_DELETION, 228 EXPECT_EQ(Animation::WAITING_FOR_DELETION,
225 controller->GetAnimation(Animation::OPACITY)->run_state()); 229 controller->GetAnimation(Animation::OPACITY)->run_state());
226 // The main thread controller should have de-activated. 230 // The main thread controller should have de-activated.
227 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); 231 EXPECT_EQ(0u, registrar->active_animation_controllers_for_testing().size());
228 232
229 controller->PushAnimationUpdatesTo(controller_impl.get()); 233 controller->PushAnimationUpdatesTo(controller_impl.get());
230 controller_impl->ActivateAnimations(); 234 controller_impl->ActivateAnimations();
231 EXPECT_FALSE(controller->has_any_animation()); 235 EXPECT_FALSE(controller->has_any_animation());
232 EXPECT_FALSE(controller_impl->has_any_animation()); 236 EXPECT_FALSE(controller_impl->has_any_animation());
233 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); 237 EXPECT_EQ(0u, registrar->active_animation_controllers_for_testing().size());
234 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); 238 EXPECT_EQ(0u,
239 registrar_impl->active_animation_controllers_for_testing().size());
235 240
236 controller->SetAnimationRegistrar(nullptr); 241 controller->SetAnimationRegistrar(nullptr);
237 controller_impl->SetAnimationRegistrar(nullptr); 242 controller_impl->SetAnimationRegistrar(nullptr);
238 } 243 }
239 244
240 TEST(LayerAnimationControllerTest, SyncPause) { 245 TEST(LayerAnimationControllerTest, SyncPause) {
241 FakeLayerAnimationValueObserver dummy_impl; 246 FakeLayerAnimationValueObserver dummy_impl;
242 scoped_refptr<LayerAnimationController> controller_impl( 247 scoped_refptr<LayerAnimationController> controller_impl(
243 LayerAnimationController::Create(0)); 248 LayerAnimationController::Create(0));
244 controller_impl->AddValueObserver(&dummy_impl); 249 controller_impl->AddValueObserver(&dummy_impl);
(...skipping 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::OPACITY)); 2381 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::OPACITY));
2377 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::FILTER)); 2382 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::FILTER));
2378 2383
2379 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 2384 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
2380 controller->UpdateState(true, nullptr); 2385 controller->UpdateState(true, nullptr);
2381 EXPECT_TRUE(controller->IsAnimatingProperty(Animation::OPACITY)); 2386 EXPECT_TRUE(controller->IsAnimatingProperty(Animation::OPACITY));
2382 } 2387 }
2383 2388
2384 } // namespace 2389 } // namespace
2385 } // namespace cc 2390 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/layer_animation_controller.cc ('k') | cc/cc.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698