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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 aura::Window* keyboard_container(controller()->GetContainerWindow()); | 126 aura::Window* keyboard_container(controller()->GetContainerWindow()); |
127 ui::Layer* layer = keyboard_container->layer(); | 127 ui::Layer* layer = keyboard_container->layer(); |
128 | 128 |
129 EXPECT_FALSE(keyboard_container->IsVisible()); | 129 EXPECT_FALSE(keyboard_container->IsVisible()); |
130 ShowKeyboard(keyboard_container); | 130 ShowKeyboard(keyboard_container); |
131 | 131 |
132 // Keyboard container and window should immediately become visible before | 132 // Keyboard container and window should immediately become visible before |
133 // animation starts. | 133 // animation starts. |
134 EXPECT_TRUE(keyboard_container->IsVisible()); | 134 EXPECT_TRUE(keyboard_container->IsVisible()); |
135 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible()); | 135 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible()); |
136 EXPECT_EQ(0.0, layer->opacity()); | 136 float show_start_opacity = layer->opacity(); |
137 gfx::Transform transform; | 137 gfx::Transform transform; |
138 transform.Translate(0, proxy()->GetKeyboardWindow()->bounds().height()); | 138 transform.Translate(0, proxy()->GetKeyboardWindow()->bounds().height()); |
139 EXPECT_EQ(transform, layer->transform()); | 139 EXPECT_EQ(transform, layer->transform()); |
140 | 140 |
141 RunAnimationForLayer(layer); | 141 RunAnimationForLayer(layer); |
142 EXPECT_TRUE(keyboard_container->IsVisible()); | 142 EXPECT_TRUE(keyboard_container->IsVisible()); |
143 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible()); | 143 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible()); |
| 144 float show_end_opacity = layer->opacity(); |
| 145 EXPECT_LT(show_start_opacity, show_end_opacity); |
| 146 EXPECT_EQ(gfx::Transform(), layer->transform()); |
| 147 |
| 148 HideKeyboard(keyboard_container); |
| 149 EXPECT_TRUE(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()); |
144 EXPECT_EQ(1.0, layer->opacity()); | 183 EXPECT_EQ(1.0, layer->opacity()); |
145 EXPECT_EQ(gfx::Transform(), layer->transform()); | 184 EXPECT_EQ(gfx::Transform(), layer->transform()); |
146 | |
147 HideKeyboard(keyboard_container); | |
148 // Keyboard container and window should be visible before hide animation | |
149 // finishes. | |
150 EXPECT_TRUE(keyboard_container->IsVisible()); | |
151 EXPECT_TRUE(proxy()->GetKeyboardWindow()->IsVisible()); | |
152 | |
153 RunAnimationForLayer(layer); | |
154 EXPECT_FALSE(keyboard_container->IsVisible()); | |
155 EXPECT_FALSE(proxy()->GetKeyboardWindow()->IsVisible()); | |
156 EXPECT_EQ(0.0, layer->opacity()); | |
157 EXPECT_EQ(transform, layer->transform()); | |
158 } | 185 } |
OLD | NEW |