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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "mojo/public/cpp/bindings/interface_request.h" | 10 #include "mojo/public/cpp/bindings/interface_request.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 ui::mojom::IMEServerPtr ime_server_; | 83 ui::mojom::IMEServerPtr ime_server_; |
84 std::unique_ptr<base::RunLoop> run_loop_; | 84 std::unique_ptr<base::RunLoop> run_loop_; |
85 bool handled_; | 85 bool handled_; |
86 | 86 |
87 DISALLOW_COPY_AND_ASSIGN(IMEAppTest); | 87 DISALLOW_COPY_AND_ASSIGN(IMEAppTest); |
88 }; | 88 }; |
89 | 89 |
90 // Tests sending a KeyEvent to the IMEDriver through the Mus IMEServer. | 90 // Tests sending a KeyEvent to the IMEDriver through the Mus IMEServer. |
91 TEST_F(IMEAppTest, ProcessKeyEvent) { | 91 TEST_F(IMEAppTest, ProcessKeyEvent) { |
92 ui::mojom::TextInputClientPtr client_ptr; | 92 ui::mojom::TextInputClientPtr client_ptr; |
93 TestTextInputClient client(GetProxy(&client_ptr)); | 93 TestTextInputClient client(MakeRequest(&client_ptr)); |
94 | 94 |
95 ui::mojom::InputMethodPtr input_method; | 95 ui::mojom::InputMethodPtr input_method; |
96 ime_server_->StartSession(std::move(client_ptr), GetProxy(&input_method)); | 96 ime_server_->StartSession(std::move(client_ptr), MakeRequest(&input_method)); |
97 | 97 |
98 // Send character key event. | 98 // Send character key event. |
99 ui::KeyEvent char_event('A', ui::VKEY_A, 0); | 99 ui::KeyEvent char_event('A', ui::VKEY_A, 0); |
100 EXPECT_TRUE(ProcessKeyEvent(&input_method, ui::Event::Clone(char_event))); | 100 EXPECT_TRUE(ProcessKeyEvent(&input_method, ui::Event::Clone(char_event))); |
101 | 101 |
102 std::unique_ptr<ui::Event> received_event = client.WaitUntilInsertChar(); | 102 std::unique_ptr<ui::Event> received_event = client.WaitUntilInsertChar(); |
103 ASSERT_TRUE(received_event && received_event->IsKeyEvent()); | 103 ASSERT_TRUE(received_event && received_event->IsKeyEvent()); |
104 | 104 |
105 ui::KeyEvent* received_key_event = received_event->AsKeyEvent(); | 105 ui::KeyEvent* received_key_event = received_event->AsKeyEvent(); |
106 EXPECT_EQ(ui::ET_KEY_PRESSED, received_key_event->type()); | 106 EXPECT_EQ(ui::ET_KEY_PRESSED, received_key_event->type()); |
107 EXPECT_TRUE(received_key_event->is_char()); | 107 EXPECT_TRUE(received_key_event->is_char()); |
108 EXPECT_EQ(char_event.GetCharacter(), received_key_event->GetCharacter()); | 108 EXPECT_EQ(char_event.GetCharacter(), received_key_event->GetCharacter()); |
109 | 109 |
110 // Send non-character key event. | 110 // Send non-character key event. |
111 ui::KeyEvent nonchar_event(ui::ET_KEY_PRESSED, ui::VKEY_LEFT, 0); | 111 ui::KeyEvent nonchar_event(ui::ET_KEY_PRESSED, ui::VKEY_LEFT, 0); |
112 EXPECT_FALSE(ProcessKeyEvent(&input_method, ui::Event::Clone(nonchar_event))); | 112 EXPECT_FALSE(ProcessKeyEvent(&input_method, ui::Event::Clone(nonchar_event))); |
113 } | 113 } |
OLD | NEW |