Chromium Code Reviews| 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 #include "ash/rotator/screen_rotation_animation.h" | 5 #include "ash/rotator/screen_rotation_animation.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | |
| 11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 14 #include "ui/compositor/layer.h" | 15 #include "ui/compositor/layer.h" |
| 15 #include "ui/compositor/layer_animation_sequence.h" | 16 #include "ui/compositor/layer_animation_sequence.h" |
| 16 #include "ui/compositor/layer_animator.h" | 17 #include "ui/compositor/layer_animator.h" |
| 17 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 18 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 18 #include "ui/gfx/animation/tween.h" | 19 #include "ui/gfx/animation/tween.h" |
| 19 #include "ui/gfx/transform.h" | 20 #include "ui/gfx/transform.h" |
| 20 | 21 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 const gfx::Transform identity_transform; | 63 const gfx::Transform identity_transform; |
| 63 | 64 |
| 64 ASSERT_EQ(identity_transform, layer->GetTargetTransform()); | 65 ASSERT_EQ(identity_transform, layer->GetTargetTransform()); |
| 65 ASSERT_NE(identity_transform, layer->transform()); | 66 ASSERT_NE(identity_transform, layer->transform()); |
| 66 | 67 |
| 67 layer->GetAnimator()->AbortAllAnimations(); | 68 layer->GetAnimator()->AbortAllAnimations(); |
| 68 | 69 |
| 69 EXPECT_EQ(identity_transform, layer->transform()); | 70 EXPECT_EQ(identity_transform, layer->transform()); |
| 70 } | 71 } |
| 71 | 72 |
| 73 // Tests that ScreenRotationAnimation::OnAbort() doesn't segfault when passed a | |
| 74 // null delegate in response to its ui::Layer being destroyed: | |
| 75 // http://crbug.com/661313 | |
| 76 TEST_F(ScreenRotationAnimationTest, DestroyLayerDuringAnimation) { | |
| 77 // Create a ui::Layer directly rather than an aura::Window, as the latter | |
| 78 // finishes all of its animation before destroying its layer. | |
| 79 std::unique_ptr<ui::Layer> layer = base::MakeUnique<ui::Layer>(); | |
| 80 | |
| 81 ui::Layer* root_layer = CurrentContext()->layer(); | |
| 82 layer->SetBounds(gfx::Rect(root_layer->bounds().size())); | |
| 83 root_layer->Add(layer.get()); | |
| 84 | |
| 85 std::unique_ptr<ScreenRotationAnimation> screen_rotation( | |
| 86 new ScreenRotationAnimation(layer.get(), 45, 0, 1.0f, 1.0f, gfx::Point(), | |
| 87 base::TimeDelta::FromSeconds(1), | |
| 88 gfx::Tween::LINEAR)); | |
| 89 ui::LayerAnimator* animator = layer->GetAnimator(); | |
| 90 std::unique_ptr<ui::LayerAnimationSequence> animation_sequence( | |
| 91 new ui::LayerAnimationSequence(screen_rotation.release())); | |
| 92 animator->StartAnimation(animation_sequence.release()); | |
| 93 | |
| 94 layer.reset(); | |
|
James Cook
2016/11/02 02:19:17
not needed? or comment that you're explicitly dest
Daniel Erat
2016/11/02 14:04:05
Done. (kept this because if this starts failing, i
| |
| 95 } | |
| 96 | |
| 72 } // namespace test | 97 } // namespace test |
| 73 } // namespace ash | 98 } // namespace ash |
| OLD | NEW |