[Telemetry] Split top_25 to top_25_smooth and top_25_repaint
[chromium-blink-merge.git] / ui / keyboard / keyboard_controller_unittest.cc
blobb2db69c76831ca201348c10fde2ac2f7d1a8d38c
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"
7 #include "base/bind.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/test/event_generator.h"
30 #include "ui/gfx/geometry/rect.h"
31 #include "ui/keyboard/keyboard_controller_observer.h"
32 #include "ui/keyboard/keyboard_controller_proxy.h"
33 #include "ui/keyboard/keyboard_util.h"
34 #include "ui/wm/core/default_activation_client.h"
36 namespace keyboard {
37 namespace {
39 // Steps a layer animation until it is completed. Animations must be enabled.
40 void RunAnimationForLayer(ui::Layer* layer) {
41 // Animations must be enabled for stepping to work.
42 ASSERT_NE(ui::ScopedAnimationDurationScaleMode::duration_scale_mode(),
43 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION);
45 ui::LayerAnimatorTestController controller(layer->GetAnimator());
46 // Multiple steps are required to complete complex animations.
47 // TODO(vollick): This should not be necessary. crbug.com/154017
48 while (controller.animator()->is_animating()) {
49 controller.StartThreadedAnimationsIfNeeded();
50 base::TimeTicks step_time = controller.animator()->last_step_time();
51 controller.animator()->Step(step_time +
52 base::TimeDelta::FromMilliseconds(1000));
56 // An event handler that focuses a window when it is clicked/touched on. This is
57 // used to match the focus manger behaviour in ash and views.
58 class TestFocusController : public ui::EventHandler {
59 public:
60 explicit TestFocusController(aura::Window* root)
61 : root_(root) {
62 root_->AddPreTargetHandler(this);
65 ~TestFocusController() override { root_->RemovePreTargetHandler(this); }
67 private:
68 // Overridden from ui::EventHandler:
69 void OnEvent(ui::Event* event) override {
70 aura::Window* target = static_cast<aura::Window*>(event->target());
71 if (event->type() == ui::ET_MOUSE_PRESSED ||
72 event->type() == ui::ET_TOUCH_PRESSED) {
73 aura::client::GetFocusClient(target)->FocusWindow(target);
77 aura::Window* root_;
78 DISALLOW_COPY_AND_ASSIGN(TestFocusController);
81 class TestKeyboardControllerProxy : public KeyboardControllerProxy {
82 public:
83 TestKeyboardControllerProxy()
84 : input_method_(
85 ui::CreateInputMethod(NULL, gfx::kNullAcceleratedWidget)) {}
87 ~TestKeyboardControllerProxy() override {
88 // Destroy the window before the delegate.
89 window_.reset();
92 // Overridden from KeyboardControllerProxy:
93 bool HasKeyboardWindow() const override { return window_; }
94 aura::Window* GetKeyboardWindow() override {
95 if (!window_) {
96 window_.reset(new aura::Window(&delegate_));
97 window_->Init(aura::WINDOW_LAYER_NOT_DRAWN);
98 window_->set_owned_by_parent(false);
100 return window_.get();
102 content::BrowserContext* GetBrowserContext() override { return NULL; }
103 ui::InputMethod* GetInputMethod() override { return input_method_.get(); }
104 void RequestAudioInput(
105 content::WebContents* web_contents,
106 const content::MediaStreamRequest& request,
107 const content::MediaResponseCallback& callback) override {
108 return;
110 void LoadSystemKeyboard() override{};
111 void ReloadKeyboardIfNeeded() override{};
113 private:
114 scoped_ptr<aura::Window> window_;
115 aura::test::TestWindowDelegate delegate_;
116 scoped_ptr<ui::InputMethod> input_method_;
118 DISALLOW_COPY_AND_ASSIGN(TestKeyboardControllerProxy);
121 // Keeps a count of all the events a window receives.
122 class EventObserver : public ui::EventHandler {
123 public:
124 EventObserver() {}
125 ~EventObserver() override {}
127 int GetEventCount(ui::EventType type) {
128 return event_counts_[type];
131 private:
132 // Overridden from ui::EventHandler:
133 void OnEvent(ui::Event* event) override {
134 ui::EventHandler::OnEvent(event);
135 event_counts_[event->type()]++;
138 std::map<ui::EventType, int> event_counts_;
139 DISALLOW_COPY_AND_ASSIGN(EventObserver);
142 class KeyboardContainerObserver : public aura::WindowObserver {
143 public:
144 explicit KeyboardContainerObserver(aura::Window* window) : window_(window) {
145 window_->AddObserver(this);
147 ~KeyboardContainerObserver() override { window_->RemoveObserver(this); }
149 private:
150 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override {
151 if (!visible)
152 base::MessageLoop::current()->Quit();
155 aura::Window* window_;
157 DISALLOW_COPY_AND_ASSIGN(KeyboardContainerObserver);
160 } // namespace
162 class KeyboardControllerTest : public testing::Test {
163 public:
164 KeyboardControllerTest() {}
165 ~KeyboardControllerTest() override {}
167 void SetUp() override {
168 // The ContextFactory must exist before any Compositors are created.
169 bool enable_pixel_output = false;
170 ui::ContextFactory* context_factory =
171 ui::InitializeContextFactoryForTests(enable_pixel_output);
173 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
174 aura_test_helper_->SetUp(context_factory);
175 new wm::DefaultActivationClient(aura_test_helper_->root_window());
176 ui::SetUpInputMethodFactoryForTesting();
177 if (::switches::IsTextInputFocusManagerEnabled())
178 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(NULL);
179 focus_controller_.reset(new TestFocusController(root_window()));
180 proxy_ = new TestKeyboardControllerProxy();
181 controller_.reset(new KeyboardController(proxy_));
184 void TearDown() override {
185 controller_.reset();
186 focus_controller_.reset();
187 if (::switches::IsTextInputFocusManagerEnabled())
188 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(NULL);
189 aura_test_helper_->TearDown();
190 ui::TerminateContextFactoryForTests();
193 aura::Window* root_window() { return aura_test_helper_->root_window(); }
194 KeyboardControllerProxy* proxy() { return proxy_; }
195 KeyboardController* controller() { return controller_.get(); }
197 void ShowKeyboard() {
198 test_text_input_client_.reset(
199 new ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT));
200 SetFocus(test_text_input_client_.get());
203 protected:
204 void SetFocus(ui::TextInputClient* client) {
205 ui::InputMethod* input_method = proxy()->GetInputMethod();
206 if (::switches::IsTextInputFocusManagerEnabled()) {
207 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(client);
208 input_method->OnTextInputTypeChanged(client);
209 } else {
210 input_method->SetFocusedTextInputClient(client);
212 if (client && client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) {
213 input_method->ShowImeIfNeeded();
214 if (proxy_->GetKeyboardWindow()->bounds().height() == 0) {
215 // Set initial bounds for test keyboard window.
216 proxy_->GetKeyboardWindow()->SetBounds(
217 KeyboardBoundsFromWindowBounds(
218 controller()->GetContainerWindow()->bounds(), 100));
223 bool WillHideKeyboard() {
224 return controller_->WillHideKeyboard();
227 bool ShouldEnableInsets(aura::Window* window) {
228 return controller_->ShouldEnableInsets(window);
231 base::MessageLoopForUI message_loop_;
232 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_;
233 scoped_ptr<TestFocusController> focus_controller_;
235 private:
236 KeyboardControllerProxy* proxy_;
237 scoped_ptr<KeyboardController> controller_;
238 scoped_ptr<ui::TextInputClient> test_text_input_client_;
239 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerTest);
242 TEST_F(KeyboardControllerTest, KeyboardSize) {
243 aura::Window* container(controller()->GetContainerWindow());
244 aura::Window* keyboard(proxy()->GetKeyboardWindow());
245 container->SetBounds(gfx::Rect(0, 0, 200, 100));
247 container->AddChild(keyboard);
248 const gfx::Rect& before_bounds = keyboard->bounds();
249 // The initial keyboard should be positioned at the bottom of container and
250 // has 0 height.
251 ASSERT_EQ(gfx::Rect(0, 100, 200, 0), before_bounds);
253 gfx::Rect new_bounds(
254 before_bounds.x(), before_bounds.y() - 50,
255 before_bounds.width(), 50);
257 keyboard->SetBounds(new_bounds);
258 ASSERT_EQ(new_bounds, keyboard->bounds());
260 // Mock a screen rotation.
261 container->SetBounds(gfx::Rect(0, 0, 100, 200));
262 // The above call should resize keyboard to new width while keeping the old
263 // height.
264 ASSERT_EQ(gfx::Rect(0, 150, 100, 50), keyboard->bounds());
267 // Tests that tapping/clicking inside the keyboard does not give it focus.
268 TEST_F(KeyboardControllerTest, ClickDoesNotFocusKeyboard) {
269 const gfx::Rect& root_bounds = root_window()->bounds();
270 aura::test::EventCountDelegate delegate;
271 scoped_ptr<aura::Window> window(new aura::Window(&delegate));
272 window->Init(aura::WINDOW_LAYER_NOT_DRAWN);
273 window->SetBounds(root_bounds);
274 root_window()->AddChild(window.get());
275 window->Show();
276 window->Focus();
278 aura::Window* keyboard_container(controller()->GetContainerWindow());
279 keyboard_container->SetBounds(root_bounds);
281 root_window()->AddChild(keyboard_container);
282 keyboard_container->Show();
284 ShowKeyboard();
286 EXPECT_TRUE(window->IsVisible());
287 EXPECT_TRUE(keyboard_container->IsVisible());
288 EXPECT_TRUE(window->HasFocus());
289 EXPECT_FALSE(keyboard_container->HasFocus());
291 // Click on the keyboard. Make sure the keyboard receives the event, but does
292 // not get focus.
293 EventObserver observer;
294 keyboard_container->AddPreTargetHandler(&observer);
296 ui::test::EventGenerator generator(root_window());
297 generator.MoveMouseTo(proxy()->GetKeyboardWindow()->bounds().CenterPoint());
298 generator.ClickLeftButton();
299 EXPECT_TRUE(window->HasFocus());
300 EXPECT_FALSE(keyboard_container->HasFocus());
301 EXPECT_EQ("0 0", delegate.GetMouseButtonCountsAndReset());
302 EXPECT_EQ(1, observer.GetEventCount(ui::ET_MOUSE_PRESSED));
303 EXPECT_EQ(1, observer.GetEventCount(ui::ET_MOUSE_RELEASED));
305 // Click outside of the keyboard. It should reach the window behind.
306 generator.MoveMouseTo(gfx::Point());
307 generator.ClickLeftButton();
308 EXPECT_EQ("1 1", delegate.GetMouseButtonCountsAndReset());
309 keyboard_container->RemovePreTargetHandler(&observer);
312 TEST_F(KeyboardControllerTest, EventHitTestingInContainer) {
313 const gfx::Rect& root_bounds = root_window()->bounds();
314 aura::test::EventCountDelegate delegate;
315 scoped_ptr<aura::Window> window(new aura::Window(&delegate));
316 window->Init(aura::WINDOW_LAYER_NOT_DRAWN);
317 window->SetBounds(root_bounds);
318 root_window()->AddChild(window.get());
319 window->Show();
320 window->Focus();
322 aura::Window* keyboard_container(controller()->GetContainerWindow());
323 keyboard_container->SetBounds(root_bounds);
325 root_window()->AddChild(keyboard_container);
326 keyboard_container->Show();
328 ShowKeyboard();
330 EXPECT_TRUE(window->IsVisible());
331 EXPECT_TRUE(keyboard_container->IsVisible());
332 EXPECT_TRUE(window->HasFocus());
333 EXPECT_FALSE(keyboard_container->HasFocus());
335 // Make sure hit testing works correctly while the keyboard is visible.
336 aura::Window* keyboard_window = proxy()->GetKeyboardWindow();
337 ui::EventTarget* root = root_window();
338 ui::EventTargeter* targeter = root->GetEventTargeter();
339 gfx::Point location = keyboard_window->bounds().CenterPoint();
340 ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, location, location, ui::EF_NONE,
341 ui::EF_NONE);
342 EXPECT_EQ(keyboard_window, targeter->FindTargetForEvent(root, &mouse1));
344 location.set_y(keyboard_window->bounds().y() - 5);
345 ui::MouseEvent mouse2(ui::ET_MOUSE_MOVED, location, location, ui::EF_NONE,
346 ui::EF_NONE);
347 EXPECT_EQ(window.get(), targeter->FindTargetForEvent(root, &mouse2));
350 TEST_F(KeyboardControllerTest, KeyboardWindowCreation) {
351 const gfx::Rect& root_bounds = root_window()->bounds();
352 aura::test::EventCountDelegate delegate;
353 scoped_ptr<aura::Window> window(new aura::Window(&delegate));
354 window->Init(aura::WINDOW_LAYER_NOT_DRAWN);
355 window->SetBounds(root_bounds);
356 root_window()->AddChild(window.get());
357 window->Show();
358 window->Focus();
360 aura::Window* keyboard_container(controller()->GetContainerWindow());
361 keyboard_container->SetBounds(root_bounds);
363 root_window()->AddChild(keyboard_container);
364 keyboard_container->Show();
366 EXPECT_FALSE(proxy()->HasKeyboardWindow());
368 ui::EventTarget* root = root_window();
369 ui::EventTargeter* targeter = root->GetEventTargeter();
370 gfx::Point location(root_window()->bounds().width() / 2,
371 root_window()->bounds().height() - 10);
372 ui::MouseEvent mouse(
373 ui::ET_MOUSE_MOVED, location, location, ui::EF_NONE, ui::EF_NONE);
374 EXPECT_EQ(window.get(), targeter->FindTargetForEvent(root, &mouse));
375 EXPECT_FALSE(proxy()->HasKeyboardWindow());
377 EXPECT_EQ(
378 controller()->GetContainerWindow(),
379 controller()->GetContainerWindow()->GetEventHandlerForPoint(location));
380 EXPECT_FALSE(proxy()->HasKeyboardWindow());
383 TEST_F(KeyboardControllerTest, VisibilityChangeWithTextInputTypeChange) {
384 const gfx::Rect& root_bounds = root_window()->bounds();
386 ui::DummyTextInputClient input_client_0(ui::TEXT_INPUT_TYPE_TEXT);
387 ui::DummyTextInputClient input_client_1(ui::TEXT_INPUT_TYPE_TEXT);
388 ui::DummyTextInputClient input_client_2(ui::TEXT_INPUT_TYPE_TEXT);
389 ui::DummyTextInputClient no_input_client_0(ui::TEXT_INPUT_TYPE_NONE);
390 ui::DummyTextInputClient no_input_client_1(ui::TEXT_INPUT_TYPE_NONE);
392 aura::Window* keyboard_container(controller()->GetContainerWindow());
393 scoped_ptr<KeyboardContainerObserver> keyboard_container_observer(
394 new KeyboardContainerObserver(keyboard_container));
395 keyboard_container->SetBounds(root_bounds);
396 root_window()->AddChild(keyboard_container);
398 SetFocus(&input_client_0);
400 EXPECT_TRUE(keyboard_container->IsVisible());
402 SetFocus(&no_input_client_0);
403 // Keyboard should not immediately hide itself. It is delayed to avoid layout
404 // flicker when the focus of input field quickly change.
405 EXPECT_TRUE(keyboard_container->IsVisible());
406 EXPECT_TRUE(WillHideKeyboard());
407 // Wait for hide keyboard to finish.
408 base::MessageLoop::current()->Run();
409 EXPECT_FALSE(keyboard_container->IsVisible());
411 SetFocus(&input_client_1);
412 EXPECT_TRUE(keyboard_container->IsVisible());
414 // Schedule to hide keyboard.
415 SetFocus(&no_input_client_1);
416 EXPECT_TRUE(WillHideKeyboard());
417 // Cancel keyboard hide.
418 SetFocus(&input_client_2);
420 EXPECT_FALSE(WillHideKeyboard());
421 EXPECT_TRUE(keyboard_container->IsVisible());
424 // Test to prevent spurious overscroll boxes when changing tabs during keyboard
425 // hide. Refer to crbug.com/401670 for more context.
426 TEST_F(KeyboardControllerTest, CheckOverscrollInsetDuringVisibilityChange) {
427 const gfx::Rect& root_bounds = root_window()->bounds();
429 ui::DummyTextInputClient input_client(ui::TEXT_INPUT_TYPE_TEXT);
430 ui::DummyTextInputClient no_input_client(ui::TEXT_INPUT_TYPE_NONE);
432 aura::Window* keyboard_container(controller()->GetContainerWindow());
433 keyboard_container->SetBounds(root_bounds);
434 root_window()->AddChild(keyboard_container);
436 // Enable touch keyboard / overscroll mode to test insets.
437 keyboard::SetTouchKeyboardEnabled(true);
438 EXPECT_TRUE(keyboard::IsKeyboardOverscrollEnabled());
440 SetFocus(&input_client);
441 SetFocus(&no_input_client);
442 // Insets should not be enabled for new windows while keyboard is in the
443 // process of hiding when overscroll is enabled.
444 EXPECT_FALSE(ShouldEnableInsets(proxy()->GetKeyboardWindow()));
445 // Cancel keyboard hide.
446 SetFocus(&input_client);
447 // Insets should be enabled for new windows as hide was cancelled.
448 EXPECT_TRUE(ShouldEnableInsets(proxy()->GetKeyboardWindow()));
451 TEST_F(KeyboardControllerTest, AlwaysVisibleWhenLocked) {
452 const gfx::Rect& root_bounds = root_window()->bounds();
454 ui::DummyTextInputClient input_client_0(ui::TEXT_INPUT_TYPE_TEXT);
455 ui::DummyTextInputClient input_client_1(ui::TEXT_INPUT_TYPE_TEXT);
456 ui::DummyTextInputClient no_input_client_0(ui::TEXT_INPUT_TYPE_NONE);
457 ui::DummyTextInputClient no_input_client_1(ui::TEXT_INPUT_TYPE_NONE);
459 aura::Window* keyboard_container(controller()->GetContainerWindow());
460 scoped_ptr<KeyboardContainerObserver> keyboard_container_observer(
461 new KeyboardContainerObserver(keyboard_container));
462 keyboard_container->SetBounds(root_bounds);
463 root_window()->AddChild(keyboard_container);
465 SetFocus(&input_client_0);
467 EXPECT_TRUE(keyboard_container->IsVisible());
469 // Lock keyboard.
470 controller()->set_lock_keyboard(true);
472 SetFocus(&no_input_client_0);
473 // Keyboard should not try to hide itself as it is locked.
474 EXPECT_TRUE(keyboard_container->IsVisible());
475 EXPECT_FALSE(WillHideKeyboard());
477 SetFocus(&input_client_1);
478 EXPECT_TRUE(keyboard_container->IsVisible());
480 // Unlock keyboard.
481 controller()->set_lock_keyboard(false);
483 // Keyboard should hide when focus on no input client.
484 SetFocus(&no_input_client_1);
485 EXPECT_TRUE(WillHideKeyboard());
487 // Wait for hide keyboard to finish.
488 base::MessageLoop::current()->Run();
489 EXPECT_FALSE(keyboard_container->IsVisible());
492 class KeyboardControllerAnimationTest : public KeyboardControllerTest,
493 public KeyboardControllerObserver {
494 public:
495 KeyboardControllerAnimationTest() {}
496 ~KeyboardControllerAnimationTest() override {}
498 void SetUp() override {
499 // We cannot short-circuit animations for this test.
500 ui::ScopedAnimationDurationScaleMode test_duration_mode(
501 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
503 KeyboardControllerTest::SetUp();
505 const gfx::Rect& root_bounds = root_window()->bounds();
506 keyboard_container()->SetBounds(root_bounds);
507 root_window()->AddChild(keyboard_container());
508 controller()->AddObserver(this);
511 void TearDown() override {
512 controller()->RemoveObserver(this);
513 KeyboardControllerTest::TearDown();
516 protected:
517 // KeyboardControllerObserver overrides
518 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override {
519 notified_bounds_ = new_bounds;
522 const gfx::Rect& notified_bounds() { return notified_bounds_; }
524 aura::Window* keyboard_container() {
525 return controller()->GetContainerWindow();
528 aura::Window* keyboard_window() {
529 return proxy()->GetKeyboardWindow();
532 private:
533 gfx::Rect notified_bounds_;
535 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerAnimationTest);
538 // Tests virtual keyboard has correct show and hide animation.
539 TEST_F(KeyboardControllerAnimationTest, ContainerAnimation) {
540 ui::Layer* layer = keyboard_container()->layer();
541 ShowKeyboard();
543 // Keyboard container and window should immediately become visible before
544 // animation starts.
545 EXPECT_TRUE(keyboard_container()->IsVisible());
546 EXPECT_TRUE(keyboard_window()->IsVisible());
547 float show_start_opacity = layer->opacity();
548 gfx::Transform transform;
549 transform.Translate(0, kAnimationDistance);
550 EXPECT_EQ(transform, layer->transform());
551 EXPECT_EQ(gfx::Rect(), notified_bounds());
553 RunAnimationForLayer(layer);
554 EXPECT_TRUE(keyboard_container()->IsVisible());
555 EXPECT_TRUE(keyboard_window()->IsVisible());
556 float show_end_opacity = layer->opacity();
557 EXPECT_LT(show_start_opacity, show_end_opacity);
558 EXPECT_EQ(gfx::Transform(), layer->transform());
559 // KeyboardController should notify the bounds of keyboard window to its
560 // observers after show animation finished.
561 EXPECT_EQ(keyboard_window()->bounds(), notified_bounds());
563 // Directly hide keyboard without delay.
564 controller()->HideKeyboard(KeyboardController::HIDE_REASON_AUTOMATIC);
565 EXPECT_TRUE(keyboard_container()->IsVisible());
566 EXPECT_TRUE(keyboard_container()->layer()->visible());
567 EXPECT_TRUE(keyboard_window()->IsVisible());
568 float hide_start_opacity = layer->opacity();
569 // KeyboardController should notify the bounds of keyboard window to its
570 // observers before hide animation starts.
571 EXPECT_EQ(gfx::Rect(), notified_bounds());
573 RunAnimationForLayer(layer);
574 EXPECT_FALSE(keyboard_container()->IsVisible());
575 EXPECT_FALSE(keyboard_container()->layer()->visible());
576 EXPECT_FALSE(keyboard_window()->IsVisible());
577 float hide_end_opacity = layer->opacity();
578 EXPECT_GT(hide_start_opacity, hide_end_opacity);
579 EXPECT_EQ(transform, layer->transform());
580 EXPECT_EQ(gfx::Rect(), notified_bounds());
583 // Show keyboard during keyboard hide animation should abort the hide animation
584 // and the keyboard should animate in.
585 // Test for crbug.com/333284.
586 TEST_F(KeyboardControllerAnimationTest, ContainerShowWhileHide) {
587 ui::Layer* layer = keyboard_container()->layer();
588 ShowKeyboard();
589 RunAnimationForLayer(layer);
591 controller()->HideKeyboard(KeyboardController::HIDE_REASON_AUTOMATIC);
592 // Before hide animation finishes, show keyboard again.
593 ShowKeyboard();
594 RunAnimationForLayer(layer);
595 EXPECT_TRUE(keyboard_container()->IsVisible());
596 EXPECT_TRUE(keyboard_window()->IsVisible());
597 EXPECT_EQ(1.0, layer->opacity());
598 EXPECT_EQ(gfx::Transform(), layer->transform());
601 } // namespace keyboard