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

Side by Side Diff: ash/rotator/screen_rotation_animation_unittest.cc

Issue 2473523003: ash: Avoid a shutdown crash in ScreenRotationAnimation. (Closed)
Patch Set: address review comments Created 4 years, 1 month 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 | « ash/rotator/screen_rotation_animation.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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 // Explicitly destroy the layer to verify that the animation doesn't crash.
95 layer.reset();
96 }
97
72 } // namespace test 98 } // namespace test
73 } // namespace ash 99 } // namespace ash
OLDNEW
« no previous file with comments | « ash/rotator/screen_rotation_animation.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698