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

Side by Side Diff: ui/keyboard/keyboard_controller_unittest.cc

Issue 578653004: Overscroll for keyboard disabled while keyboard is hiding. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: ) Created 6 years, 3 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
« no previous file with comments | « ui/keyboard/keyboard_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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 "ui/keyboard/keyboard_controller.h" 5 #include "ui/keyboard/keyboard_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 KeyboardBoundsFromWindowBounds( 221 KeyboardBoundsFromWindowBounds(
222 controller()->GetContainerWindow()->bounds(), 100)); 222 controller()->GetContainerWindow()->bounds(), 100));
223 } 223 }
224 } 224 }
225 } 225 }
226 226
227 bool WillHideKeyboard() { 227 bool WillHideKeyboard() {
228 return controller_->WillHideKeyboard(); 228 return controller_->WillHideKeyboard();
229 } 229 }
230 230
231 bool ShouldEnableInsets(aura::Window* window) {
232 return controller_->ShouldEnableInsets(window);
233 }
234
231 base::MessageLoopForUI message_loop_; 235 base::MessageLoopForUI message_loop_;
232 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; 236 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_;
233 scoped_ptr<TestFocusController> focus_controller_; 237 scoped_ptr<TestFocusController> focus_controller_;
234 238
235 private: 239 private:
236 KeyboardControllerProxy* proxy_; 240 KeyboardControllerProxy* proxy_;
237 scoped_ptr<KeyboardController> controller_; 241 scoped_ptr<KeyboardController> controller_;
238 scoped_ptr<ui::TextInputClient> test_text_input_client_; 242 scoped_ptr<ui::TextInputClient> test_text_input_client_;
239 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerTest); 243 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerTest);
240 }; 244 };
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 // Schedule to hide keyboard. 418 // Schedule to hide keyboard.
415 SetFocus(&no_input_client_1); 419 SetFocus(&no_input_client_1);
416 EXPECT_TRUE(WillHideKeyboard()); 420 EXPECT_TRUE(WillHideKeyboard());
417 // Cancel keyboard hide. 421 // Cancel keyboard hide.
418 SetFocus(&input_client_2); 422 SetFocus(&input_client_2);
419 423
420 EXPECT_FALSE(WillHideKeyboard()); 424 EXPECT_FALSE(WillHideKeyboard());
421 EXPECT_TRUE(keyboard_container->IsVisible()); 425 EXPECT_TRUE(keyboard_container->IsVisible());
422 } 426 }
423 427
428 // Test to prevent spurious overscroll boxes when changing tabs during keyboard
429 // hide. Refer to crbug.com/401670 for more context.
430 TEST_F(KeyboardControllerTest, CheckOverscrollInsetDuringVisibilityChange) {
431 const gfx::Rect& root_bounds = root_window()->bounds();
432
433 ui::DummyTextInputClient input_client(ui::TEXT_INPUT_TYPE_TEXT);
434 ui::DummyTextInputClient no_input_client(ui::TEXT_INPUT_TYPE_NONE);
435
436 aura::Window* keyboard_container(controller()->GetContainerWindow());
437 keyboard_container->SetBounds(root_bounds);
438 root_window()->AddChild(keyboard_container);
439
440 // Enable touch keyboard / overscroll mode to test insets.
441 keyboard::SetTouchKeyboardEnabled(true);
442 EXPECT_TRUE(keyboard::IsKeyboardOverscrollEnabled());
443
444 SetFocus(&input_client);
445 SetFocus(&no_input_client);
446 // Insets should not be enabled for new windows while keyboard is in the
447 // process of hiding when overscroll is enabled.
448 EXPECT_FALSE(ShouldEnableInsets(proxy()->GetKeyboardWindow()));
449 // Cancel keyboard hide.
450 SetFocus(&input_client);
451 // Insets should be enabled for new windows as hide was cancelled.
452 EXPECT_TRUE(ShouldEnableInsets(proxy()->GetKeyboardWindow()));
453 }
454
424 TEST_F(KeyboardControllerTest, AlwaysVisibleWhenLocked) { 455 TEST_F(KeyboardControllerTest, AlwaysVisibleWhenLocked) {
425 const gfx::Rect& root_bounds = root_window()->bounds(); 456 const gfx::Rect& root_bounds = root_window()->bounds();
426 457
427 ui::DummyTextInputClient input_client_0(ui::TEXT_INPUT_TYPE_TEXT); 458 ui::DummyTextInputClient input_client_0(ui::TEXT_INPUT_TYPE_TEXT);
428 ui::DummyTextInputClient input_client_1(ui::TEXT_INPUT_TYPE_TEXT); 459 ui::DummyTextInputClient input_client_1(ui::TEXT_INPUT_TYPE_TEXT);
429 ui::DummyTextInputClient no_input_client_0(ui::TEXT_INPUT_TYPE_NONE); 460 ui::DummyTextInputClient no_input_client_0(ui::TEXT_INPUT_TYPE_NONE);
430 ui::DummyTextInputClient no_input_client_1(ui::TEXT_INPUT_TYPE_NONE); 461 ui::DummyTextInputClient no_input_client_1(ui::TEXT_INPUT_TYPE_NONE);
431 462
432 aura::Window* keyboard_container(controller()->GetContainerWindow()); 463 aura::Window* keyboard_container(controller()->GetContainerWindow());
433 scoped_ptr<KeyboardContainerObserver> keyboard_container_observer( 464 scoped_ptr<KeyboardContainerObserver> keyboard_container_observer(
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 // Before hide animation finishes, show keyboard again. 596 // Before hide animation finishes, show keyboard again.
566 ShowKeyboard(); 597 ShowKeyboard();
567 RunAnimationForLayer(layer); 598 RunAnimationForLayer(layer);
568 EXPECT_TRUE(keyboard_container()->IsVisible()); 599 EXPECT_TRUE(keyboard_container()->IsVisible());
569 EXPECT_TRUE(keyboard_window()->IsVisible()); 600 EXPECT_TRUE(keyboard_window()->IsVisible());
570 EXPECT_EQ(1.0, layer->opacity()); 601 EXPECT_EQ(1.0, layer->opacity());
571 EXPECT_EQ(gfx::Transform(), layer->transform()); 602 EXPECT_EQ(gfx::Transform(), layer->transform());
572 } 603 }
573 604
574 } // namespace keyboard 605 } // namespace keyboard
OLDNEW
« no previous file with comments | « ui/keyboard/keyboard_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698