OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/views/mus/input_method_mus.h" | 5 #include "ui/views/mus/input_method_mus.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
8 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/base/ime/dummy_text_input_client.h" | 12 #include "ui/base/ime/dummy_text_input_client.h" |
11 #include "ui/base/ime/input_method_delegate.h" | 13 #include "ui/base/ime/input_method_delegate.h" |
12 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
13 #include "ui/views/mus/window_manager_connection.h" | 15 #include "ui/views/mus/window_manager_connection.h" |
14 #include "ui/views/test/scoped_views_test_helper.h" | 16 #include "ui/views/test/scoped_views_test_helper.h" |
15 | 17 |
16 namespace views { | 18 namespace views { |
(...skipping 13 matching lines...) Expand all Loading... |
30 private: | 32 private: |
31 DISALLOW_COPY_AND_ASSIGN(TestInputMethodDelegate); | 33 DISALLOW_COPY_AND_ASSIGN(TestInputMethodDelegate); |
32 }; | 34 }; |
33 | 35 |
34 class TestTextInputClient : public ui::DummyTextInputClient { | 36 class TestTextInputClient : public ui::DummyTextInputClient { |
35 public: | 37 public: |
36 TestTextInputClient() {} | 38 TestTextInputClient() {} |
37 ~TestTextInputClient() override {} | 39 ~TestTextInputClient() override {} |
38 | 40 |
39 ui::KeyEvent* WaitUntilInputReceieved() { | 41 ui::KeyEvent* WaitUntilInputReceieved() { |
40 run_loop_.reset(new base::RunLoop); | 42 run_loop_ = base::MakeUnique<base::RunLoop>(); |
41 run_loop_->Run(); | 43 run_loop_->Run(); |
42 run_loop_.reset(); | 44 run_loop_.reset(); |
43 | 45 |
44 return received_event_->AsKeyEvent(); | 46 return received_event_->AsKeyEvent(); |
45 } | 47 } |
46 | 48 |
47 // ui::DummyTextInputClient: | 49 // ui::DummyTextInputClient: |
48 void InsertChar(const ui::KeyEvent& event) override { | 50 void InsertChar(const ui::KeyEvent& event) override { |
49 received_event_ = ui::Event::Clone(event); | 51 received_event_ = ui::Event::Clone(event); |
50 run_loop_->Quit(); | 52 run_loop_->Quit(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 ui::KeyEvent key_event('A', ui::VKEY_A, 0); | 92 ui::KeyEvent key_event('A', ui::VKEY_A, 0); |
91 input_method.DispatchKeyEvent(&key_event); | 93 input_method.DispatchKeyEvent(&key_event); |
92 | 94 |
93 ui::KeyEvent* received_event = text_input_client.WaitUntilInputReceieved(); | 95 ui::KeyEvent* received_event = text_input_client.WaitUntilInputReceieved(); |
94 EXPECT_EQ(ui::ET_KEY_PRESSED, received_event->type()); | 96 EXPECT_EQ(ui::ET_KEY_PRESSED, received_event->type()); |
95 EXPECT_TRUE(received_event->is_char()); | 97 EXPECT_TRUE(received_event->is_char()); |
96 EXPECT_EQ(key_event.GetCharacter(), received_event->GetCharacter()); | 98 EXPECT_EQ(key_event.GetCharacter(), received_event->GetCharacter()); |
97 } | 99 } |
98 | 100 |
99 } // namespace views | 101 } // namespace views |
OLD | NEW |