OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <X11/Xlib.h> | 5 #include <X11/Xlib.h> |
6 #undef Bool | 6 #undef Bool |
7 #undef FocusIn | 7 #undef FocusIn |
8 #undef FocusOut | 8 #undef FocusOut |
9 #undef None | 9 #undef None |
10 | 10 |
11 #include <cstring> | 11 #include <cstring> |
12 | 12 |
13 #include "base/i18n/char_iterator.h" | 13 #include "base/i18n/char_iterator.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "chromeos/dbus/dbus_thread_manager.h" | 16 #include "chromeos/dbus/dbus_thread_manager.h" |
17 #include "chromeos/dbus/ibus/ibus_text.h" | 17 #include "chromeos/dbus/ibus/ibus_text.h" |
18 #include "chromeos/dbus/ibus/mock_ibus_client.h" | |
19 #include "chromeos/ime/ibus_bridge.h" | 18 #include "chromeos/ime/ibus_bridge.h" |
20 #include "chromeos/ime/ibus_keymap.h" | 19 #include "chromeos/ime/ibus_keymap.h" |
21 #include "chromeos/ime/mock_ime_candidate_window_handler.h" | 20 #include "chromeos/ime/mock_ime_candidate_window_handler.h" |
22 #include "chromeos/ime/mock_ime_engine_handler.h" | 21 #include "chromeos/ime/mock_ime_engine_handler.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
24 #include "ui/base/ime/input_method_delegate.h" | 23 #include "ui/base/ime/input_method_delegate.h" |
25 #include "ui/base/ime/input_method_ibus.h" | 24 #include "ui/base/ime/input_method_ibus.h" |
26 #include "ui/base/ime/text_input_client.h" | 25 #include "ui/base/ime/text_input_client.h" |
27 #include "ui/events/event.h" | 26 #include "ui/events/event.h" |
28 #include "ui/events/x/events_x_utils.h" | 27 #include "ui/events/x/events_x_utils.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 100 |
102 // Change access rights for testing. | 101 // Change access rights for testing. |
103 using InputMethodIBus::ExtractCompositionText; | 102 using InputMethodIBus::ExtractCompositionText; |
104 using InputMethodIBus::ResetContext; | 103 using InputMethodIBus::ResetContext; |
105 | 104 |
106 private: | 105 private: |
107 ProcessKeyEventPostIMEArgs process_key_event_post_ime_args_; | 106 ProcessKeyEventPostIMEArgs process_key_event_post_ime_args_; |
108 int process_key_event_post_ime_call_count_; | 107 int process_key_event_post_ime_call_count_; |
109 }; | 108 }; |
110 | 109 |
111 class CreateInputContextSuccessHandler { | |
112 public: | |
113 explicit CreateInputContextSuccessHandler(const dbus::ObjectPath& object_path) | |
114 : object_path_(object_path) { | |
115 } | |
116 | |
117 void Run(const std::string& client_name, | |
118 const chromeos::IBusClient::CreateInputContextCallback& callback) { | |
119 EXPECT_EQ("chrome", client_name); | |
120 callback.Run(object_path_); | |
121 } | |
122 | |
123 private: | |
124 dbus::ObjectPath object_path_; | |
125 | |
126 DISALLOW_COPY_AND_ASSIGN(CreateInputContextSuccessHandler); | |
127 }; | |
128 | |
129 class CreateInputContextNoResponseHandler { | |
130 public: | |
131 CreateInputContextNoResponseHandler() {} | |
132 void Run(const std::string& client_name, | |
133 const chromeos::IBusClient::CreateInputContextCallback& callback) { | |
134 } | |
135 | |
136 private: | |
137 DISALLOW_COPY_AND_ASSIGN(CreateInputContextNoResponseHandler); | |
138 }; | |
139 | |
140 class CreateInputContextDelayHandler { | |
141 public: | |
142 explicit CreateInputContextDelayHandler(const dbus::ObjectPath& object_path) | |
143 : object_path_(object_path) { | |
144 } | |
145 | |
146 void Run(const std::string& client_name, | |
147 const chromeos::IBusClient::CreateInputContextCallback& callback) { | |
148 callback_ = callback; | |
149 } | |
150 | |
151 void RunCallback() { | |
152 callback_.Run(object_path_); | |
153 } | |
154 | |
155 private: | |
156 dbus::ObjectPath object_path_; | |
157 chromeos::IBusClient::CreateInputContextCallback callback_; | |
158 | |
159 DISALLOW_COPY_AND_ASSIGN(CreateInputContextDelayHandler); | |
160 }; | |
161 | |
162 class SynchronousKeyEventHandler { | 110 class SynchronousKeyEventHandler { |
163 public: | 111 public: |
164 SynchronousKeyEventHandler(uint32 expected_keyval, | 112 SynchronousKeyEventHandler(uint32 expected_keyval, |
165 uint32 expected_keycode, | 113 uint32 expected_keycode, |
166 uint32 expected_state, | 114 uint32 expected_state, |
167 KeyEventHandlerBehavior behavior) | 115 KeyEventHandlerBehavior behavior) |
168 : expected_keyval_(expected_keyval), | 116 : expected_keyval_(expected_keyval), |
169 expected_keycode_(expected_keycode), | 117 expected_keycode_(expected_keycode), |
170 expected_state_(expected_state), | 118 expected_state_(expected_state), |
171 behavior_(behavior) {} | 119 behavior_(behavior) {} |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 ime_->ResetContext(); | 1026 ime_->ResetContext(); |
1079 | 1027 |
1080 // Do callback. | 1028 // Do callback. |
1081 mock_ime_engine_handler_->last_passed_callback().Run(true); | 1029 mock_ime_engine_handler_->last_passed_callback().Run(true); |
1082 | 1030 |
1083 EXPECT_EQ(0, ime_->process_key_event_post_ime_call_count()); | 1031 EXPECT_EQ(0, ime_->process_key_event_post_ime_call_count()); |
1084 } | 1032 } |
1085 // TODO(nona): Introduce ProcessKeyEventPostIME tests(crbug.com/156593). | 1033 // TODO(nona): Introduce ProcessKeyEventPostIME tests(crbug.com/156593). |
1086 | 1034 |
1087 } // namespace ui | 1035 } // namespace ui |
OLD | NEW |