Index: chrome/browser/ui/ash/ash_keyboard_controller_proxy_unittest.cc |
diff --git a/chrome/browser/ui/ash/ash_keyboard_controller_proxy_unittest.cc b/chrome/browser/ui/ash/ash_keyboard_controller_proxy_unittest.cc |
index 4f4da622d0a6af17a49ea7ee7c29df5d394037de..4de7f199d13fab327f54b1551249d255339ca38c 100644 |
--- a/chrome/browser/ui/ash/ash_keyboard_controller_proxy_unittest.cc |
+++ b/chrome/browser/ui/ash/ash_keyboard_controller_proxy_unittest.cc |
@@ -16,6 +16,9 @@ |
namespace { |
+// Keep in sync with the one in ash_keyboard_controller_proxy.cc |
+const float kAnimationStartOrAfterHideOpacity = 0.2f; |
+ |
// Steps a layer animation until it is completed. Animations must be enabled. |
void RunAnimationForLayer(ui::Layer* layer) { |
// Animations must be enabled for stepping to work. |
@@ -131,7 +134,7 @@ TEST_F(AshKeyboardControllerProxyTest, VirtualKeyboardContainerAnimation) { |
// animation starts. |
EXPECT_TRUE(keyboard_container->IsVisible()); |
EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible()); |
- EXPECT_EQ(0.0, layer->opacity()); |
+ 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
|
gfx::Transform transform; |
transform.Translate(0, proxy()->GetKeyboardWindow()->bounds().height()); |
EXPECT_EQ(transform, layer->transform()); |
@@ -143,14 +146,39 @@ TEST_F(AshKeyboardControllerProxyTest, VirtualKeyboardContainerAnimation) { |
EXPECT_EQ(gfx::Transform(), layer->transform()); |
HideKeyboard(keyboard_container); |
- // Keyboard container and window should be visible before hide animation |
- // finishes. |
- EXPECT_TRUE(keyboard_container->IsVisible()); |
+ // Keyboard container window is not visible but its layer should keep visible |
+ // until hide animation finishes. Otherwise, user can not see hide animation. |
+ EXPECT_FALSE(keyboard_container->IsVisible()); |
+ EXPECT_TRUE(keyboard_container->layer()->visible()); |
EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible()); |
RunAnimationForLayer(layer); |
EXPECT_FALSE(keyboard_container->IsVisible()); |
+ EXPECT_FALSE(keyboard_container->layer()->visible()); |
EXPECT_FALSE(proxy()->GetKeyboardWindow()->IsVisible()); |
- EXPECT_EQ(0.0, layer->opacity()); |
+ EXPECT_EQ(kAnimationStartOrAfterHideOpacity, layer->opacity()); |
EXPECT_EQ(transform, layer->transform()); |
} |
+ |
+TEST_F(AshKeyboardControllerProxyTest, VirtualKeyboardContainerShowWhileHide) { |
+ // We cannot short-circuit animations for this test. |
+ ui::ScopedAnimationDurationScaleMode normal_duration_mode( |
+ ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); |
+ |
+ aura::Window* keyboard_container(controller()->GetContainerWindow()); |
+ ui::Layer* layer = keyboard_container->layer(); |
+ |
+ EXPECT_FALSE(keyboard_container->IsVisible()); |
+ ShowKeyboard(keyboard_container); |
+ RunAnimationForLayer(layer); |
+ |
+ HideKeyboard(keyboard_container); |
+ |
+ // Before hide animation finishes, show keyboard again. |
+ ShowKeyboard(keyboard_container); |
+ RunAnimationForLayer(layer); |
+ EXPECT_TRUE(keyboard_container->IsVisible()); |
+ EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible()); |
+ EXPECT_EQ(1.0, layer->opacity()); |
+ EXPECT_EQ(gfx::Transform(), layer->transform()); |
+} |