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

Unified 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 side-by-side diff with in-line comments
Download patch
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());
+}

Powered by Google App Engine
This is Rietveld 408576698