OLD | NEW |
---|---|
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 Loading... | |
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 EXPECT_TRUE(keyboard_container->IsVisible()); | |
148 EXPECT_TRUE(keyboard_container->layer()->visible()); | |
149 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible()); | |
150 float hide_start_opacity = layer->opacity(); | |
151 | |
152 RunAnimationForLayer(layer); | |
153 EXPECT_FALSE(keyboard_container->IsVisible()); | |
154 EXPECT_FALSE(keyboard_container->layer()->visible()); | |
155 EXPECT_FALSE(proxy()->GetKeyboardWindow()->IsVisible()); | |
156 float hide_end_opacity = layer->opacity(); | |
157 EXPECT_GT(hide_start_opacity, hide_end_opacity); | |
158 EXPECT_EQ(transform, layer->transform()); | |
159 } | |
160 | |
161 // Test for crbug.com/333284. | |
James Cook
2014/01/16 17:55:03
It's great that you wrote a test specifically for
| |
162 TEST_F(AshKeyboardControllerProxyTest, VirtualKeyboardContainerShowWhileHide) { | |
163 // We cannot short-circuit animations for this test. | |
164 ui::ScopedAnimationDurationScaleMode normal_duration_mode( | |
165 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | |
166 | |
167 aura::Window* keyboard_container(controller()->GetContainerWindow()); | |
168 ui::Layer* layer = keyboard_container->layer(); | |
169 | |
170 EXPECT_FALSE(keyboard_container->IsVisible()); | |
171 ShowKeyboard(keyboard_container); | |
172 RunAnimationForLayer(layer); | |
173 | |
174 HideKeyboard(keyboard_container); | |
175 // Before hide animation finishes, show keyboard again. | |
176 ShowKeyboard(keyboard_container); | |
177 | |
178 RunAnimationForLayer(layer); | |
179 EXPECT_TRUE(keyboard_container->IsVisible()); | |
180 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible()); | |
142 EXPECT_EQ(1.0, layer->opacity()); | 181 EXPECT_EQ(1.0, layer->opacity()); |
143 EXPECT_EQ(gfx::Transform(), layer->transform()); | 182 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 } | 183 } |
OLD | NEW |