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

Unified 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: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gl/gl_surface_glx.cc ('k') | ui/message_center/views/message_center_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/keyboard/keyboard_controller_unittest.cc
diff --git a/ui/keyboard/keyboard_controller_unittest.cc b/ui/keyboard/keyboard_controller_unittest.cc
index 9b8f8b7822f83982d9ee7f7f7876909be533e540..4f00f2fbdded85cc23014d5dbf670bfe28db6caa 100644
--- a/ui/keyboard/keyboard_controller_unittest.cc
+++ b/ui/keyboard/keyboard_controller_unittest.cc
@@ -10,6 +10,7 @@
#include "base/command_line.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/layout_manager.h"
@@ -146,7 +147,9 @@ class EventObserver : public ui::EventHandler {
class KeyboardContainerObserver : public aura::WindowObserver {
public:
- explicit KeyboardContainerObserver(aura::Window* window) : window_(window) {
+ explicit KeyboardContainerObserver(aura::Window* window,
+ base::RunLoop* run_loop)
+ : window_(window), run_loop_(run_loop) {
window_->AddObserver(this);
}
~KeyboardContainerObserver() override { window_->RemoveObserver(this); }
@@ -154,10 +157,11 @@ class KeyboardContainerObserver : public aura::WindowObserver {
private:
void OnWindowVisibilityChanged(aura::Window* window, bool visible) override {
if (!visible)
- base::MessageLoop::current()->QuitWhenIdle();
+ run_loop_->QuitWhenIdle();
}
aura::Window* window_;
+ base::RunLoop* const run_loop_;
DISALLOW_COPY_AND_ASSIGN(KeyboardContainerObserver);
};
@@ -364,9 +368,10 @@ TEST_F(KeyboardControllerTest, VisibilityChangeWithTextInputTypeChange) {
ui::DummyTextInputClient no_input_client_0(ui::TEXT_INPUT_TYPE_NONE);
ui::DummyTextInputClient no_input_client_1(ui::TEXT_INPUT_TYPE_NONE);
+ base::RunLoop run_loop;
aura::Window* keyboard_container(controller()->GetContainerWindow());
std::unique_ptr<KeyboardContainerObserver> keyboard_container_observer(
- new KeyboardContainerObserver(keyboard_container));
+ new KeyboardContainerObserver(keyboard_container, &run_loop));
root_window()->AddChild(keyboard_container);
SetFocus(&input_client_0);
@@ -379,7 +384,7 @@ TEST_F(KeyboardControllerTest, VisibilityChangeWithTextInputTypeChange) {
EXPECT_TRUE(keyboard_container->IsVisible());
EXPECT_TRUE(WillHideKeyboard());
// Wait for hide keyboard to finish.
- base::MessageLoop::current()->Run();
+ run_loop.Run();
EXPECT_FALSE(keyboard_container->IsVisible());
SetFocus(&input_client_1);
@@ -427,10 +432,11 @@ TEST_F(KeyboardControllerTest, FloatingKeyboardDontOverscrollOrResize) {
ui::DummyTextInputClient input_client(ui::TEXT_INPUT_TYPE_TEXT);
ui::DummyTextInputClient no_input_client(ui::TEXT_INPUT_TYPE_NONE);
+ base::RunLoop run_loop;
aura::Window* container(controller()->GetContainerWindow());
root_window()->AddChild(container);
std::unique_ptr<KeyboardContainerObserver> keyboard_container_observer(
- new KeyboardContainerObserver(container));
+ new KeyboardContainerObserver(container, &run_loop));
gfx::Rect screen_bounds = root_window()->bounds();
keyboard::SetTouchKeyboardEnabled(true);
@@ -447,7 +453,7 @@ TEST_F(KeyboardControllerTest, FloatingKeyboardDontOverscrollOrResize) {
EXPECT_EQ(gfx::Rect(), notified_bounds());
EXPECT_EQ(2, number_of_calls());
SetFocus(&no_input_client);
- base::MessageLoop::current()->Run();
+ run_loop.Run();
EXPECT_EQ(gfx::Rect(), notified_bounds());
EXPECT_EQ(3, number_of_calls());
SetFocus(&input_client);
@@ -487,9 +493,10 @@ TEST_F(KeyboardControllerTest, AlwaysVisibleWhenLocked) {
ui::DummyTextInputClient no_input_client_0(ui::TEXT_INPUT_TYPE_NONE);
ui::DummyTextInputClient no_input_client_1(ui::TEXT_INPUT_TYPE_NONE);
+ base::RunLoop run_loop;
aura::Window* keyboard_container(controller()->GetContainerWindow());
std::unique_ptr<KeyboardContainerObserver> keyboard_container_observer(
- new KeyboardContainerObserver(keyboard_container));
+ new KeyboardContainerObserver(keyboard_container, &run_loop));
root_window()->AddChild(keyboard_container);
SetFocus(&input_client_0);
@@ -515,7 +522,7 @@ TEST_F(KeyboardControllerTest, AlwaysVisibleWhenLocked) {
EXPECT_TRUE(WillHideKeyboard());
// Wait for hide keyboard to finish.
- base::MessageLoop::current()->Run();
+ run_loop.Run();
EXPECT_FALSE(keyboard_container->IsVisible());
keyboard::SetAccessibilityKeyboardEnabled(false);
}
« no previous file with comments | « ui/gl/gl_surface_glx.cc ('k') | ui/message_center/views/message_center_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698