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 |
| 7 #include <memory> |
| 8 |
6 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
7 #include "base/macros.h" | 10 #include "base/macros.h" |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/time/time.h" | 11 #include "base/time/time.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
12 #include "ui/compositor/layer.h" | 14 #include "ui/compositor/layer.h" |
13 #include "ui/compositor/layer_animation_sequence.h" | 15 #include "ui/compositor/layer_animation_sequence.h" |
14 #include "ui/compositor/layer_animator.h" | 16 #include "ui/compositor/layer_animator.h" |
15 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 17 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
16 #include "ui/gfx/animation/tween.h" | 18 #include "ui/gfx/animation/tween.h" |
17 #include "ui/gfx/transform.h" | 19 #include "ui/gfx/transform.h" |
18 | 20 |
19 namespace ash { | 21 namespace ash { |
20 namespace test { | 22 namespace test { |
21 | 23 |
22 class ScreenRotationAnimationTest : public AshTestBase { | 24 class ScreenRotationAnimationTest : public AshTestBase { |
23 public: | 25 public: |
24 ScreenRotationAnimationTest() {} | 26 ScreenRotationAnimationTest() {} |
25 ~ScreenRotationAnimationTest() override {} | 27 ~ScreenRotationAnimationTest() override {} |
26 | 28 |
27 // AshTestBase: | 29 // AshTestBase: |
28 void SetUp() override; | 30 void SetUp() override; |
29 | 31 |
30 private: | 32 private: |
31 scoped_ptr<ui::ScopedAnimationDurationScaleMode> non_zero_duration_mode_; | 33 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> non_zero_duration_mode_; |
32 | 34 |
33 DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimationTest); | 35 DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimationTest); |
34 }; | 36 }; |
35 | 37 |
36 void ScreenRotationAnimationTest::SetUp() { | 38 void ScreenRotationAnimationTest::SetUp() { |
37 AshTestBase::SetUp(); | 39 AshTestBase::SetUp(); |
38 non_zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( | 40 non_zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( |
39 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION)); | 41 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION)); |
40 } | 42 } |
41 | 43 |
42 TEST_F(ScreenRotationAnimationTest, LayerTransformGetsSetToTargetWhenAborted) { | 44 TEST_F(ScreenRotationAnimationTest, LayerTransformGetsSetToTargetWhenAborted) { |
43 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(9)); | 45 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(9)); |
44 ui::Layer* layer = window->layer(); | 46 ui::Layer* layer = window->layer(); |
45 | 47 |
46 scoped_ptr<ScreenRotationAnimation> screen_rotation( | 48 std::unique_ptr<ScreenRotationAnimation> screen_rotation( |
47 new ScreenRotationAnimation( | 49 new ScreenRotationAnimation( |
48 layer, 45 /* start_degrees */, 0 /* end_degrees */, | 50 layer, 45 /* start_degrees */, 0 /* end_degrees */, |
49 0.5f /* initial_opacity */, 1.0f /* target_opacity */, | 51 0.5f /* initial_opacity */, 1.0f /* target_opacity */, |
50 gfx::Point(10, 10) /* pivot */, | 52 gfx::Point(10, 10) /* pivot */, |
51 base::TimeDelta::FromSeconds(10) /* duration */, gfx::Tween::LINEAR)); | 53 base::TimeDelta::FromSeconds(10) /* duration */, gfx::Tween::LINEAR)); |
52 | 54 |
53 ui::LayerAnimator* animator = layer->GetAnimator(); | 55 ui::LayerAnimator* animator = layer->GetAnimator(); |
54 animator->set_preemption_strategy( | 56 animator->set_preemption_strategy( |
55 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 57 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
56 scoped_ptr<ui::LayerAnimationSequence> animation_sequence( | 58 std::unique_ptr<ui::LayerAnimationSequence> animation_sequence( |
57 new ui::LayerAnimationSequence(screen_rotation.release())); | 59 new ui::LayerAnimationSequence(screen_rotation.release())); |
58 animator->StartAnimation(animation_sequence.release()); | 60 animator->StartAnimation(animation_sequence.release()); |
59 | 61 |
60 const gfx::Transform identity_transform; | 62 const gfx::Transform identity_transform; |
61 | 63 |
62 ASSERT_EQ(identity_transform, layer->GetTargetTransform()); | 64 ASSERT_EQ(identity_transform, layer->GetTargetTransform()); |
63 ASSERT_NE(identity_transform, layer->transform()); | 65 ASSERT_NE(identity_transform, layer->transform()); |
64 | 66 |
65 layer->GetAnimator()->AbortAllAnimations(); | 67 layer->GetAnimator()->AbortAllAnimations(); |
66 | 68 |
67 EXPECT_EQ(identity_transform, layer->transform()); | 69 EXPECT_EQ(identity_transform, layer->transform()); |
68 } | 70 } |
69 | 71 |
70 } // namespace test | 72 } // namespace test |
71 } // namespace ash | 73 } // namespace ash |
OLD | NEW |