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 "chromeos/dbus/ibus/ibus_engine_service.h" | 5 #include "chromeos/dbus/ibus/ibus_engine_service.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 namespace { | 29 namespace { |
30 const std::string kObjectPath = "/org/freedesktop/IBus/Engine/1"; | 30 const std::string kObjectPath = "/org/freedesktop/IBus/Engine/1"; |
31 | 31 |
32 class MockIBusEngineHandler : public IBusEngineHandlerInterface { | 32 class MockIBusEngineHandler : public IBusEngineHandlerInterface { |
33 public: | 33 public: |
34 MOCK_METHOD0(FocusIn, void()); | 34 MOCK_METHOD0(FocusIn, void()); |
35 MOCK_METHOD0(FocusOut, void()); | 35 MOCK_METHOD0(FocusOut, void()); |
36 MOCK_METHOD0(Enable, void()); | 36 MOCK_METHOD0(Enable, void()); |
37 MOCK_METHOD0(Disable, void()); | 37 MOCK_METHOD0(Disable, void()); |
38 MOCK_METHOD2(PropertyActivate, void(const std::string& property_name, | 38 MOCK_METHOD2(PropertyActivate, void(const std::string& property_name, |
39 IBusPropertyState property_state)); | 39 ibus::IBusPropertyState property_state)); |
40 MOCK_METHOD1(PropertyShow, void(const std::string& property_name)); | 40 MOCK_METHOD1(PropertyShow, void(const std::string& property_name)); |
41 MOCK_METHOD1(PropertyHide, void(const std::string& property_name)); | 41 MOCK_METHOD1(PropertyHide, void(const std::string& property_name)); |
42 MOCK_METHOD1(SetCapability, void(IBusCapability capability)); | 42 MOCK_METHOD1(SetCapability, void(IBusCapability capability)); |
43 MOCK_METHOD0(Reset, void()); | 43 MOCK_METHOD0(Reset, void()); |
44 MOCK_METHOD4(ProcessKeyEvent, void( | 44 MOCK_METHOD4(ProcessKeyEvent, void( |
45 uint32 keysym, | 45 uint32 keysym, |
46 uint32 keycode, | 46 uint32 keycode, |
47 uint32 state, | 47 uint32 state, |
48 const KeyEventDoneCallback& callback)); | 48 const KeyEventDoneCallback& callback)); |
49 MOCK_METHOD3(CandidateClicked, void(uint32 index, | 49 MOCK_METHOD3(CandidateClicked, void(uint32 index, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 uint32 serial_no_; | 102 uint32 serial_no_; |
103 bool result_; | 103 bool result_; |
104 | 104 |
105 DISALLOW_COPY_AND_ASSIGN(BoolResponseExpectation); | 105 DISALLOW_COPY_AND_ASSIGN(BoolResponseExpectation); |
106 }; | 106 }; |
107 | 107 |
108 // Used for RegisterProperties signal message evaluation. | 108 // Used for RegisterProperties signal message evaluation. |
109 class RegisterPropertiesExpectation { | 109 class RegisterPropertiesExpectation { |
110 public: | 110 public: |
111 explicit RegisterPropertiesExpectation( | 111 explicit RegisterPropertiesExpectation( |
112 const ibus::IBusPropertyList& property_list) | 112 const IBusPropertyList& property_list) |
113 : property_list_(property_list) {} | 113 : property_list_(property_list) {} |
114 | 114 |
115 // Evaluates the given |signal| is a valid message. | 115 // Evaluates the given |signal| is a valid message. |
116 void Evaluate(dbus::Signal* signal) { | 116 void Evaluate(dbus::Signal* signal) { |
117 ibus::IBusPropertyList property_list; | 117 IBusPropertyList property_list; |
118 | 118 |
119 // Read a signal argument. | 119 // Read a signal argument. |
120 dbus::MessageReader reader(signal); | 120 dbus::MessageReader reader(signal); |
121 EXPECT_TRUE(ibus::PopIBusPropertyList(&reader, &property_list)); | 121 EXPECT_TRUE(PopIBusPropertyList(&reader, &property_list)); |
122 EXPECT_FALSE(reader.HasMoreData()); | 122 EXPECT_FALSE(reader.HasMoreData()); |
123 | 123 |
124 // Check an argument. | 124 // Check an argument. |
125 EXPECT_EQ(property_list_.size(), property_list.size()); | 125 EXPECT_EQ(property_list_.size(), property_list.size()); |
126 for (size_t i = 0; i < property_list_.size(); ++i) { | 126 for (size_t i = 0; i < property_list_.size(); ++i) { |
127 EXPECT_EQ(property_list_[i]->key(), property_list[i]->key()); | 127 EXPECT_EQ(property_list_[i]->key(), property_list[i]->key()); |
128 EXPECT_EQ(property_list_[i]->type(), property_list[i]->type()); | 128 EXPECT_EQ(property_list_[i]->type(), property_list[i]->type()); |
129 EXPECT_EQ(property_list_[i]->label(), property_list[i]->label()); | 129 EXPECT_EQ(property_list_[i]->label(), property_list[i]->label()); |
130 EXPECT_EQ(property_list_[i]->tooltip(), property_list[i]->tooltip()); | 130 EXPECT_EQ(property_list_[i]->tooltip(), property_list[i]->tooltip()); |
131 EXPECT_EQ(property_list_[i]->visible(), property_list[i]->visible()); | 131 EXPECT_EQ(property_list_[i]->visible(), property_list[i]->visible()); |
132 EXPECT_EQ(property_list_[i]->checked(), property_list[i]->checked()); | 132 EXPECT_EQ(property_list_[i]->checked(), property_list[i]->checked()); |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 private: | 136 private: |
137 const ibus::IBusPropertyList& property_list_; | 137 const IBusPropertyList& property_list_; |
138 | 138 |
139 DISALLOW_COPY_AND_ASSIGN(RegisterPropertiesExpectation); | 139 DISALLOW_COPY_AND_ASSIGN(RegisterPropertiesExpectation); |
140 }; | 140 }; |
141 | 141 |
142 // Used for mocking ProcessKeyEventHandler. | 142 // Used for mocking ProcessKeyEventHandler. |
143 class ProcessKeyEventHandler { | 143 class ProcessKeyEventHandler { |
144 public: | 144 public: |
145 explicit ProcessKeyEventHandler(bool expected_value) | 145 explicit ProcessKeyEventHandler(bool expected_value) |
146 : expected_value_(expected_value) { | 146 : expected_value_(expected_value) { |
147 } | 147 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 bool expected_value_; | 181 bool expected_value_; |
182 MessageLoop* message_loop_; | 182 MessageLoop* message_loop_; |
183 | 183 |
184 DISALLOW_COPY_AND_ASSIGN(DelayProcessKeyEventHandler); | 184 DISALLOW_COPY_AND_ASSIGN(DelayProcessKeyEventHandler); |
185 }; | 185 }; |
186 | 186 |
187 // Used for UpdatePreedit signal message evaluation. | 187 // Used for UpdatePreedit signal message evaluation. |
188 class UpdatePreeditExpectation { | 188 class UpdatePreeditExpectation { |
189 public: | 189 public: |
190 UpdatePreeditExpectation( | 190 UpdatePreeditExpectation( |
191 const ibus::IBusText& ibus_text, | 191 const IBusText& ibus_text, |
192 uint32 cursor_pos, | 192 uint32 cursor_pos, |
193 bool is_visible, | 193 bool is_visible, |
194 IBusEngineService::IBusEnginePreeditFocusOutMode mode) | 194 IBusEngineService::IBusEnginePreeditFocusOutMode mode) |
195 : ibus_text_(ibus_text), | 195 : ibus_text_(ibus_text), |
196 cursor_pos_(cursor_pos), | 196 cursor_pos_(cursor_pos), |
197 is_visible_(is_visible), | 197 is_visible_(is_visible), |
198 mode_(mode) {} | 198 mode_(mode) {} |
199 | 199 |
200 // Evaluates the given |signal| is a valid message. | 200 // Evaluates the given |signal| is a valid message. |
201 void Evaluate(dbus::Signal* signal) { | 201 void Evaluate(dbus::Signal* signal) { |
202 ibus::IBusText ibus_text; | 202 IBusText ibus_text; |
203 uint32 cursor_pos = 0; | 203 uint32 cursor_pos = 0; |
204 bool is_visible = false; | 204 bool is_visible = false; |
205 uint32 preedit_mode = 0; | 205 uint32 preedit_mode = 0; |
206 | 206 |
207 // Read signal arguments. | 207 // Read signal arguments. |
208 dbus::MessageReader reader(signal); | 208 dbus::MessageReader reader(signal); |
209 EXPECT_TRUE(ibus::PopIBusText(&reader, &ibus_text)); | 209 EXPECT_TRUE(PopIBusText(&reader, &ibus_text)); |
210 EXPECT_TRUE(reader.PopUint32(&cursor_pos)); | 210 EXPECT_TRUE(reader.PopUint32(&cursor_pos)); |
211 EXPECT_TRUE(reader.PopBool(&is_visible)); | 211 EXPECT_TRUE(reader.PopBool(&is_visible)); |
212 EXPECT_TRUE(reader.PopUint32(&preedit_mode)); | 212 EXPECT_TRUE(reader.PopUint32(&preedit_mode)); |
213 EXPECT_FALSE(reader.HasMoreData()); | 213 EXPECT_FALSE(reader.HasMoreData()); |
214 | 214 |
215 // Check arguments. | 215 // Check arguments. |
216 EXPECT_EQ(ibus_text_.text(), ibus_text.text()); | 216 EXPECT_EQ(ibus_text_.text(), ibus_text.text()); |
217 EXPECT_EQ(cursor_pos_, cursor_pos); | 217 EXPECT_EQ(cursor_pos_, cursor_pos); |
218 EXPECT_EQ(is_visible_, is_visible); | 218 EXPECT_EQ(is_visible_, is_visible); |
219 EXPECT_EQ(mode_, | 219 EXPECT_EQ(mode_, |
220 static_cast<IBusEngineService::IBusEnginePreeditFocusOutMode>( | 220 static_cast<IBusEngineService::IBusEnginePreeditFocusOutMode>( |
221 preedit_mode)); | 221 preedit_mode)); |
222 } | 222 } |
223 | 223 |
224 private: | 224 private: |
225 const ibus::IBusText& ibus_text_; | 225 const IBusText& ibus_text_; |
226 uint32 cursor_pos_; | 226 uint32 cursor_pos_; |
227 bool is_visible_; | 227 bool is_visible_; |
228 IBusEngineService::IBusEnginePreeditFocusOutMode mode_; | 228 IBusEngineService::IBusEnginePreeditFocusOutMode mode_; |
229 | 229 |
230 DISALLOW_COPY_AND_ASSIGN(UpdatePreeditExpectation); | 230 DISALLOW_COPY_AND_ASSIGN(UpdatePreeditExpectation); |
231 }; | 231 }; |
232 | 232 |
233 // Used for UpdateAuxiliaryText signal message evaluation. | 233 // Used for UpdateAuxiliaryText signal message evaluation. |
234 class UpdateAuxiliaryTextExpectation { | 234 class UpdateAuxiliaryTextExpectation { |
235 public: | 235 public: |
236 UpdateAuxiliaryTextExpectation(const ibus::IBusText& ibus_text, | 236 UpdateAuxiliaryTextExpectation(const IBusText& ibus_text, |
237 bool is_visible) | 237 bool is_visible) |
238 : ibus_text_(ibus_text), is_visible_(is_visible) {} | 238 : ibus_text_(ibus_text), is_visible_(is_visible) {} |
239 | 239 |
240 // Evaluates the given |signal| is a valid message. | 240 // Evaluates the given |signal| is a valid message. |
241 void Evaluate(dbus::Signal* signal) { | 241 void Evaluate(dbus::Signal* signal) { |
242 ibus::IBusText ibus_text; | 242 IBusText ibus_text; |
243 bool is_visible = false; | 243 bool is_visible = false; |
244 | 244 |
245 // Read signal arguments. | 245 // Read signal arguments. |
246 dbus::MessageReader reader(signal); | 246 dbus::MessageReader reader(signal); |
247 EXPECT_TRUE(ibus::PopIBusText(&reader, &ibus_text)); | 247 EXPECT_TRUE(PopIBusText(&reader, &ibus_text)); |
248 EXPECT_TRUE(reader.PopBool(&is_visible)); | 248 EXPECT_TRUE(reader.PopBool(&is_visible)); |
249 EXPECT_FALSE(reader.HasMoreData()); | 249 EXPECT_FALSE(reader.HasMoreData()); |
250 | 250 |
251 // Check arguments. | 251 // Check arguments. |
252 EXPECT_EQ(ibus_text_.text(), ibus_text.text()); | 252 EXPECT_EQ(ibus_text_.text(), ibus_text.text()); |
253 EXPECT_EQ(is_visible_, is_visible); | 253 EXPECT_EQ(is_visible_, is_visible); |
254 } | 254 } |
255 | 255 |
256 private: | 256 private: |
257 const ibus::IBusText& ibus_text_; | 257 const IBusText& ibus_text_; |
258 bool is_visible_; | 258 bool is_visible_; |
259 | 259 |
260 DISALLOW_COPY_AND_ASSIGN(UpdateAuxiliaryTextExpectation); | 260 DISALLOW_COPY_AND_ASSIGN(UpdateAuxiliaryTextExpectation); |
261 }; | 261 }; |
262 | 262 |
263 // Used for UpdateLookupTable signal message evaluation. | 263 // Used for UpdateLookupTable signal message evaluation. |
264 class UpdateLookupTableExpectation { | 264 class UpdateLookupTableExpectation { |
265 public: | 265 public: |
266 UpdateLookupTableExpectation(const ibus::IBusLookupTable& lookup_table, | 266 UpdateLookupTableExpectation(const IBusLookupTable& lookup_table, |
267 bool is_visible) | 267 bool is_visible) |
268 : lookup_table_(lookup_table), is_visible_(is_visible) {} | 268 : lookup_table_(lookup_table), is_visible_(is_visible) {} |
269 | 269 |
270 // Evaluates the given |signal| is a valid message. | 270 // Evaluates the given |signal| is a valid message. |
271 void Evaluate(dbus::Signal* signal) { | 271 void Evaluate(dbus::Signal* signal) { |
272 ibus::IBusLookupTable lookup_table; | 272 IBusLookupTable lookup_table; |
273 bool is_visible = false; | 273 bool is_visible = false; |
274 | 274 |
275 // Read signal arguments. | 275 // Read signal arguments. |
276 dbus::MessageReader reader(signal); | 276 dbus::MessageReader reader(signal); |
277 EXPECT_TRUE(PopIBusLookupTable(&reader, &lookup_table)); | 277 EXPECT_TRUE(PopIBusLookupTable(&reader, &lookup_table)); |
278 EXPECT_TRUE(reader.PopBool(&is_visible)); | 278 EXPECT_TRUE(reader.PopBool(&is_visible)); |
279 EXPECT_FALSE(reader.HasMoreData()); | 279 EXPECT_FALSE(reader.HasMoreData()); |
280 | 280 |
281 // Check arguments. | 281 // Check arguments. |
282 EXPECT_EQ(lookup_table_.page_size(), lookup_table.page_size()); | 282 EXPECT_EQ(lookup_table_.page_size(), lookup_table.page_size()); |
283 EXPECT_EQ(lookup_table_.cursor_position(), lookup_table.cursor_position()); | 283 EXPECT_EQ(lookup_table_.cursor_position(), lookup_table.cursor_position()); |
284 EXPECT_EQ(lookup_table_.is_cursor_visible(), | 284 EXPECT_EQ(lookup_table_.is_cursor_visible(), |
285 lookup_table.is_cursor_visible()); | 285 lookup_table.is_cursor_visible()); |
286 EXPECT_EQ(is_visible_, is_visible); | 286 EXPECT_EQ(is_visible_, is_visible); |
287 } | 287 } |
288 | 288 |
289 private: | 289 private: |
290 const ibus::IBusLookupTable& lookup_table_; | 290 const IBusLookupTable& lookup_table_; |
291 bool is_visible_; | 291 bool is_visible_; |
292 | 292 |
293 DISALLOW_COPY_AND_ASSIGN(UpdateLookupTableExpectation); | 293 DISALLOW_COPY_AND_ASSIGN(UpdateLookupTableExpectation); |
294 }; | 294 }; |
295 | 295 |
296 // Used for UpdateProperty signal message evaluation. | 296 // Used for UpdateProperty signal message evaluation. |
297 class UpdatePropertyExpectation { | 297 class UpdatePropertyExpectation { |
298 public: | 298 public: |
299 explicit UpdatePropertyExpectation(const ibus::IBusProperty& property) | 299 explicit UpdatePropertyExpectation(const IBusProperty& property) |
300 : property_(property) {} | 300 : property_(property) {} |
301 | 301 |
302 // Evaluates the given |signal| is a valid message. | 302 // Evaluates the given |signal| is a valid message. |
303 void Evaluate(dbus::Signal* signal) { | 303 void Evaluate(dbus::Signal* signal) { |
304 ibus::IBusProperty property; | 304 IBusProperty property; |
305 | 305 |
306 // Read a signal argument. | 306 // Read a signal argument. |
307 dbus::MessageReader reader(signal); | 307 dbus::MessageReader reader(signal); |
308 EXPECT_TRUE(PopIBusProperty(&reader, &property)); | 308 EXPECT_TRUE(PopIBusProperty(&reader, &property)); |
309 EXPECT_FALSE(reader.HasMoreData()); | 309 EXPECT_FALSE(reader.HasMoreData()); |
310 | 310 |
311 // Check the argument. | 311 // Check the argument. |
312 EXPECT_EQ(property_.key(), property.key()); | 312 EXPECT_EQ(property_.key(), property.key()); |
313 EXPECT_EQ(property_.type(), property.type()); | 313 EXPECT_EQ(property_.type(), property.type()); |
314 EXPECT_EQ(property_.label(), property.label()); | 314 EXPECT_EQ(property_.label(), property.label()); |
315 EXPECT_EQ(property_.tooltip(), property.tooltip()); | 315 EXPECT_EQ(property_.tooltip(), property.tooltip()); |
316 EXPECT_EQ(property_.visible(), property.visible()); | 316 EXPECT_EQ(property_.visible(), property.visible()); |
317 EXPECT_EQ(property_.checked(), property.checked()); | 317 EXPECT_EQ(property_.checked(), property.checked()); |
318 } | 318 } |
319 | 319 |
320 private: | 320 private: |
321 const ibus::IBusProperty& property_; | 321 const IBusProperty& property_; |
322 | 322 |
323 DISALLOW_COPY_AND_ASSIGN(UpdatePropertyExpectation); | 323 DISALLOW_COPY_AND_ASSIGN(UpdatePropertyExpectation); |
324 }; | 324 }; |
325 | 325 |
326 // Used for ForwardKeyEvent signal message evaluation. | 326 // Used for ForwardKeyEvent signal message evaluation. |
327 class ForwardKeyEventExpectation { | 327 class ForwardKeyEventExpectation { |
328 public: | 328 public: |
329 ForwardKeyEventExpectation(uint32 keyval, uint32 keycode, uint32 state) | 329 ForwardKeyEventExpectation(uint32 keyval, uint32 keycode, uint32 state) |
330 : keyval_(keyval), | 330 : keyval_(keyval), |
331 keycode_(keycode), | 331 keycode_(keycode), |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 method_callback_map_[ibus::engine::kDisableMethod].Run( | 642 method_callback_map_[ibus::engine::kDisableMethod].Run( |
643 &method_call, | 643 &method_call, |
644 base::Bind(&MockResponseSender::Run, | 644 base::Bind(&MockResponseSender::Run, |
645 base::Unretained(&response_sender))); | 645 base::Unretained(&response_sender))); |
646 } | 646 } |
647 | 647 |
648 TEST_F(IBusEngineServiceTest, PropertyActivateTest) { | 648 TEST_F(IBusEngineServiceTest, PropertyActivateTest) { |
649 // Set expectations. | 649 // Set expectations. |
650 const uint32 kSerialNo = 1; | 650 const uint32 kSerialNo = 1; |
651 const std::string kPropertyName = "Property Name"; | 651 const std::string kPropertyName = "Property Name"; |
652 const IBusEngineHandlerInterface::IBusPropertyState kIBusPropertyState = | 652 const ibus::IBusPropertyState kIBusPropertyState = |
653 IBusEngineHandlerInterface::IBUS_PROPERTY_STATE_UNCHECKED; | 653 ibus::IBUS_PROPERTY_STATE_UNCHECKED; |
654 EXPECT_CALL(*engine_handler_, PropertyActivate(kPropertyName, | 654 EXPECT_CALL(*engine_handler_, PropertyActivate(kPropertyName, |
655 kIBusPropertyState)); | 655 kIBusPropertyState)); |
656 MockResponseSender response_sender; | 656 MockResponseSender response_sender; |
657 EmptyResponseExpectation response_expectation(kSerialNo); | 657 EmptyResponseExpectation response_expectation(kSerialNo); |
658 EXPECT_CALL(response_sender, Run(_)) | 658 EXPECT_CALL(response_sender, Run(_)) |
659 .WillOnce(Invoke(&response_expectation, | 659 .WillOnce(Invoke(&response_expectation, |
660 &EmptyResponseExpectation::Evaluate)); | 660 &EmptyResponseExpectation::Evaluate)); |
661 | 661 |
662 // Create method call; | 662 // Create method call; |
663 dbus::MethodCall method_call(ibus::engine::kServiceInterface, | 663 dbus::MethodCall method_call(ibus::engine::kServiceInterface, |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 kAnchorPos)).Times(0); | 1002 kAnchorPos)).Times(0); |
1003 EXPECT_CALL(response_sender, Run(_)).Times(0); | 1003 EXPECT_CALL(response_sender, Run(_)).Times(0); |
1004 method_callback_map_[ibus::engine::kSetSurroundingTextMethod].Run( | 1004 method_callback_map_[ibus::engine::kSetSurroundingTextMethod].Run( |
1005 &method_call, | 1005 &method_call, |
1006 base::Bind(&MockResponseSender::Run, | 1006 base::Bind(&MockResponseSender::Run, |
1007 base::Unretained(&response_sender))); | 1007 base::Unretained(&response_sender))); |
1008 } | 1008 } |
1009 | 1009 |
1010 TEST_F(IBusEngineServiceTest, RegisterProperties) { | 1010 TEST_F(IBusEngineServiceTest, RegisterProperties) { |
1011 // Set expectations. | 1011 // Set expectations. |
1012 ibus::IBusPropertyList property_list; | 1012 IBusPropertyList property_list; |
1013 property_list.push_back(new ibus::IBusProperty()); | 1013 property_list.push_back(new IBusProperty()); |
1014 property_list[0]->set_key("Sample Key"); | 1014 property_list[0]->set_key("Sample Key"); |
1015 property_list[0]->set_type(ibus::IBusProperty::IBUS_PROPERTY_TYPE_MENU); | 1015 property_list[0]->set_type(IBusProperty::IBUS_PROPERTY_TYPE_MENU); |
1016 property_list[0]->set_label("Sample Label"); | 1016 property_list[0]->set_label("Sample Label"); |
1017 property_list[0]->set_tooltip("Sample Tooltip"); | 1017 property_list[0]->set_tooltip("Sample Tooltip"); |
1018 property_list[0]->set_visible(true); | 1018 property_list[0]->set_visible(true); |
1019 property_list[0]->set_checked(true); | 1019 property_list[0]->set_checked(true); |
1020 | 1020 |
1021 RegisterPropertiesExpectation expectation(property_list); | 1021 RegisterPropertiesExpectation expectation(property_list); |
1022 EXPECT_CALL(*mock_exported_object_, SendSignal(_)) | 1022 EXPECT_CALL(*mock_exported_object_, SendSignal(_)) |
1023 .WillOnce(Invoke(&expectation, | 1023 .WillOnce(Invoke(&expectation, |
1024 &RegisterPropertiesExpectation::Evaluate)); | 1024 &RegisterPropertiesExpectation::Evaluate)); |
1025 // Emit signal. | 1025 // Emit signal. |
1026 service_->RegisterProperties(property_list); | 1026 service_->RegisterProperties(property_list); |
1027 } | 1027 } |
1028 | 1028 |
1029 TEST_F(IBusEngineServiceTest, UpdatePreeditTest) { | 1029 TEST_F(IBusEngineServiceTest, UpdatePreeditTest) { |
1030 // Set expectations. | 1030 // Set expectations. |
1031 ibus::IBusText ibus_text; | 1031 IBusText ibus_text; |
1032 ibus_text.set_text("Sample Text"); | 1032 ibus_text.set_text("Sample Text"); |
1033 const uint32 kCursorPos = 9; | 1033 const uint32 kCursorPos = 9; |
1034 const bool kIsVisible = false; | 1034 const bool kIsVisible = false; |
1035 const IBusEngineService::IBusEnginePreeditFocusOutMode kPreeditMode = | 1035 const IBusEngineService::IBusEnginePreeditFocusOutMode kPreeditMode = |
1036 IBusEngineService::IBUS_ENGINE_PREEEDIT_FOCUS_OUT_MODE_CLEAR; | 1036 IBusEngineService::IBUS_ENGINE_PREEEDIT_FOCUS_OUT_MODE_CLEAR; |
1037 UpdatePreeditExpectation expectation(ibus_text, kCursorPos, kIsVisible, | 1037 UpdatePreeditExpectation expectation(ibus_text, kCursorPos, kIsVisible, |
1038 kPreeditMode); | 1038 kPreeditMode); |
1039 EXPECT_CALL(*mock_exported_object_, SendSignal(_)) | 1039 EXPECT_CALL(*mock_exported_object_, SendSignal(_)) |
1040 .WillOnce(Invoke(&expectation, &UpdatePreeditExpectation::Evaluate)); | 1040 .WillOnce(Invoke(&expectation, &UpdatePreeditExpectation::Evaluate)); |
1041 | 1041 |
1042 // Emit signal. | 1042 // Emit signal. |
1043 service_->UpdatePreedit(ibus_text, kCursorPos, kIsVisible, kPreeditMode); | 1043 service_->UpdatePreedit(ibus_text, kCursorPos, kIsVisible, kPreeditMode); |
1044 } | 1044 } |
1045 | 1045 |
1046 TEST_F(IBusEngineServiceTest, UpdateAuxiliaryText) { | 1046 TEST_F(IBusEngineServiceTest, UpdateAuxiliaryText) { |
1047 ibus::IBusText ibus_text; | 1047 IBusText ibus_text; |
1048 ibus_text.set_text("Sample Text"); | 1048 ibus_text.set_text("Sample Text"); |
1049 const bool kIsVisible = false; | 1049 const bool kIsVisible = false; |
1050 UpdateAuxiliaryTextExpectation expectation(ibus_text, kIsVisible); | 1050 UpdateAuxiliaryTextExpectation expectation(ibus_text, kIsVisible); |
1051 | 1051 |
1052 EXPECT_CALL(*mock_exported_object_, SendSignal(_)) | 1052 EXPECT_CALL(*mock_exported_object_, SendSignal(_)) |
1053 .WillOnce(Invoke(&expectation, | 1053 .WillOnce(Invoke(&expectation, |
1054 &UpdateAuxiliaryTextExpectation::Evaluate)); | 1054 &UpdateAuxiliaryTextExpectation::Evaluate)); |
1055 | 1055 |
1056 // Emit signal. | 1056 // Emit signal. |
1057 service_->UpdateAuxiliaryText(ibus_text, kIsVisible); | 1057 service_->UpdateAuxiliaryText(ibus_text, kIsVisible); |
1058 } | 1058 } |
1059 | 1059 |
1060 TEST_F(IBusEngineServiceTest, UpdateLookupTableTest) { | 1060 TEST_F(IBusEngineServiceTest, UpdateLookupTableTest) { |
1061 ibus::IBusLookupTable lookup_table; | 1061 IBusLookupTable lookup_table; |
1062 lookup_table.set_page_size(10); | 1062 lookup_table.set_page_size(10); |
1063 lookup_table.set_cursor_position(2); | 1063 lookup_table.set_cursor_position(2); |
1064 lookup_table.set_is_cursor_visible(false); | 1064 lookup_table.set_is_cursor_visible(false); |
1065 const bool kIsVisible = true; | 1065 const bool kIsVisible = true; |
1066 | 1066 |
1067 UpdateLookupTableExpectation expectation(lookup_table, kIsVisible); | 1067 UpdateLookupTableExpectation expectation(lookup_table, kIsVisible); |
1068 EXPECT_CALL(*mock_exported_object_, SendSignal(_)) | 1068 EXPECT_CALL(*mock_exported_object_, SendSignal(_)) |
1069 .WillOnce(Invoke(&expectation, | 1069 .WillOnce(Invoke(&expectation, |
1070 &UpdateLookupTableExpectation::Evaluate)); | 1070 &UpdateLookupTableExpectation::Evaluate)); |
1071 | 1071 |
1072 // Emit signal. | 1072 // Emit signal. |
1073 service_->UpdateLookupTable(lookup_table, kIsVisible); | 1073 service_->UpdateLookupTable(lookup_table, kIsVisible); |
1074 } | 1074 } |
1075 | 1075 |
1076 TEST_F(IBusEngineServiceTest, UpdatePropertyTest) { | 1076 TEST_F(IBusEngineServiceTest, UpdatePropertyTest) { |
1077 ibus::IBusProperty property; | 1077 IBusProperty property; |
1078 property.set_key("Sample Key"); | 1078 property.set_key("Sample Key"); |
1079 property.set_type(ibus::IBusProperty::IBUS_PROPERTY_TYPE_MENU); | 1079 property.set_type(IBusProperty::IBUS_PROPERTY_TYPE_MENU); |
1080 property.set_label("Sample Label"); | 1080 property.set_label("Sample Label"); |
1081 property.set_tooltip("Sample Tooltip"); | 1081 property.set_tooltip("Sample Tooltip"); |
1082 property.set_visible(true); | 1082 property.set_visible(true); |
1083 property.set_checked(true); | 1083 property.set_checked(true); |
1084 | 1084 |
1085 UpdatePropertyExpectation expectation(property); | 1085 UpdatePropertyExpectation expectation(property); |
1086 EXPECT_CALL(*mock_exported_object_, SendSignal(_)) | 1086 EXPECT_CALL(*mock_exported_object_, SendSignal(_)) |
1087 .WillOnce(Invoke(&expectation, | 1087 .WillOnce(Invoke(&expectation, |
1088 &UpdatePropertyExpectation::Evaluate)); | 1088 &UpdatePropertyExpectation::Evaluate)); |
1089 | 1089 |
(...skipping 20 matching lines...) Expand all Loading... |
1110 RequireSurroundingTextExpectation expectation; | 1110 RequireSurroundingTextExpectation expectation; |
1111 EXPECT_CALL(*mock_exported_object_, SendSignal(_)) | 1111 EXPECT_CALL(*mock_exported_object_, SendSignal(_)) |
1112 .WillOnce(Invoke(&expectation, | 1112 .WillOnce(Invoke(&expectation, |
1113 &RequireSurroundingTextExpectation::Evaluate)); | 1113 &RequireSurroundingTextExpectation::Evaluate)); |
1114 | 1114 |
1115 // Emit signal. | 1115 // Emit signal. |
1116 service_->RequireSurroundingText(); | 1116 service_->RequireSurroundingText(); |
1117 } | 1117 } |
1118 | 1118 |
1119 } // namespace chromeos | 1119 } // namespace chromeos |
OLD | NEW |