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

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: kevers' review 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"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 aura::Window* keyboard_container(controller()->GetContainerWindow()); 124 aura::Window* keyboard_container(controller()->GetContainerWindow());
125 ui::Layer* layer = keyboard_container->layer(); 125 ui::Layer* layer = keyboard_container->layer();
126 126
127 EXPECT_FALSE(keyboard_container->IsVisible()); 127 EXPECT_FALSE(keyboard_container->IsVisible());
128 ShowKeyboard(keyboard_container); 128 ShowKeyboard(keyboard_container);
129 129
130 // Keyboard container and window should immediately become visible before 130 // Keyboard container and window should immediately become visible before
131 // animation starts. 131 // animation starts.
132 EXPECT_TRUE(keyboard_container->IsVisible()); 132 EXPECT_TRUE(keyboard_container->IsVisible());
133 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible()); 133 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible());
134 EXPECT_EQ(0.0, layer->opacity()); 134 float show_start_opacity = layer->opacity();
135 gfx::Transform transform; 135 gfx::Transform transform;
136 transform.Translate(0, proxy()->GetKeyboardWindow()->bounds().height()); 136 transform.Translate(0, proxy()->GetKeyboardWindow()->bounds().height());
137 EXPECT_EQ(transform, layer->transform()); 137 EXPECT_EQ(transform, layer->transform());
138 138
139 RunAnimationForLayer(layer); 139 RunAnimationForLayer(layer);
140 EXPECT_TRUE(keyboard_container->IsVisible()); 140 EXPECT_TRUE(keyboard_container->IsVisible());
141 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible()); 141 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible());
142 float show_end_opacity = layer->opacity();
143 EXPECT_LT(show_start_opacity, show_end_opacity);
144 EXPECT_EQ(gfx::Transform(), layer->transform());
145
146 HideKeyboard(keyboard_container);
147 // Keyboard container window is not visible but its layer should keep visible
148 // until hide animation finishes. Otherwise, user can not see hide animation.
149 EXPECT_FALSE(keyboard_container->IsVisible());
150 EXPECT_TRUE(keyboard_container->layer()->visible());
151 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible());
152 float hide_start_opacity = layer->opacity();
153
154 RunAnimationForLayer(layer);
155 EXPECT_FALSE(keyboard_container->IsVisible());
156 EXPECT_FALSE(keyboard_container->layer()->visible());
157 EXPECT_FALSE(proxy()->GetKeyboardWindow()->IsVisible());
158 float hide_end_opacity = layer->opacity();
159 EXPECT_GT(hide_start_opacity, hide_end_opacity);
160 EXPECT_EQ(transform, layer->transform());
161 }
162
163 // Test for crbug.com/333284.
164 TEST_F(AshKeyboardControllerProxyTest, VirtualKeyboardContainerShowWhileHide) {
165 // We cannot short-circuit animations for this test.
166 ui::ScopedAnimationDurationScaleMode normal_duration_mode(
167 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
168
169 aura::Window* keyboard_container(controller()->GetContainerWindow());
170 ui::Layer* layer = keyboard_container->layer();
171
172 EXPECT_FALSE(keyboard_container->IsVisible());
173 ShowKeyboard(keyboard_container);
174 RunAnimationForLayer(layer);
175
176 HideKeyboard(keyboard_container);
177 // Before hide animation finishes, show keyboard again.
178 ShowKeyboard(keyboard_container);
179
180 RunAnimationForLayer(layer);
181 EXPECT_TRUE(keyboard_container->IsVisible());
182 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible());
142 EXPECT_EQ(1.0, layer->opacity()); 183 EXPECT_EQ(1.0, layer->opacity());
143 EXPECT_EQ(gfx::Transform(), layer->transform()); 184 EXPECT_EQ(gfx::Transform(), layer->transform());
144
145 HideKeyboard(keyboard_container);
146 // Keyboard container and window should be visible before hide animation
147 // finishes.
148 EXPECT_TRUE(keyboard_container->IsVisible());
149 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible());
150
151 RunAnimationForLayer(layer);
152 EXPECT_FALSE(keyboard_container->IsVisible());
153 EXPECT_FALSE(proxy()->GetKeyboardWindow()->IsVisible());
154 EXPECT_EQ(0.0, layer->opacity());
155 EXPECT_EQ(transform, layer->transform());
156 } 185 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698