1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/keyboard/keyboard_controller.h"
8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/aura/client/focus_client.h"
13 #include "ui/aura/layout_manager.h"
14 #include "ui/aura/test/aura_test_helper.h"
15 #include "ui/aura/test/test_window_delegate.h"
16 #include "ui/aura/window.h"
17 #include "ui/aura/window_event_dispatcher.h"
18 #include "ui/base/ime/dummy_text_input_client.h"
19 #include "ui/base/ime/input_method.h"
20 #include "ui/base/ime/input_method_factory.h"
21 #include "ui/base/ime/text_input_client.h"
22 #include "ui/base/ime/text_input_focus_manager.h"
23 #include "ui/base/ui_base_switches_util.h"
24 #include "ui/compositor/compositor.h"
25 #include "ui/compositor/layer_type.h"
26 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
27 #include "ui/compositor/test/context_factories_for_test.h"
28 #include "ui/compositor/test/layer_animator_test_controller.h"
29 #include "ui/events/event_utils.h"
30 #include "ui/events/test/event_generator.h"
31 #include "ui/gfx/geometry/rect.h"
32 #include "ui/keyboard/keyboard_controller_observer.h"
33 #include "ui/keyboard/keyboard_controller_proxy.h"
34 #include "ui/keyboard/keyboard_util.h"
35 #include "ui/wm/core/default_activation_client.h"
40 // Steps a layer animation until it is completed. Animations must be enabled.
41 void RunAnimationForLayer(ui::Layer
* layer
) {
42 // Animations must be enabled for stepping to work.
43 ASSERT_NE(ui::ScopedAnimationDurationScaleMode::duration_scale_mode(),
44 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION
);
46 ui::LayerAnimatorTestController
controller(layer
->GetAnimator());
47 // Multiple steps are required to complete complex animations.
48 // TODO(vollick): This should not be necessary. crbug.com/154017
49 while (controller
.animator()->is_animating()) {
50 controller
.StartThreadedAnimationsIfNeeded();
51 base::TimeTicks step_time
= controller
.animator()->last_step_time();
52 controller
.animator()->Step(step_time
+
53 base::TimeDelta::FromMilliseconds(1000));
57 // An event handler that focuses a window when it is clicked/touched on. This is
58 // used to match the focus manger behaviour in ash and views.
59 class TestFocusController
: public ui::EventHandler
{
61 explicit TestFocusController(aura::Window
* root
)
63 root_
->AddPreTargetHandler(this);
66 ~TestFocusController() override
{ root_
->RemovePreTargetHandler(this); }
69 // Overridden from ui::EventHandler:
70 void OnEvent(ui::Event
* event
) override
{
71 aura::Window
* target
= static_cast<aura::Window
*>(event
->target());
72 if (event
->type() == ui::ET_MOUSE_PRESSED
||
73 event
->type() == ui::ET_TOUCH_PRESSED
) {
74 aura::client::GetFocusClient(target
)->FocusWindow(target
);
79 DISALLOW_COPY_AND_ASSIGN(TestFocusController
);
82 class TestKeyboardControllerProxy
: public KeyboardControllerProxy
{
84 TestKeyboardControllerProxy()
85 : KeyboardControllerProxy(nullptr),
87 ui::CreateInputMethod(nullptr, gfx::kNullAcceleratedWidget
)) {}
89 ~TestKeyboardControllerProxy() override
{
90 // Destroy the window before the delegate.
94 // Overridden from KeyboardControllerProxy:
95 bool HasKeyboardWindow() const override
{ return window_
; }
96 aura::Window
* GetKeyboardWindow() override
{
98 window_
.reset(new aura::Window(&delegate_
));
99 window_
->Init(ui::LAYER_NOT_DRAWN
);
100 window_
->set_owned_by_parent(false);
102 return window_
.get();
104 ui::InputMethod
* GetInputMethod() override
{ return input_method_
.get(); }
105 void RequestAudioInput(
106 content::WebContents
* web_contents
,
107 const content::MediaStreamRequest
& request
,
108 const content::MediaResponseCallback
& callback
) override
{
111 void LoadSystemKeyboard() override
{};
112 void ReloadKeyboardIfNeeded() override
{};
115 scoped_ptr
<aura::Window
> window_
;
116 aura::test::TestWindowDelegate delegate_
;
117 scoped_ptr
<ui::InputMethod
> input_method_
;
119 DISALLOW_COPY_AND_ASSIGN(TestKeyboardControllerProxy
);
122 // Keeps a count of all the events a window receives.
123 class EventObserver
: public ui::EventHandler
{
126 ~EventObserver() override
{}
128 int GetEventCount(ui::EventType type
) {
129 return event_counts_
[type
];
133 // Overridden from ui::EventHandler:
134 void OnEvent(ui::Event
* event
) override
{
135 ui::EventHandler::OnEvent(event
);
136 event_counts_
[event
->type()]++;
139 std::map
<ui::EventType
, int> event_counts_
;
140 DISALLOW_COPY_AND_ASSIGN(EventObserver
);
143 class KeyboardContainerObserver
: public aura::WindowObserver
{
145 explicit KeyboardContainerObserver(aura::Window
* window
) : window_(window
) {
146 window_
->AddObserver(this);
148 ~KeyboardContainerObserver() override
{ window_
->RemoveObserver(this); }
151 void OnWindowVisibilityChanged(aura::Window
* window
, bool visible
) override
{
153 base::MessageLoop::current()->Quit();
156 aura::Window
* window_
;
158 DISALLOW_COPY_AND_ASSIGN(KeyboardContainerObserver
);
163 class KeyboardControllerTest
: public testing::Test
{
165 KeyboardControllerTest() {}
166 ~KeyboardControllerTest() override
{}
168 void SetUp() override
{
169 // The ContextFactory must exist before any Compositors are created.
170 bool enable_pixel_output
= false;
171 ui::ContextFactory
* context_factory
=
172 ui::InitializeContextFactoryForTests(enable_pixel_output
);
174 aura_test_helper_
.reset(new aura::test::AuraTestHelper(&message_loop_
));
175 aura_test_helper_
->SetUp(context_factory
);
176 new wm::DefaultActivationClient(aura_test_helper_
->root_window());
177 ui::SetUpInputMethodFactoryForTesting();
178 if (::switches::IsTextInputFocusManagerEnabled())
179 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(NULL
);
180 focus_controller_
.reset(new TestFocusController(root_window()));
181 proxy_
= new TestKeyboardControllerProxy();
182 controller_
.reset(new KeyboardController(proxy_
));
185 void TearDown() override
{
187 focus_controller_
.reset();
188 if (::switches::IsTextInputFocusManagerEnabled())
189 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(NULL
);
190 aura_test_helper_
->TearDown();
191 ui::TerminateContextFactoryForTests();
194 aura::Window
* root_window() { return aura_test_helper_
->root_window(); }
195 KeyboardControllerProxy
* proxy() { return proxy_
; }
196 KeyboardController
* controller() { return controller_
.get(); }
198 void ShowKeyboard() {
199 test_text_input_client_
.reset(
200 new ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT
));
201 SetFocus(test_text_input_client_
.get());
205 void SetFocus(ui::TextInputClient
* client
) {
206 ui::InputMethod
* input_method
= proxy()->GetInputMethod();
207 if (::switches::IsTextInputFocusManagerEnabled()) {
208 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(client
);
209 input_method
->OnTextInputTypeChanged(client
);
211 input_method
->SetFocusedTextInputClient(client
);
213 if (client
&& client
->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE
) {
214 input_method
->ShowImeIfNeeded();
215 if (proxy_
->GetKeyboardWindow()->bounds().height() == 0) {
216 // Set initial bounds for test keyboard window.
217 proxy_
->GetKeyboardWindow()->SetBounds(
218 KeyboardBoundsFromWindowBounds(
219 controller()->GetContainerWindow()->bounds(), 100));
224 bool WillHideKeyboard() {
225 return controller_
->WillHideKeyboard();
228 bool ShouldEnableInsets(aura::Window
* window
) {
229 return controller_
->ShouldEnableInsets(window
);
232 base::MessageLoopForUI message_loop_
;
233 scoped_ptr
<aura::test::AuraTestHelper
> aura_test_helper_
;
234 scoped_ptr
<TestFocusController
> focus_controller_
;
237 KeyboardControllerProxy
* proxy_
;
238 scoped_ptr
<KeyboardController
> controller_
;
239 scoped_ptr
<ui::TextInputClient
> test_text_input_client_
;
240 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerTest
);
243 TEST_F(KeyboardControllerTest
, KeyboardSize
) {
244 aura::Window
* container(controller()->GetContainerWindow());
245 aura::Window
* keyboard(proxy()->GetKeyboardWindow());
246 container
->SetBounds(gfx::Rect(0, 0, 200, 100));
248 container
->AddChild(keyboard
);
249 const gfx::Rect
& before_bounds
= keyboard
->bounds();
250 // The initial keyboard should be positioned at the bottom of container and
252 ASSERT_EQ(gfx::Rect(0, 100, 200, 0), before_bounds
);
254 gfx::Rect
new_bounds(
255 before_bounds
.x(), before_bounds
.y() - 50,
256 before_bounds
.width(), 50);
258 keyboard
->SetBounds(new_bounds
);
259 ASSERT_EQ(new_bounds
, keyboard
->bounds());
261 // Mock a screen rotation.
262 container
->SetBounds(gfx::Rect(0, 0, 100, 200));
263 // The above call should resize keyboard to new width while keeping the old
265 ASSERT_EQ(gfx::Rect(0, 150, 100, 50), keyboard
->bounds());
268 // Tests that tapping/clicking inside the keyboard does not give it focus.
269 TEST_F(KeyboardControllerTest
, ClickDoesNotFocusKeyboard
) {
270 const gfx::Rect
& root_bounds
= root_window()->bounds();
271 aura::test::EventCountDelegate delegate
;
272 scoped_ptr
<aura::Window
> window(new aura::Window(&delegate
));
273 window
->Init(ui::LAYER_NOT_DRAWN
);
274 window
->SetBounds(root_bounds
);
275 root_window()->AddChild(window
.get());
279 aura::Window
* keyboard_container(controller()->GetContainerWindow());
280 keyboard_container
->SetBounds(root_bounds
);
282 root_window()->AddChild(keyboard_container
);
283 keyboard_container
->Show();
287 EXPECT_TRUE(window
->IsVisible());
288 EXPECT_TRUE(keyboard_container
->IsVisible());
289 EXPECT_TRUE(window
->HasFocus());
290 EXPECT_FALSE(keyboard_container
->HasFocus());
292 // Click on the keyboard. Make sure the keyboard receives the event, but does
294 EventObserver observer
;
295 keyboard_container
->AddPreTargetHandler(&observer
);
297 ui::test::EventGenerator
generator(root_window());
298 generator
.MoveMouseTo(proxy()->GetKeyboardWindow()->bounds().CenterPoint());
299 generator
.ClickLeftButton();
300 EXPECT_TRUE(window
->HasFocus());
301 EXPECT_FALSE(keyboard_container
->HasFocus());
302 EXPECT_EQ("0 0", delegate
.GetMouseButtonCountsAndReset());
303 EXPECT_EQ(1, observer
.GetEventCount(ui::ET_MOUSE_PRESSED
));
304 EXPECT_EQ(1, observer
.GetEventCount(ui::ET_MOUSE_RELEASED
));
306 // Click outside of the keyboard. It should reach the window behind.
307 generator
.MoveMouseTo(gfx::Point());
308 generator
.ClickLeftButton();
309 EXPECT_EQ("1 1", delegate
.GetMouseButtonCountsAndReset());
310 keyboard_container
->RemovePreTargetHandler(&observer
);
313 TEST_F(KeyboardControllerTest
, EventHitTestingInContainer
) {
314 const gfx::Rect
& root_bounds
= root_window()->bounds();
315 aura::test::EventCountDelegate delegate
;
316 scoped_ptr
<aura::Window
> window(new aura::Window(&delegate
));
317 window
->Init(ui::LAYER_NOT_DRAWN
);
318 window
->SetBounds(root_bounds
);
319 root_window()->AddChild(window
.get());
323 aura::Window
* keyboard_container(controller()->GetContainerWindow());
324 keyboard_container
->SetBounds(root_bounds
);
326 root_window()->AddChild(keyboard_container
);
327 keyboard_container
->Show();
331 EXPECT_TRUE(window
->IsVisible());
332 EXPECT_TRUE(keyboard_container
->IsVisible());
333 EXPECT_TRUE(window
->HasFocus());
334 EXPECT_FALSE(keyboard_container
->HasFocus());
336 // Make sure hit testing works correctly while the keyboard is visible.
337 aura::Window
* keyboard_window
= proxy()->GetKeyboardWindow();
338 ui::EventTarget
* root
= root_window();
339 ui::EventTargeter
* targeter
= root
->GetEventTargeter();
340 gfx::Point location
= keyboard_window
->bounds().CenterPoint();
341 ui::MouseEvent
mouse1(ui::ET_MOUSE_MOVED
, location
, location
,
342 ui::EventTimeForNow(), ui::EF_NONE
, ui::EF_NONE
);
343 EXPECT_EQ(keyboard_window
, targeter
->FindTargetForEvent(root
, &mouse1
));
345 location
.set_y(keyboard_window
->bounds().y() - 5);
346 ui::MouseEvent
mouse2(ui::ET_MOUSE_MOVED
, location
, location
,
347 ui::EventTimeForNow(), ui::EF_NONE
, ui::EF_NONE
);
348 EXPECT_EQ(window
.get(), targeter
->FindTargetForEvent(root
, &mouse2
));
351 TEST_F(KeyboardControllerTest
, KeyboardWindowCreation
) {
352 const gfx::Rect
& root_bounds
= root_window()->bounds();
353 aura::test::EventCountDelegate delegate
;
354 scoped_ptr
<aura::Window
> window(new aura::Window(&delegate
));
355 window
->Init(ui::LAYER_NOT_DRAWN
);
356 window
->SetBounds(root_bounds
);
357 root_window()->AddChild(window
.get());
361 aura::Window
* keyboard_container(controller()->GetContainerWindow());
362 keyboard_container
->SetBounds(root_bounds
);
364 root_window()->AddChild(keyboard_container
);
365 keyboard_container
->Show();
367 EXPECT_FALSE(proxy()->HasKeyboardWindow());
369 ui::EventTarget
* root
= root_window();
370 ui::EventTargeter
* targeter
= root
->GetEventTargeter();
371 gfx::Point
location(root_window()->bounds().width() / 2,
372 root_window()->bounds().height() - 10);
373 ui::MouseEvent
mouse(ui::ET_MOUSE_MOVED
, location
, location
,
374 ui::EventTimeForNow(), ui::EF_NONE
, ui::EF_NONE
);
375 EXPECT_EQ(window
.get(), targeter
->FindTargetForEvent(root
, &mouse
));
376 EXPECT_FALSE(proxy()->HasKeyboardWindow());
379 controller()->GetContainerWindow(),
380 controller()->GetContainerWindow()->GetEventHandlerForPoint(location
));
381 EXPECT_FALSE(proxy()->HasKeyboardWindow());
384 TEST_F(KeyboardControllerTest
, VisibilityChangeWithTextInputTypeChange
) {
385 const gfx::Rect
& root_bounds
= root_window()->bounds();
387 ui::DummyTextInputClient
input_client_0(ui::TEXT_INPUT_TYPE_TEXT
);
388 ui::DummyTextInputClient
input_client_1(ui::TEXT_INPUT_TYPE_TEXT
);
389 ui::DummyTextInputClient
input_client_2(ui::TEXT_INPUT_TYPE_TEXT
);
390 ui::DummyTextInputClient
no_input_client_0(ui::TEXT_INPUT_TYPE_NONE
);
391 ui::DummyTextInputClient
no_input_client_1(ui::TEXT_INPUT_TYPE_NONE
);
393 aura::Window
* keyboard_container(controller()->GetContainerWindow());
394 scoped_ptr
<KeyboardContainerObserver
> keyboard_container_observer(
395 new KeyboardContainerObserver(keyboard_container
));
396 keyboard_container
->SetBounds(root_bounds
);
397 root_window()->AddChild(keyboard_container
);
399 SetFocus(&input_client_0
);
401 EXPECT_TRUE(keyboard_container
->IsVisible());
403 SetFocus(&no_input_client_0
);
404 // Keyboard should not immediately hide itself. It is delayed to avoid layout
405 // flicker when the focus of input field quickly change.
406 EXPECT_TRUE(keyboard_container
->IsVisible());
407 EXPECT_TRUE(WillHideKeyboard());
408 // Wait for hide keyboard to finish.
409 base::MessageLoop::current()->Run();
410 EXPECT_FALSE(keyboard_container
->IsVisible());
412 SetFocus(&input_client_1
);
413 EXPECT_TRUE(keyboard_container
->IsVisible());
415 // Schedule to hide keyboard.
416 SetFocus(&no_input_client_1
);
417 EXPECT_TRUE(WillHideKeyboard());
418 // Cancel keyboard hide.
419 SetFocus(&input_client_2
);
421 EXPECT_FALSE(WillHideKeyboard());
422 EXPECT_TRUE(keyboard_container
->IsVisible());
425 // Test to prevent spurious overscroll boxes when changing tabs during keyboard
426 // hide. Refer to crbug.com/401670 for more context.
427 TEST_F(KeyboardControllerTest
, CheckOverscrollInsetDuringVisibilityChange
) {
428 const gfx::Rect
& root_bounds
= root_window()->bounds();
430 ui::DummyTextInputClient
input_client(ui::TEXT_INPUT_TYPE_TEXT
);
431 ui::DummyTextInputClient
no_input_client(ui::TEXT_INPUT_TYPE_NONE
);
433 aura::Window
* keyboard_container(controller()->GetContainerWindow());
434 keyboard_container
->SetBounds(root_bounds
);
435 root_window()->AddChild(keyboard_container
);
437 // Enable touch keyboard / overscroll mode to test insets.
438 keyboard::SetTouchKeyboardEnabled(true);
439 EXPECT_TRUE(keyboard::IsKeyboardOverscrollEnabled());
441 SetFocus(&input_client
);
442 SetFocus(&no_input_client
);
443 // Insets should not be enabled for new windows while keyboard is in the
444 // process of hiding when overscroll is enabled.
445 EXPECT_FALSE(ShouldEnableInsets(proxy()->GetKeyboardWindow()));
446 // Cancel keyboard hide.
447 SetFocus(&input_client
);
448 // Insets should be enabled for new windows as hide was cancelled.
449 EXPECT_TRUE(ShouldEnableInsets(proxy()->GetKeyboardWindow()));
452 TEST_F(KeyboardControllerTest
, AlwaysVisibleWhenLocked
) {
453 const gfx::Rect
& root_bounds
= root_window()->bounds();
455 ui::DummyTextInputClient
input_client_0(ui::TEXT_INPUT_TYPE_TEXT
);
456 ui::DummyTextInputClient
input_client_1(ui::TEXT_INPUT_TYPE_TEXT
);
457 ui::DummyTextInputClient
no_input_client_0(ui::TEXT_INPUT_TYPE_NONE
);
458 ui::DummyTextInputClient
no_input_client_1(ui::TEXT_INPUT_TYPE_NONE
);
460 aura::Window
* keyboard_container(controller()->GetContainerWindow());
461 scoped_ptr
<KeyboardContainerObserver
> keyboard_container_observer(
462 new KeyboardContainerObserver(keyboard_container
));
463 keyboard_container
->SetBounds(root_bounds
);
464 root_window()->AddChild(keyboard_container
);
466 SetFocus(&input_client_0
);
468 EXPECT_TRUE(keyboard_container
->IsVisible());
471 controller()->set_lock_keyboard(true);
473 SetFocus(&no_input_client_0
);
474 // Keyboard should not try to hide itself as it is locked.
475 EXPECT_TRUE(keyboard_container
->IsVisible());
476 EXPECT_FALSE(WillHideKeyboard());
478 SetFocus(&input_client_1
);
479 EXPECT_TRUE(keyboard_container
->IsVisible());
482 controller()->set_lock_keyboard(false);
484 // Keyboard should hide when focus on no input client.
485 SetFocus(&no_input_client_1
);
486 EXPECT_TRUE(WillHideKeyboard());
488 // Wait for hide keyboard to finish.
489 base::MessageLoop::current()->Run();
490 EXPECT_FALSE(keyboard_container
->IsVisible());
493 class KeyboardControllerAnimationTest
: public KeyboardControllerTest
,
494 public KeyboardControllerObserver
{
496 KeyboardControllerAnimationTest() {}
497 ~KeyboardControllerAnimationTest() override
{}
499 void SetUp() override
{
500 // We cannot short-circuit animations for this test.
501 ui::ScopedAnimationDurationScaleMode
test_duration_mode(
502 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION
);
504 KeyboardControllerTest::SetUp();
506 const gfx::Rect
& root_bounds
= root_window()->bounds();
507 keyboard_container()->SetBounds(root_bounds
);
508 root_window()->AddChild(keyboard_container());
509 controller()->AddObserver(this);
512 void TearDown() override
{
513 controller()->RemoveObserver(this);
514 KeyboardControllerTest::TearDown();
518 // KeyboardControllerObserver overrides
519 void OnKeyboardBoundsChanging(const gfx::Rect
& new_bounds
) override
{
520 notified_bounds_
= new_bounds
;
523 const gfx::Rect
& notified_bounds() { return notified_bounds_
; }
525 aura::Window
* keyboard_container() {
526 return controller()->GetContainerWindow();
529 aura::Window
* keyboard_window() {
530 return proxy()->GetKeyboardWindow();
534 gfx::Rect notified_bounds_
;
536 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerAnimationTest
);
539 // Tests virtual keyboard has correct show and hide animation.
540 TEST_F(KeyboardControllerAnimationTest
, ContainerAnimation
) {
541 ui::Layer
* layer
= keyboard_container()->layer();
544 // Keyboard container and window should immediately become visible before
546 EXPECT_TRUE(keyboard_container()->IsVisible());
547 EXPECT_TRUE(keyboard_window()->IsVisible());
548 float show_start_opacity
= layer
->opacity();
549 gfx::Transform transform
;
550 transform
.Translate(0, kAnimationDistance
);
551 EXPECT_EQ(transform
, layer
->transform());
552 EXPECT_EQ(gfx::Rect(), notified_bounds());
554 RunAnimationForLayer(layer
);
555 EXPECT_TRUE(keyboard_container()->IsVisible());
556 EXPECT_TRUE(keyboard_window()->IsVisible());
557 float show_end_opacity
= layer
->opacity();
558 EXPECT_LT(show_start_opacity
, show_end_opacity
);
559 EXPECT_EQ(gfx::Transform(), layer
->transform());
560 // KeyboardController should notify the bounds of keyboard window to its
561 // observers after show animation finished.
562 EXPECT_EQ(keyboard_window()->bounds(), notified_bounds());
564 // Directly hide keyboard without delay.
565 controller()->HideKeyboard(KeyboardController::HIDE_REASON_AUTOMATIC
);
566 EXPECT_TRUE(keyboard_container()->IsVisible());
567 EXPECT_TRUE(keyboard_container()->layer()->visible());
568 EXPECT_TRUE(keyboard_window()->IsVisible());
569 float hide_start_opacity
= layer
->opacity();
570 // KeyboardController should notify the bounds of keyboard window to its
571 // observers before hide animation starts.
572 EXPECT_EQ(gfx::Rect(), notified_bounds());
574 RunAnimationForLayer(layer
);
575 EXPECT_FALSE(keyboard_container()->IsVisible());
576 EXPECT_FALSE(keyboard_container()->layer()->visible());
577 EXPECT_FALSE(keyboard_window()->IsVisible());
578 float hide_end_opacity
= layer
->opacity();
579 EXPECT_GT(hide_start_opacity
, hide_end_opacity
);
580 EXPECT_EQ(transform
, layer
->transform());
581 EXPECT_EQ(gfx::Rect(), notified_bounds());
584 // Show keyboard during keyboard hide animation should abort the hide animation
585 // and the keyboard should animate in.
586 // Test for crbug.com/333284.
587 TEST_F(KeyboardControllerAnimationTest
, ContainerShowWhileHide
) {
588 ui::Layer
* layer
= keyboard_container()->layer();
590 RunAnimationForLayer(layer
);
592 controller()->HideKeyboard(KeyboardController::HIDE_REASON_AUTOMATIC
);
593 // Before hide animation finishes, show keyboard again.
595 RunAnimationForLayer(layer
);
596 EXPECT_TRUE(keyboard_container()->IsVisible());
597 EXPECT_TRUE(keyboard_window()->IsVisible());
598 EXPECT_EQ(1.0, layer
->opacity());
599 EXPECT_EQ(gfx::Transform(), layer
->transform());
602 } // namespace keyboard