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

Side by Side Diff: ash/wm/window_animations_unittest.cc

Issue 311783002: Revert r274404 and r274409: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « ash/shelf/shelf_layout_manager_unittest.cc ('k') | ash/wm/workspace_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/gfx/animation/animation_container_element.h"
19 20
20 using aura::Window; 21 using aura::Window;
21 using ui::Layer; 22 using ui::Layer;
22 23
23 namespace ash { 24 namespace ash {
24 class WindowAnimationsTest : public ash::test::AshTestBase { 25 class WindowAnimationsTest : public ash::test::AshTestBase {
25 public: 26 public:
26 WindowAnimationsTest() {} 27 WindowAnimationsTest() {}
27 28
28 virtual void TearDown() OVERRIDE { 29 virtual void TearDown() OVERRIDE {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // Showing. 82 // Showing.
82 ::wm::SetWindowVisibilityAnimationType( 83 ::wm::SetWindowVisibilityAnimationType(
83 window.get(), 84 window.get(),
84 WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE); 85 WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE);
85 AnimateOnChildWindowVisibilityChanged(window.get(), true); 86 AnimateOnChildWindowVisibilityChanged(window.get(), true);
86 EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness()); 87 EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness());
87 EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale()); 88 EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale());
88 EXPECT_TRUE(window->layer()->visible()); 89 EXPECT_TRUE(window->layer()->visible());
89 90
90 // Stays shown. 91 // Stays shown.
91 window->layer()->GetAnimator()->Step(base::TimeTicks::Now() + 92 gfx::AnimationContainerElement* element =
92 base::TimeDelta::FromSeconds(5)); 93 static_cast<gfx::AnimationContainerElement*>(
94 window->layer()->GetAnimator());
95 element->Step(base::TimeTicks::Now() +
96 base::TimeDelta::FromSeconds(5));
93 EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness()); 97 EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness());
94 EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale()); 98 EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale());
95 EXPECT_TRUE(window->layer()->visible()); 99 EXPECT_TRUE(window->layer()->visible());
96 } 100 }
97 101
98 TEST_F(WindowAnimationsTest, LayerTargetVisibility) { 102 TEST_F(WindowAnimationsTest, LayerTargetVisibility) {
99 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); 103 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
100 104
101 // Layer target visibility changes according to Show/Hide. 105 // Layer target visibility changes according to Show/Hide.
102 window->Show(); 106 window->Show();
(...skipping 27 matching lines...) Expand all
130 EXPECT_EQ("5,10 320x240", old_layer->bounds().ToString()); 134 EXPECT_EQ("5,10 320x240", old_layer->bounds().ToString());
131 gfx::Transform grow_transform; 135 gfx::Transform grow_transform;
132 grow_transform.Translate(-5.f, -10.f); 136 grow_transform.Translate(-5.f, -10.f);
133 grow_transform.Scale(640.f / 320.f, 480.f / 240.f); 137 grow_transform.Scale(640.f / 320.f, 480.f / 240.f);
134 EXPECT_EQ(grow_transform, old_layer->GetTargetTransform()); 138 EXPECT_EQ(grow_transform, old_layer->GetTargetTransform());
135 // New layer animates in to the identity transform. 139 // New layer animates in to the identity transform.
136 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity()); 140 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
137 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform()); 141 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform());
138 142
139 // Run the animations to completion. 143 // Run the animations to completion.
140 old_layer->GetAnimator()->Step(base::TimeTicks::Now() + 144 static_cast<gfx::AnimationContainerElement*>(old_layer->GetAnimator())->Step(
141 base::TimeDelta::FromSeconds(1)); 145 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
142 window->layer()->GetAnimator()->Step(base::TimeTicks::Now() + 146 static_cast<gfx::AnimationContainerElement*>(window->layer()->GetAnimator())->
143 base::TimeDelta::FromSeconds(1)); 147 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
144 148
145 // Cross fade to a smaller size, as in a restore animation. 149 // Cross fade to a smaller size, as in a restore animation.
146 old_layer = window->layer(); 150 old_layer = window->layer();
147 GetWindowState(window.get())->SetBoundsDirectCrossFade( 151 GetWindowState(window.get())->SetBoundsDirectCrossFade(
148 gfx::Rect(5, 10, 320, 240)); 152 gfx::Rect(5, 10, 320, 240));
149 // Again, window layer has been replaced. 153 // Again, window layer has been replaced.
150 EXPECT_NE(old_layer, window->layer()); 154 EXPECT_NE(old_layer, window->layer());
151 // Original layer fades out and stretches down to new size. 155 // Original layer fades out and stretches down to new size.
152 EXPECT_EQ(0.0f, old_layer->GetTargetOpacity()); 156 EXPECT_EQ(0.0f, old_layer->GetTargetOpacity());
153 EXPECT_EQ("0,0 640x480", old_layer->bounds().ToString()); 157 EXPECT_EQ("0,0 640x480", old_layer->bounds().ToString());
154 gfx::Transform shrink_transform; 158 gfx::Transform shrink_transform;
155 shrink_transform.Translate(5.f, 10.f); 159 shrink_transform.Translate(5.f, 10.f);
156 shrink_transform.Scale(320.f / 640.f, 240.f / 480.f); 160 shrink_transform.Scale(320.f / 640.f, 240.f / 480.f);
157 EXPECT_EQ(shrink_transform, old_layer->GetTargetTransform()); 161 EXPECT_EQ(shrink_transform, old_layer->GetTargetTransform());
158 // New layer animates in to the identity transform. 162 // New layer animates in to the identity transform.
159 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity()); 163 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
160 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform()); 164 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform());
161 165
162 old_layer->GetAnimator()->Step(base::TimeTicks::Now() + 166 static_cast<gfx::AnimationContainerElement*>(old_layer->GetAnimator())->Step(
163 base::TimeDelta::FromSeconds(1)); 167 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
164 window->layer()->GetAnimator()->Step(base::TimeTicks::Now() + 168 static_cast<gfx::AnimationContainerElement*>(window->layer()->GetAnimator())->
165 base::TimeDelta::FromSeconds(1)); 169 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
166 } 170 }
167 171
168 } // namespace wm 172 } // namespace wm
169 173
170 TEST_F(WindowAnimationsTest, LockAnimationDuration) { 174 TEST_F(WindowAnimationsTest, LockAnimationDuration) {
171 ui::ScopedAnimationDurationScaleMode normal_duration_mode( 175 ui::ScopedAnimationDurationScaleMode normal_duration_mode(
172 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); 176 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
173 177
174 scoped_ptr<Window> window(CreateTestWindowInShellWithId(0)); 178 scoped_ptr<Window> window(CreateTestWindowInShellWithId(0));
175 Layer* layer = window->layer(); 179 Layer* layer = window->layer();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 EXPECT_TRUE(layer->GetAnimator()->is_animating()); 241 EXPECT_TRUE(layer->GetAnimator()->is_animating());
238 // Expect default duration (200ms for stock ash minimizing animation). 242 // Expect default duration (200ms for stock ash minimizing animation).
239 EXPECT_EQ(default_duration.InMilliseconds(), 243 EXPECT_EQ(default_duration.InMilliseconds(),
240 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); 244 layer->GetAnimator()->GetTransitionDuration().InMilliseconds());
241 window->Show(); 245 window->Show();
242 layer->GetAnimator()->StopAnimating(); 246 layer->GetAnimator()->StopAnimating();
243 } 247 }
244 } 248 }
245 249
246 } // namespace ash 250 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager_unittest.cc ('k') | ash/wm/workspace_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698