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

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

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

Powered by Google App Engine
This is Rietveld 408576698