OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ash/wm/window_animations.h" | 5 #include "ash/wm/window_animations.h" |
6 | 6 |
7 #include "ash/shell_window_ids.h" | 7 #include "ash/shell_window_ids.h" |
8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
9 #include "ash/wm/window_state.h" | 9 #include "ash/wm/window_state.h" |
10 #include "ash/wm/workspace_controller.h" | 10 #include "ash/wm/workspace_controller.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "ui/aura/test/test_windows.h" | 12 #include "ui/aura/test/test_windows.h" |
13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
14 #include "ui/compositor/layer.h" | 14 #include "ui/compositor/layer.h" |
15 #include "ui/compositor/layer_animation_observer.h" | 15 #include "ui/compositor/layer_animation_observer.h" |
16 #include "ui/compositor/layer_animator.h" | 16 #include "ui/compositor/layer_animator.h" |
17 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 17 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
18 #include "ui/compositor/scoped_layer_animation_settings.h" | 18 #include "ui/compositor/scoped_layer_animation_settings.h" |
19 | 19 |
20 using aura::Window; | 20 using aura::Window; |
21 using ui::Layer; | 21 using ui::Layer; |
22 | 22 |
23 namespace ash { | 23 namespace ash { |
24 class WindowAnimationsTest : public ash::test::AshTestBase { | 24 class WindowAnimationsTest : public ash::test::AshTestBase { |
25 public: | 25 public: |
26 WindowAnimationsTest() {} | 26 WindowAnimationsTest() {} |
27 | 27 |
28 virtual void TearDown() OVERRIDE { | 28 virtual void TearDown() override { |
29 AshTestBase::TearDown(); | 29 AshTestBase::TearDown(); |
30 } | 30 } |
31 | 31 |
32 private: | 32 private: |
33 DISALLOW_COPY_AND_ASSIGN(WindowAnimationsTest); | 33 DISALLOW_COPY_AND_ASSIGN(WindowAnimationsTest); |
34 }; | 34 }; |
35 | 35 |
36 // Listens to animation scheduled notifications. Remembers the transition | 36 // Listens to animation scheduled notifications. Remembers the transition |
37 // duration of the first sequence. | 37 // duration of the first sequence. |
38 class MinimizeAnimationObserver : public ui::LayerAnimationObserver { | 38 class MinimizeAnimationObserver : public ui::LayerAnimationObserver { |
39 public: | 39 public: |
40 explicit MinimizeAnimationObserver(ui::LayerAnimator* animator) | 40 explicit MinimizeAnimationObserver(ui::LayerAnimator* animator) |
41 : animator_(animator) { | 41 : animator_(animator) { |
42 animator_->AddObserver(this); | 42 animator_->AddObserver(this); |
43 // RemoveObserver is called when the first animation is scheduled and so | 43 // RemoveObserver is called when the first animation is scheduled and so |
44 // there should be no need for now to remove it in destructor. | 44 // there should be no need for now to remove it in destructor. |
45 }; | 45 }; |
46 base::TimeDelta duration() { return duration_; } | 46 base::TimeDelta duration() { return duration_; } |
47 | 47 |
48 protected: | 48 protected: |
49 // ui::LayerAnimationObserver: | 49 // ui::LayerAnimationObserver: |
50 virtual void OnLayerAnimationScheduled( | 50 virtual void OnLayerAnimationScheduled( |
51 ui::LayerAnimationSequence* sequence) OVERRIDE { | 51 ui::LayerAnimationSequence* sequence) override { |
52 duration_ = animator_->GetTransitionDuration(); | 52 duration_ = animator_->GetTransitionDuration(); |
53 animator_->RemoveObserver(this); | 53 animator_->RemoveObserver(this); |
54 } | 54 } |
55 virtual void OnLayerAnimationEnded( | 55 virtual void OnLayerAnimationEnded( |
56 ui::LayerAnimationSequence* sequence) OVERRIDE {} | 56 ui::LayerAnimationSequence* sequence) override {} |
57 virtual void OnLayerAnimationAborted( | 57 virtual void OnLayerAnimationAborted( |
58 ui::LayerAnimationSequence* sequence) OVERRIDE {} | 58 ui::LayerAnimationSequence* sequence) override {} |
59 | 59 |
60 private: | 60 private: |
61 ui::LayerAnimator* animator_; | 61 ui::LayerAnimator* animator_; |
62 base::TimeDelta duration_; | 62 base::TimeDelta duration_; |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(MinimizeAnimationObserver); | 64 DISALLOW_COPY_AND_ASSIGN(MinimizeAnimationObserver); |
65 }; | 65 }; |
66 | 66 |
67 TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) { | 67 TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) { |
68 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 68 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 EXPECT_TRUE(layer->GetAnimator()->is_animating()); | 280 EXPECT_TRUE(layer->GetAnimator()->is_animating()); |
281 // Expect default duration (200ms for stock ash minimizing animation). | 281 // Expect default duration (200ms for stock ash minimizing animation). |
282 EXPECT_EQ(default_duration.InMilliseconds(), | 282 EXPECT_EQ(default_duration.InMilliseconds(), |
283 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); | 283 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); |
284 window->Show(); | 284 window->Show(); |
285 layer->GetAnimator()->StopAnimating(); | 285 layer->GetAnimator()->StopAnimating(); |
286 } | 286 } |
287 } | 287 } |
288 | 288 |
289 } // namespace ash | 289 } // namespace ash |
OLD | NEW |