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

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

Issue 23531053: ui/base/animation -> ui/gfx/animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge 2 trunk Created 7 years, 3 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/wm/window_animations.cc ('k') | ash/wm/workspace/alternate_frame_caption_button.h » ('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/time.h" 10 #include "base/time/time.h"
11 #include "ui/aura/test/test_windows.h" 11 #include "ui/aura/test/test_windows.h"
12 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
13 #include "ui/base/animation/animation_container_element.h"
14 #include "ui/compositor/layer.h" 13 #include "ui/compositor/layer.h"
15 #include "ui/compositor/layer_animator.h" 14 #include "ui/compositor/layer_animator.h"
16 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 15 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
16 #include "ui/gfx/animation/animation_container_element.h"
17 17
18 using aura::Window; 18 using aura::Window;
19 using ui::Layer; 19 using ui::Layer;
20 20
21 namespace ash { 21 namespace ash {
22 namespace internal { 22 namespace internal {
23 23
24 class WindowAnimationsTest : public ash::test::AshTestBase { 24 class WindowAnimationsTest : public ash::test::AshTestBase {
25 public: 25 public:
26 WindowAnimationsTest() {} 26 WindowAnimationsTest() {}
(...skipping 23 matching lines...) Expand all
50 // Showing. 50 // Showing.
51 views::corewm::SetWindowVisibilityAnimationType( 51 views::corewm::SetWindowVisibilityAnimationType(
52 window.get(), 52 window.get(),
53 WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE); 53 WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE);
54 AnimateOnChildWindowVisibilityChanged(window.get(), true); 54 AnimateOnChildWindowVisibilityChanged(window.get(), true);
55 EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness()); 55 EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness());
56 EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale()); 56 EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale());
57 EXPECT_TRUE(window->layer()->visible()); 57 EXPECT_TRUE(window->layer()->visible());
58 58
59 // Stays shown. 59 // Stays shown.
60 ui::AnimationContainerElement* element = 60 gfx::AnimationContainerElement* element =
61 static_cast<ui::AnimationContainerElement*>( 61 static_cast<gfx::AnimationContainerElement*>(
62 window->layer()->GetAnimator()); 62 window->layer()->GetAnimator());
63 element->Step(base::TimeTicks::Now() + 63 element->Step(base::TimeTicks::Now() +
64 base::TimeDelta::FromSeconds(5)); 64 base::TimeDelta::FromSeconds(5));
65 EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness()); 65 EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness());
66 EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale()); 66 EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale());
67 EXPECT_TRUE(window->layer()->visible()); 67 EXPECT_TRUE(window->layer()->visible());
68 } 68 }
69 69
70 TEST_F(WindowAnimationsTest, LayerTargetVisibility) { 70 TEST_F(WindowAnimationsTest, LayerTargetVisibility) {
71 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); 71 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
(...skipping 27 matching lines...) Expand all
99 EXPECT_EQ("5,10 320x240", old_layer->bounds().ToString()); 99 EXPECT_EQ("5,10 320x240", old_layer->bounds().ToString());
100 gfx::Transform grow_transform; 100 gfx::Transform grow_transform;
101 grow_transform.Translate(-5.f, -10.f); 101 grow_transform.Translate(-5.f, -10.f);
102 grow_transform.Scale(640.f / 320.f, 480.f / 240.f); 102 grow_transform.Scale(640.f / 320.f, 480.f / 240.f);
103 EXPECT_EQ(grow_transform, old_layer->GetTargetTransform()); 103 EXPECT_EQ(grow_transform, old_layer->GetTargetTransform());
104 // New layer animates in to the identity transform. 104 // New layer animates in to the identity transform.
105 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity()); 105 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
106 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform()); 106 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform());
107 107
108 // Run the animations to completion. 108 // Run the animations to completion.
109 static_cast<ui::AnimationContainerElement*>(old_layer->GetAnimator())->Step( 109 static_cast<gfx::AnimationContainerElement*>(old_layer->GetAnimator())->Step(
110 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); 110 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
111 static_cast<ui::AnimationContainerElement*>(window->layer()->GetAnimator())-> 111 static_cast<gfx::AnimationContainerElement*>(window->layer()->GetAnimator())->
112 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); 112 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
113 113
114 // Cross fade to a smaller size, as in a restore animation. 114 // Cross fade to a smaller size, as in a restore animation.
115 old_layer = window->layer(); 115 old_layer = window->layer();
116 CrossFadeToBounds(window.get(), gfx::Rect(5, 10, 320, 240)); 116 CrossFadeToBounds(window.get(), gfx::Rect(5, 10, 320, 240));
117 // Again, window layer has been replaced. 117 // Again, window layer has been replaced.
118 EXPECT_NE(old_layer, window->layer()); 118 EXPECT_NE(old_layer, window->layer());
119 // Original layer fades out and stretches down to new size. 119 // Original layer fades out and stretches down to new size.
120 EXPECT_EQ(0.0f, old_layer->GetTargetOpacity()); 120 EXPECT_EQ(0.0f, old_layer->GetTargetOpacity());
121 EXPECT_EQ("0,0 640x480", old_layer->bounds().ToString()); 121 EXPECT_EQ("0,0 640x480", old_layer->bounds().ToString());
122 gfx::Transform shrink_transform; 122 gfx::Transform shrink_transform;
123 shrink_transform.Translate(5.f, 10.f); 123 shrink_transform.Translate(5.f, 10.f);
124 shrink_transform.Scale(320.f / 640.f, 240.f / 480.f); 124 shrink_transform.Scale(320.f / 640.f, 240.f / 480.f);
125 EXPECT_EQ(shrink_transform, old_layer->GetTargetTransform()); 125 EXPECT_EQ(shrink_transform, old_layer->GetTargetTransform());
126 // New layer animates in to the identity transform. 126 // New layer animates in to the identity transform.
127 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity()); 127 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
128 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform()); 128 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform());
129 129
130 static_cast<ui::AnimationContainerElement*>(old_layer->GetAnimator())->Step( 130 static_cast<gfx::AnimationContainerElement*>(old_layer->GetAnimator())->Step(
131 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); 131 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
132 static_cast<ui::AnimationContainerElement*>(window->layer()->GetAnimator())-> 132 static_cast<gfx::AnimationContainerElement*>(window->layer()->GetAnimator())->
133 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); 133 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
134 } 134 }
135 135
136 } // namespace internal 136 } // namespace internal
137 } // namespace ash 137 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_animations.cc ('k') | ash/wm/workspace/alternate_frame_caption_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698