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

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

Issue 10444014: ash: Improved window maximize/restore animations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix workspace mgr, remove ignore_window, cleanup Created 8 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
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 "ui/aura/test/test_windows.h" 9 #include "ui/aura/test/test_windows.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
11 #include "ui/base/animation/animation_container_element.h" 11 #include "ui/base/animation/animation_container_element.h"
12 #include "ui/compositor/layer.h" 12 #include "ui/compositor/layer.h"
13 #include "ui/compositor/layer_animator.h" 13 #include "ui/compositor/layer_animator.h"
14 14
15 using aura::Window;
16 using ui::Layer;
17
15 namespace ash { 18 namespace ash {
16 namespace internal { 19 namespace internal {
17 20
18 typedef ash::test::AshTestBase WindowAnimationsWorkspaceTest; 21 typedef ash::test::AshTestBase WindowAnimationsWorkspaceTest;
19 22
20 TEST_F(WindowAnimationsWorkspaceTest, HideShow) { 23 TEST_F(WindowAnimationsWorkspaceTest, HideShow) {
21 aura::Window* default_container = 24 aura::Window* default_container =
22 ash::Shell::GetInstance()->GetContainer( 25 ash::Shell::GetInstance()->GetContainer(
23 internal::kShellWindowId_DefaultContainer); 26 internal::kShellWindowId_DefaultContainer);
24 scoped_ptr<aura::Window> window( 27 scoped_ptr<aura::Window> window(
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 103
101 // Layer target visibility changes according to Show/Hide. 104 // Layer target visibility changes according to Show/Hide.
102 window->Show(); 105 window->Show();
103 EXPECT_TRUE(window->layer()->GetTargetVisibility()); 106 EXPECT_TRUE(window->layer()->GetTargetVisibility());
104 window->Hide(); 107 window->Hide();
105 EXPECT_FALSE(window->layer()->GetTargetVisibility()); 108 EXPECT_FALSE(window->layer()->GetTargetVisibility());
106 window->Show(); 109 window->Show();
107 EXPECT_TRUE(window->layer()->GetTargetVisibility()); 110 EXPECT_TRUE(window->layer()->GetTargetVisibility());
108 } 111 }
109 112
113 TEST_F(WindowAnimationsWorkspaceTest, CrossFadeToBounds) {
114 Window* default_container =
115 ash::Shell::GetInstance()->GetContainer(
116 internal::kShellWindowId_DefaultContainer);
117 scoped_ptr<Window> window(
118 aura::test::CreateTestWindowWithId(0, default_container));
119 window->SetBounds(gfx::Rect(5, 10, 320, 240));
120 window->Show();
121
122 Layer* old_layer = window->layer();
123 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity());
124
125 // Cross fade to a larger size, as in a maximize animation.
126 CrossFadeToBounds(window.get(), gfx::Rect(0, 0, 640, 480));
127 // Window's layer has been replaced.
128 EXPECT_NE(old_layer, window->layer());
129 // Original layer stays opaque and stretches to new size.
130 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity());
131 EXPECT_EQ("5,10 320x240", old_layer->bounds().ToString());
132 ui::Transform grow_transform;
133 grow_transform.ConcatScale(640.f / 320.f, 480.f / 240.f);
134 grow_transform.ConcatTranslate(-5.f, -10.f);
135 EXPECT_EQ(grow_transform, old_layer->GetTargetTransform());
136 // New layer animates in to the identity transform.
137 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
138 EXPECT_EQ(ui::Transform(), window->layer()->GetTargetTransform());
139
140 // Allow the animation observer to delete itself.
141 RunAllPendingInMessageLoop();
142
143 // Cross fade to a smaller size, as in a restore animation.
144 old_layer = window->layer();
145 CrossFadeToBounds(window.get(), gfx::Rect(5, 10, 320, 240));
146 // Again, window layer has been replaced.
147 EXPECT_NE(old_layer, window->layer());
148 // Original layer fades out and stretches down to new size.
149 EXPECT_EQ(0.0f, old_layer->GetTargetOpacity());
150 EXPECT_EQ("0,0 640x480", old_layer->bounds().ToString());
151 ui::Transform shrink_transform;
152 shrink_transform.ConcatScale(320.f / 640.f, 240.f / 480.f);
153 shrink_transform.ConcatTranslate(5.f, 10.f);
154 EXPECT_EQ(shrink_transform, old_layer->GetTargetTransform());
155 // New layer animates in to the identity transform.
156 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
157 EXPECT_EQ(ui::Transform(), window->layer()->GetTargetTransform());
158
159 RunAllPendingInMessageLoop();
160 }
161
110 } // namespace internal 162 } // namespace internal
111 } // namespace ash 163 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698