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

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

Issue 11145005: Migrate ui::Transform to gfx::Transform (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Hopefully should work this time Created 8 years, 2 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
« no previous file with comments | « ash/wm/window_animations.cc ('k') | ash/wm/window_manager_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/workspace_controller.h" 9 #include "ash/wm/workspace_controller.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 Layer* old_layer = window->layer(); 162 Layer* old_layer = window->layer();
163 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity()); 163 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity());
164 164
165 // Cross fade to a larger size, as in a maximize animation. 165 // Cross fade to a larger size, as in a maximize animation.
166 CrossFadeToBounds(window.get(), gfx::Rect(0, 0, 640, 480)); 166 CrossFadeToBounds(window.get(), gfx::Rect(0, 0, 640, 480));
167 // Window's layer has been replaced. 167 // Window's layer has been replaced.
168 EXPECT_NE(old_layer, window->layer()); 168 EXPECT_NE(old_layer, window->layer());
169 // Original layer stays opaque and stretches to new size. 169 // Original layer stays opaque and stretches to new size.
170 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity()); 170 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity());
171 EXPECT_EQ("5,10 320x240", old_layer->bounds().ToString()); 171 EXPECT_EQ("5,10 320x240", old_layer->bounds().ToString());
172 ui::Transform grow_transform; 172 gfx::Transform grow_transform;
173 grow_transform.ConcatScale(640.f / 320.f, 480.f / 240.f); 173 grow_transform.ConcatScale(640.f / 320.f, 480.f / 240.f);
174 grow_transform.ConcatTranslate(-5.f, -10.f); 174 grow_transform.ConcatTranslate(-5.f, -10.f);
175 EXPECT_EQ(grow_transform, old_layer->GetTargetTransform()); 175 EXPECT_EQ(grow_transform, old_layer->GetTargetTransform());
176 // New layer animates in to the identity transform. 176 // New layer animates in to the identity transform.
177 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity()); 177 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
178 EXPECT_EQ(ui::Transform(), window->layer()->GetTargetTransform()); 178 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform());
179 179
180 // Run the animations to completion. 180 // Run the animations to completion.
181 static_cast<ui::AnimationContainerElement*>(old_layer->GetAnimator())->Step( 181 static_cast<ui::AnimationContainerElement*>(old_layer->GetAnimator())->Step(
182 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); 182 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
183 static_cast<ui::AnimationContainerElement*>(window->layer()->GetAnimator())-> 183 static_cast<ui::AnimationContainerElement*>(window->layer()->GetAnimator())->
184 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); 184 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
185 185
186 // Cross fade to a smaller size, as in a restore animation. 186 // Cross fade to a smaller size, as in a restore animation.
187 old_layer = window->layer(); 187 old_layer = window->layer();
188 CrossFadeToBounds(window.get(), gfx::Rect(5, 10, 320, 240)); 188 CrossFadeToBounds(window.get(), gfx::Rect(5, 10, 320, 240));
189 // Again, window layer has been replaced. 189 // Again, window layer has been replaced.
190 EXPECT_NE(old_layer, window->layer()); 190 EXPECT_NE(old_layer, window->layer());
191 // Original layer fades out and stretches down to new size. 191 // Original layer fades out and stretches down to new size.
192 EXPECT_EQ(0.0f, old_layer->GetTargetOpacity()); 192 EXPECT_EQ(0.0f, old_layer->GetTargetOpacity());
193 EXPECT_EQ("0,0 640x480", old_layer->bounds().ToString()); 193 EXPECT_EQ("0,0 640x480", old_layer->bounds().ToString());
194 ui::Transform shrink_transform; 194 gfx::Transform shrink_transform;
195 shrink_transform.ConcatScale(320.f / 640.f, 240.f / 480.f); 195 shrink_transform.ConcatScale(320.f / 640.f, 240.f / 480.f);
196 shrink_transform.ConcatTranslate(5.f, 10.f); 196 shrink_transform.ConcatTranslate(5.f, 10.f);
197 EXPECT_EQ(shrink_transform, old_layer->GetTargetTransform()); 197 EXPECT_EQ(shrink_transform, old_layer->GetTargetTransform());
198 // New layer animates in to the identity transform. 198 // New layer animates in to the identity transform.
199 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity()); 199 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
200 EXPECT_EQ(ui::Transform(), window->layer()->GetTargetTransform()); 200 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform());
201 201
202 static_cast<ui::AnimationContainerElement*>(old_layer->GetAnimator())->Step( 202 static_cast<ui::AnimationContainerElement*>(old_layer->GetAnimator())->Step(
203 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); 203 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
204 static_cast<ui::AnimationContainerElement*>(window->layer()->GetAnimator())-> 204 static_cast<ui::AnimationContainerElement*>(window->layer()->GetAnimator())->
205 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); 205 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
206 } 206 }
207 207
208 TEST_F(WindowAnimationsTest, GetCrossFadeDuration) { 208 TEST_F(WindowAnimationsTest, GetCrossFadeDuration) {
209 if (WorkspaceController::IsWorkspace2Enabled()) 209 if (WorkspaceController::IsWorkspace2Enabled())
210 return; 210 return;
(...skipping 24 matching lines...) Expand all
235 // Medium changes take medium time. 235 // Medium changes take medium time.
236 gfx::Rect half_screen(10, 10, 500, 250); 236 gfx::Rect half_screen(10, 10, 500, 250);
237 EXPECT_EQ(kMinimum + kRange * 3 / 4, 237 EXPECT_EQ(kMinimum + kRange * 3 / 4,
238 GetCrossFadeDuration(half_screen, screen).InMilliseconds()); 238 GetCrossFadeDuration(half_screen, screen).InMilliseconds());
239 EXPECT_EQ(kMinimum + kRange * 3 / 4, 239 EXPECT_EQ(kMinimum + kRange * 3 / 4,
240 GetCrossFadeDuration(screen, half_screen).InMilliseconds()); 240 GetCrossFadeDuration(screen, half_screen).InMilliseconds());
241 } 241 }
242 242
243 } // namespace internal 243 } // namespace internal
244 } // namespace ash 244 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_animations.cc ('k') | ash/wm/window_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698