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

Side by Side Diff: chrome/browser/ui/ash/ash_keyboard_controller_proxy_unittest.cc

Issue 134133003: Fix VK animation related issues (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add test Created 6 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/ash/ash_keyboard_controller_proxy.h" 5 #include "chrome/browser/ui/ash/ash_keyboard_controller_proxy.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ui/aura/test/test_window_delegate.h" 9 #include "ui/aura/test/test_window_delegate.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
11 #include "ui/base/ime/input_method.h" 11 #include "ui/base/ime/input_method.h"
12 #include "ui/base/ime/input_method_factory.h" 12 #include "ui/base/ime/input_method_factory.h"
13 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 13 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
14 #include "ui/compositor/test/layer_animator_test_controller.h" 14 #include "ui/compositor/test/layer_animator_test_controller.h"
15 #include "ui/keyboard/keyboard_controller.h" 15 #include "ui/keyboard/keyboard_controller.h"
16 16
17 namespace { 17 namespace {
18 18
19 // Keep in sync with the one in ash_keyboard_controller_proxy.cc
20 const float kAnimationStartOrAfterHideOpacity = 0.2f;
21
19 // Steps a layer animation until it is completed. Animations must be enabled. 22 // Steps a layer animation until it is completed. Animations must be enabled.
20 void RunAnimationForLayer(ui::Layer* layer) { 23 void RunAnimationForLayer(ui::Layer* layer) {
21 // Animations must be enabled for stepping to work. 24 // Animations must be enabled for stepping to work.
22 ASSERT_NE(ui::ScopedAnimationDurationScaleMode::duration_scale_mode(), 25 ASSERT_NE(ui::ScopedAnimationDurationScaleMode::duration_scale_mode(),
23 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); 26 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION);
24 27
25 ui::LayerAnimatorTestController controller(layer->GetAnimator()); 28 ui::LayerAnimatorTestController controller(layer->GetAnimator());
26 gfx::AnimationContainerElement* element = layer->GetAnimator(); 29 gfx::AnimationContainerElement* element = layer->GetAnimator();
27 // Multiple steps are required to complete complex animations. 30 // Multiple steps are required to complete complex animations.
28 // TODO(vollick): This should not be necessary. crbug.com/154017 31 // TODO(vollick): This should not be necessary. crbug.com/154017
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 aura::Window* keyboard_container(controller()->GetContainerWindow()); 127 aura::Window* keyboard_container(controller()->GetContainerWindow());
125 ui::Layer* layer = keyboard_container->layer(); 128 ui::Layer* layer = keyboard_container->layer();
126 129
127 EXPECT_FALSE(keyboard_container->IsVisible()); 130 EXPECT_FALSE(keyboard_container->IsVisible());
128 ShowKeyboard(keyboard_container); 131 ShowKeyboard(keyboard_container);
129 132
130 // Keyboard container and window should immediately become visible before 133 // Keyboard container and window should immediately become visible before
131 // animation starts. 134 // animation starts.
132 EXPECT_TRUE(keyboard_container->IsVisible()); 135 EXPECT_TRUE(keyboard_container->IsVisible());
133 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible()); 136 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible());
134 EXPECT_EQ(0.0, layer->opacity()); 137 EXPECT_EQ(kAnimationStartOrAfterHideOpacity, layer->opacity());
kevers 2014/01/14 19:08:43 Equality test on a floating point value seems susc
bshe 2014/01/15 19:28:13 talked offline. Please see my latest patch. On 20
135 gfx::Transform transform; 138 gfx::Transform transform;
136 transform.Translate(0, proxy()->GetKeyboardWindow()->bounds().height()); 139 transform.Translate(0, proxy()->GetKeyboardWindow()->bounds().height());
137 EXPECT_EQ(transform, layer->transform()); 140 EXPECT_EQ(transform, layer->transform());
138 141
139 RunAnimationForLayer(layer); 142 RunAnimationForLayer(layer);
140 EXPECT_TRUE(keyboard_container->IsVisible()); 143 EXPECT_TRUE(keyboard_container->IsVisible());
141 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible()); 144 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible());
142 EXPECT_EQ(1.0, layer->opacity()); 145 EXPECT_EQ(1.0, layer->opacity());
143 EXPECT_EQ(gfx::Transform(), layer->transform()); 146 EXPECT_EQ(gfx::Transform(), layer->transform());
144 147
145 HideKeyboard(keyboard_container); 148 HideKeyboard(keyboard_container);
146 // Keyboard container and window should be visible before hide animation 149 // Keyboard container window is not visible but its layer should keep visible
147 // finishes. 150 // until hide animation finishes. Otherwise, user can not see hide animation.
148 EXPECT_TRUE(keyboard_container->IsVisible()); 151 EXPECT_FALSE(keyboard_container->IsVisible());
152 EXPECT_TRUE(keyboard_container->layer()->visible());
149 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible()); 153 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible());
150 154
151 RunAnimationForLayer(layer); 155 RunAnimationForLayer(layer);
152 EXPECT_FALSE(keyboard_container->IsVisible()); 156 EXPECT_FALSE(keyboard_container->IsVisible());
157 EXPECT_FALSE(keyboard_container->layer()->visible());
153 EXPECT_FALSE(proxy()->GetKeyboardWindow()->IsVisible()); 158 EXPECT_FALSE(proxy()->GetKeyboardWindow()->IsVisible());
154 EXPECT_EQ(0.0, layer->opacity()); 159 EXPECT_EQ(kAnimationStartOrAfterHideOpacity, layer->opacity());
155 EXPECT_EQ(transform, layer->transform()); 160 EXPECT_EQ(transform, layer->transform());
156 } 161 }
162
163 TEST_F(AshKeyboardControllerProxyTest, VirtualKeyboardContainerShowWhileHide) {
164 // We cannot short-circuit animations for this test.
165 ui::ScopedAnimationDurationScaleMode normal_duration_mode(
166 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
167
168 aura::Window* keyboard_container(controller()->GetContainerWindow());
169 ui::Layer* layer = keyboard_container->layer();
170
171 EXPECT_FALSE(keyboard_container->IsVisible());
172 ShowKeyboard(keyboard_container);
173 RunAnimationForLayer(layer);
174
175 HideKeyboard(keyboard_container);
176
177 // Before hide animation finishes, show keyboard again.
178 ShowKeyboard(keyboard_container);
179 RunAnimationForLayer(layer);
180 EXPECT_TRUE(keyboard_container->IsVisible());
181 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible());
182 EXPECT_EQ(1.0, layer->opacity());
183 EXPECT_EQ(gfx::Transform(), layer->transform());
184 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698