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