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

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

Issue 11418040: gfx::Transform API clean-up (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 1 month 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/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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity()); 95 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity());
96 96
97 // Cross fade to a larger size, as in a maximize animation. 97 // Cross fade to a larger size, as in a maximize animation.
98 CrossFadeToBounds(window.get(), gfx::Rect(0, 0, 640, 480)); 98 CrossFadeToBounds(window.get(), gfx::Rect(0, 0, 640, 480));
99 // Window's layer has been replaced. 99 // Window's layer has been replaced.
100 EXPECT_NE(old_layer, window->layer()); 100 EXPECT_NE(old_layer, window->layer());
101 // Original layer stays opaque and stretches to new size. 101 // Original layer stays opaque and stretches to new size.
102 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity()); 102 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity());
103 EXPECT_EQ("5,10 320x240", old_layer->bounds().ToString()); 103 EXPECT_EQ("5,10 320x240", old_layer->bounds().ToString());
104 gfx::Transform grow_transform; 104 gfx::Transform grow_transform;
105 grow_transform.ConcatScale(640.f / 320.f, 480.f / 240.f); 105 grow_transform.Translate(-5.f, -10.f);
106 grow_transform.ConcatTranslate(-5.f, -10.f); 106 grow_transform.Scale(640.f / 320.f, 480.f / 240.f);
107 EXPECT_EQ(grow_transform, old_layer->GetTargetTransform()); 107 EXPECT_EQ(grow_transform, old_layer->GetTargetTransform());
108 // New layer animates in to the identity transform. 108 // New layer animates in to the identity transform.
109 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity()); 109 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
110 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform()); 110 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform());
111 111
112 // Run the animations to completion. 112 // Run the animations to completion.
113 static_cast<ui::AnimationContainerElement*>(old_layer->GetAnimator())->Step( 113 static_cast<ui::AnimationContainerElement*>(old_layer->GetAnimator())->Step(
114 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); 114 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
115 static_cast<ui::AnimationContainerElement*>(window->layer()->GetAnimator())-> 115 static_cast<ui::AnimationContainerElement*>(window->layer()->GetAnimator())->
116 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); 116 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
117 117
118 // Cross fade to a smaller size, as in a restore animation. 118 // Cross fade to a smaller size, as in a restore animation.
119 old_layer = window->layer(); 119 old_layer = window->layer();
120 CrossFadeToBounds(window.get(), gfx::Rect(5, 10, 320, 240)); 120 CrossFadeToBounds(window.get(), gfx::Rect(5, 10, 320, 240));
121 // Again, window layer has been replaced. 121 // Again, window layer has been replaced.
122 EXPECT_NE(old_layer, window->layer()); 122 EXPECT_NE(old_layer, window->layer());
123 // Original layer fades out and stretches down to new size. 123 // Original layer fades out and stretches down to new size.
124 EXPECT_EQ(0.0f, old_layer->GetTargetOpacity()); 124 EXPECT_EQ(0.0f, old_layer->GetTargetOpacity());
125 EXPECT_EQ("0,0 640x480", old_layer->bounds().ToString()); 125 EXPECT_EQ("0,0 640x480", old_layer->bounds().ToString());
126 gfx::Transform shrink_transform; 126 gfx::Transform shrink_transform;
127 shrink_transform.ConcatScale(320.f / 640.f, 240.f / 480.f); 127 shrink_transform.Translate(5.f, 10.f);
128 shrink_transform.ConcatTranslate(5.f, 10.f); 128 shrink_transform.Scale(320.f / 640.f, 240.f / 480.f);
129 EXPECT_EQ(shrink_transform, old_layer->GetTargetTransform()); 129 EXPECT_EQ(shrink_transform, old_layer->GetTargetTransform());
130 // New layer animates in to the identity transform. 130 // New layer animates in to the identity transform.
131 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity()); 131 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
132 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform()); 132 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform());
133 133
134 static_cast<ui::AnimationContainerElement*>(old_layer->GetAnimator())->Step( 134 static_cast<ui::AnimationContainerElement*>(old_layer->GetAnimator())->Step(
135 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); 135 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
136 static_cast<ui::AnimationContainerElement*>(window->layer()->GetAnimator())-> 136 static_cast<ui::AnimationContainerElement*>(window->layer()->GetAnimator())->
137 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); 137 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
138 } 138 }
139 139
140 } // namespace internal 140 } // namespace internal
141 } // namespace ash 141 } // 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