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/workspace_controller.h" | 9 #include "ash/wm/workspace_controller.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 virtual void TearDown() OVERRIDE { | 27 virtual void TearDown() OVERRIDE { |
28 ui::LayerAnimator::set_disable_animations_for_test(true); | 28 ui::LayerAnimator::set_disable_animations_for_test(true); |
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 TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) { | 36 TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) { |
37 scoped_ptr<aura::Window> window( | 37 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
38 aura::test::CreateTestWindowWithId(0, NULL)); | |
39 window->Show(); | 38 window->Show(); |
40 EXPECT_TRUE(window->layer()->visible()); | 39 EXPECT_TRUE(window->layer()->visible()); |
41 | 40 |
42 // Hiding. | 41 // Hiding. |
43 SetWindowVisibilityAnimationType( | 42 SetWindowVisibilityAnimationType( |
44 window.get(), | 43 window.get(), |
45 WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE); | 44 WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE); |
46 ash::internal::AnimateOnChildWindowVisibilityChanged( | 45 ash::internal::AnimateOnChildWindowVisibilityChanged( |
47 window.get(), false); | 46 window.get(), false); |
48 EXPECT_EQ(0.0f, window->layer()->GetTargetOpacity()); | 47 EXPECT_EQ(0.0f, window->layer()->GetTargetOpacity()); |
(...skipping 15 matching lines...) Expand all Loading... |
64 static_cast<ui::AnimationContainerElement*>( | 63 static_cast<ui::AnimationContainerElement*>( |
65 window->layer()->GetAnimator()); | 64 window->layer()->GetAnimator()); |
66 element->Step(base::TimeTicks::Now() + | 65 element->Step(base::TimeTicks::Now() + |
67 base::TimeDelta::FromSeconds(5)); | 66 base::TimeDelta::FromSeconds(5)); |
68 EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness()); | 67 EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness()); |
69 EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale()); | 68 EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale()); |
70 EXPECT_TRUE(window->layer()->visible()); | 69 EXPECT_TRUE(window->layer()->visible()); |
71 } | 70 } |
72 | 71 |
73 TEST_F(WindowAnimationsTest, LayerTargetVisibility) { | 72 TEST_F(WindowAnimationsTest, LayerTargetVisibility) { |
74 scoped_ptr<aura::Window> window( | 73 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
75 aura::test::CreateTestWindowWithId(0, NULL)); | |
76 | 74 |
77 // Layer target visibility changes according to Show/Hide. | 75 // Layer target visibility changes according to Show/Hide. |
78 window->Show(); | 76 window->Show(); |
79 EXPECT_TRUE(window->layer()->GetTargetVisibility()); | 77 EXPECT_TRUE(window->layer()->GetTargetVisibility()); |
80 window->Hide(); | 78 window->Hide(); |
81 EXPECT_FALSE(window->layer()->GetTargetVisibility()); | 79 EXPECT_FALSE(window->layer()->GetTargetVisibility()); |
82 window->Show(); | 80 window->Show(); |
83 EXPECT_TRUE(window->layer()->GetTargetVisibility()); | 81 EXPECT_TRUE(window->layer()->GetTargetVisibility()); |
84 } | 82 } |
85 | 83 |
86 TEST_F(WindowAnimationsTest, CrossFadeToBounds) { | 84 TEST_F(WindowAnimationsTest, CrossFadeToBounds) { |
87 ui::LayerAnimator::set_disable_animations_for_test(false); | 85 ui::LayerAnimator::set_disable_animations_for_test(false); |
88 | 86 |
89 scoped_ptr<Window> window( | 87 scoped_ptr<Window> window(CreateTestWindowInShellWithId(0)); |
90 aura::test::CreateTestWindowWithId(0, NULL)); | |
91 window->SetBounds(gfx::Rect(5, 10, 320, 240)); | 88 window->SetBounds(gfx::Rect(5, 10, 320, 240)); |
92 window->Show(); | 89 window->Show(); |
93 | 90 |
94 Layer* old_layer = window->layer(); | 91 Layer* old_layer = window->layer(); |
95 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity()); | 92 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity()); |
96 | 93 |
97 // Cross fade to a larger size, as in a maximize animation. | 94 // Cross fade to a larger size, as in a maximize animation. |
98 CrossFadeToBounds(window.get(), gfx::Rect(0, 0, 640, 480)); | 95 CrossFadeToBounds(window.get(), gfx::Rect(0, 0, 640, 480)); |
99 // Window's layer has been replaced. | 96 // Window's layer has been replaced. |
100 EXPECT_NE(old_layer, window->layer()); | 97 EXPECT_NE(old_layer, window->layer()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform()); | 129 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform()); |
133 | 130 |
134 static_cast<ui::AnimationContainerElement*>(old_layer->GetAnimator())->Step( | 131 static_cast<ui::AnimationContainerElement*>(old_layer->GetAnimator())->Step( |
135 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); | 132 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); |
136 static_cast<ui::AnimationContainerElement*>(window->layer()->GetAnimator())-> | 133 static_cast<ui::AnimationContainerElement*>(window->layer()->GetAnimator())-> |
137 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); | 134 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); |
138 } | 135 } |
139 | 136 |
140 } // namespace internal | 137 } // namespace internal |
141 } // namespace ash | 138 } // namespace ash |
OLD | NEW |