| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(MakeRequest(&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), MakeRequest(&input_method)); | 96 ui::mojom::StartSessionDetailsPtr details = |
| 97 ui::mojom::StartSessionDetails::New(); |
| 98 details->client = std::move(client_ptr); |
| 99 details->input_method_request = MakeRequest(&input_method); |
| 100 ime_server_->StartSession(std::move(details)); |
| 97 | 101 |
| 98 // Send character key event. | 102 // Send character key event. |
| 99 ui::KeyEvent char_event('A', ui::VKEY_A, 0); | 103 ui::KeyEvent char_event('A', ui::VKEY_A, 0); |
| 100 EXPECT_TRUE(ProcessKeyEvent(&input_method, ui::Event::Clone(char_event))); | 104 EXPECT_TRUE(ProcessKeyEvent(&input_method, ui::Event::Clone(char_event))); |
| 101 | 105 |
| 102 std::unique_ptr<ui::Event> received_event = client.WaitUntilInsertChar(); | 106 std::unique_ptr<ui::Event> received_event = client.WaitUntilInsertChar(); |
| 103 ASSERT_TRUE(received_event && received_event->IsKeyEvent()); | 107 ASSERT_TRUE(received_event && received_event->IsKeyEvent()); |
| 104 | 108 |
| 105 ui::KeyEvent* received_key_event = received_event->AsKeyEvent(); | 109 ui::KeyEvent* received_key_event = received_event->AsKeyEvent(); |
| 106 EXPECT_EQ(ui::ET_KEY_PRESSED, received_key_event->type()); | 110 EXPECT_EQ(ui::ET_KEY_PRESSED, received_key_event->type()); |
| 107 EXPECT_TRUE(received_key_event->is_char()); | 111 EXPECT_TRUE(received_key_event->is_char()); |
| 108 EXPECT_EQ(char_event.GetCharacter(), received_key_event->GetCharacter()); | 112 EXPECT_EQ(char_event.GetCharacter(), received_key_event->GetCharacter()); |
| 109 | 113 |
| 110 // Send non-character key event. | 114 // Send non-character key event. |
| 111 ui::KeyEvent nonchar_event(ui::ET_KEY_PRESSED, ui::VKEY_LEFT, 0); | 115 ui::KeyEvent nonchar_event(ui::ET_KEY_PRESSED, ui::VKEY_LEFT, 0); |
| 112 EXPECT_FALSE(ProcessKeyEvent(&input_method, ui::Event::Clone(nonchar_event))); | 116 EXPECT_FALSE(ProcessKeyEvent(&input_method, ui::Event::Clone(nonchar_event))); |
| 113 } | 117 } |
| OLD | NEW |