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

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

Issue 2211473003: Remove calls to deprecated MessageLoop methods on Windows and Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR Created 4 years, 4 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
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 <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/aura/client/focus_client.h" 15 #include "ui/aura/client/focus_client.h"
15 #include "ui/aura/layout_manager.h" 16 #include "ui/aura/layout_manager.h"
16 #include "ui/aura/test/aura_test_helper.h" 17 #include "ui/aura/test/aura_test_helper.h"
17 #include "ui/aura/test/test_window_delegate.h" 18 #include "ui/aura/test/test_window_delegate.h"
18 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
19 #include "ui/aura/window_event_dispatcher.h" 20 #include "ui/aura/window_event_dispatcher.h"
20 #include "ui/base/ime/dummy_text_input_client.h" 21 #include "ui/base/ime/dummy_text_input_client.h"
21 #include "ui/base/ime/input_method.h" 22 #include "ui/base/ime/input_method.h"
22 #include "ui/base/ime/input_method_factory.h" 23 #include "ui/base/ime/input_method_factory.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 class KeyboardContainerObserver : public aura::WindowObserver { 148 class KeyboardContainerObserver : public aura::WindowObserver {
148 public: 149 public:
149 explicit KeyboardContainerObserver(aura::Window* window) : window_(window) { 150 explicit KeyboardContainerObserver(aura::Window* window) : window_(window) {
150 window_->AddObserver(this); 151 window_->AddObserver(this);
151 } 152 }
152 ~KeyboardContainerObserver() override { window_->RemoveObserver(this); } 153 ~KeyboardContainerObserver() override { window_->RemoveObserver(this); }
153 154
154 private: 155 private:
155 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override { 156 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override {
156 if (!visible) 157 if (!visible)
157 base::MessageLoop::current()->QuitWhenIdle(); 158 base::MessageLoop::current()->QuitWhenIdle();
sadrul 2016/08/08 20:42:42 Runloop?
fdoray 2016/08/23 15:30:27 Done.
158 } 159 }
159 160
160 aura::Window* window_; 161 aura::Window* window_;
161 162
162 DISALLOW_COPY_AND_ASSIGN(KeyboardContainerObserver); 163 DISALLOW_COPY_AND_ASSIGN(KeyboardContainerObserver);
163 }; 164 };
164 165
165 } // namespace 166 } // namespace
166 167
167 class KeyboardControllerTest : public testing::Test, 168 class KeyboardControllerTest : public testing::Test,
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 SetFocus(&input_client_0); 373 SetFocus(&input_client_0);
373 374
374 EXPECT_TRUE(keyboard_container->IsVisible()); 375 EXPECT_TRUE(keyboard_container->IsVisible());
375 376
376 SetFocus(&no_input_client_0); 377 SetFocus(&no_input_client_0);
377 // Keyboard should not immediately hide itself. It is delayed to avoid layout 378 // Keyboard should not immediately hide itself. It is delayed to avoid layout
378 // flicker when the focus of input field quickly change. 379 // flicker when the focus of input field quickly change.
379 EXPECT_TRUE(keyboard_container->IsVisible()); 380 EXPECT_TRUE(keyboard_container->IsVisible());
380 EXPECT_TRUE(WillHideKeyboard()); 381 EXPECT_TRUE(WillHideKeyboard());
381 // Wait for hide keyboard to finish. 382 // Wait for hide keyboard to finish.
382 base::MessageLoop::current()->Run(); 383 base::RunLoop().Run();
383 EXPECT_FALSE(keyboard_container->IsVisible()); 384 EXPECT_FALSE(keyboard_container->IsVisible());
384 385
385 SetFocus(&input_client_1); 386 SetFocus(&input_client_1);
386 EXPECT_TRUE(keyboard_container->IsVisible()); 387 EXPECT_TRUE(keyboard_container->IsVisible());
387 388
388 // Schedule to hide keyboard. 389 // Schedule to hide keyboard.
389 SetFocus(&no_input_client_1); 390 SetFocus(&no_input_client_1);
390 EXPECT_TRUE(WillHideKeyboard()); 391 EXPECT_TRUE(WillHideKeyboard());
391 // Cancel keyboard hide. 392 // Cancel keyboard hide.
392 SetFocus(&input_client_2); 393 SetFocus(&input_client_2);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 screen_bounds.width(), kDefaultVirtualKeyboardHeight); 441 screen_bounds.width(), kDefaultVirtualKeyboardHeight);
441 // Verify overscroll or resize is in effect. 442 // Verify overscroll or resize is in effect.
442 EXPECT_EQ(expected_bounds, notified_bounds()); 443 EXPECT_EQ(expected_bounds, notified_bounds());
443 EXPECT_EQ(1, number_of_calls()); 444 EXPECT_EQ(1, number_of_calls());
444 445
445 controller()->SetKeyboardMode(FLOATING); 446 controller()->SetKeyboardMode(FLOATING);
446 // Switch to FLOATING should clear overscroll or resize. 447 // Switch to FLOATING should clear overscroll or resize.
447 EXPECT_EQ(gfx::Rect(), notified_bounds()); 448 EXPECT_EQ(gfx::Rect(), notified_bounds());
448 EXPECT_EQ(2, number_of_calls()); 449 EXPECT_EQ(2, number_of_calls());
449 SetFocus(&no_input_client); 450 SetFocus(&no_input_client);
450 base::MessageLoop::current()->Run(); 451 base::RunLoop().Run();
451 EXPECT_EQ(gfx::Rect(), notified_bounds()); 452 EXPECT_EQ(gfx::Rect(), notified_bounds());
452 EXPECT_EQ(3, number_of_calls()); 453 EXPECT_EQ(3, number_of_calls());
453 SetFocus(&input_client); 454 SetFocus(&input_client);
454 // In FLOATING mode, no overscroll or resize should be triggered. 455 // In FLOATING mode, no overscroll or resize should be triggered.
455 EXPECT_EQ(3, number_of_calls()); 456 EXPECT_EQ(3, number_of_calls());
456 EXPECT_EQ(gfx::Rect(), controller()->current_keyboard_bounds()); 457 EXPECT_EQ(gfx::Rect(), controller()->current_keyboard_bounds());
457 keyboard::SetAccessibilityKeyboardEnabled(false); 458 keyboard::SetAccessibilityKeyboardEnabled(false);
458 } 459 }
459 460
460 // Verify switch to FULL_WIDTH mode will move virtual keyboard to the right 461 // Verify switch to FULL_WIDTH mode will move virtual keyboard to the right
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 EXPECT_TRUE(keyboard_container->IsVisible()); 509 EXPECT_TRUE(keyboard_container->IsVisible());
509 510
510 // Unlock keyboard. 511 // Unlock keyboard.
511 controller()->set_lock_keyboard(false); 512 controller()->set_lock_keyboard(false);
512 513
513 // Keyboard should hide when focus on no input client. 514 // Keyboard should hide when focus on no input client.
514 SetFocus(&no_input_client_1); 515 SetFocus(&no_input_client_1);
515 EXPECT_TRUE(WillHideKeyboard()); 516 EXPECT_TRUE(WillHideKeyboard());
516 517
517 // Wait for hide keyboard to finish. 518 // Wait for hide keyboard to finish.
518 base::MessageLoop::current()->Run(); 519 base::RunLoop().Run();
519 EXPECT_FALSE(keyboard_container->IsVisible()); 520 EXPECT_FALSE(keyboard_container->IsVisible());
520 keyboard::SetAccessibilityKeyboardEnabled(false); 521 keyboard::SetAccessibilityKeyboardEnabled(false);
521 } 522 }
522 523
523 class KeyboardControllerAnimationTest : public KeyboardControllerTest { 524 class KeyboardControllerAnimationTest : public KeyboardControllerTest {
524 public: 525 public:
525 KeyboardControllerAnimationTest() {} 526 KeyboardControllerAnimationTest() {}
526 ~KeyboardControllerAnimationTest() override {} 527 ~KeyboardControllerAnimationTest() override {}
527 528
528 void SetUp() override { 529 void SetUp() override {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 gfx::Rect new_bounds(0, 0, 1280, 800); 652 gfx::Rect new_bounds(0, 0, 1280, 800);
652 ASSERT_NE(new_bounds, root_window()->bounds()); 653 ASSERT_NE(new_bounds, root_window()->bounds());
653 EXPECT_EQ(1, number_of_calls()); 654 EXPECT_EQ(1, number_of_calls());
654 root_window()->SetBounds(new_bounds); 655 root_window()->SetBounds(new_bounds);
655 EXPECT_EQ(2, number_of_calls()); 656 EXPECT_EQ(2, number_of_calls());
656 MockRotateScreen(); 657 MockRotateScreen();
657 EXPECT_EQ(3, number_of_calls()); 658 EXPECT_EQ(3, number_of_calls());
658 } 659 }
659 660
660 } // namespace keyboard 661 } // namespace keyboard
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698