| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 private: | 159 private: |
| 160 bool expected_value_; | 160 bool expected_value_; |
| 161 | 161 |
| 162 DISALLOW_COPY_AND_ASSIGN(ProcessKeyEventHandler); | 162 DISALLOW_COPY_AND_ASSIGN(ProcessKeyEventHandler); |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 // Used for mocking asynchronous ProcessKeyEventHandler. | 165 // Used for mocking asynchronous ProcessKeyEventHandler. |
| 166 class DelayProcessKeyEventHandler { | 166 class DelayProcessKeyEventHandler { |
| 167 public: | 167 public: |
| 168 DelayProcessKeyEventHandler(bool expected_value, | 168 DelayProcessKeyEventHandler(bool expected_value, |
| 169 MessageLoop* message_loop) | 169 base::MessageLoop* message_loop) |
| 170 : expected_value_(expected_value), | 170 : expected_value_(expected_value), |
| 171 message_loop_(message_loop) { | 171 message_loop_(message_loop) { |
| 172 } | 172 } |
| 173 | 173 |
| 174 void ProcessKeyEvent( | 174 void ProcessKeyEvent( |
| 175 uint32 keysym, | 175 uint32 keysym, |
| 176 uint32 keycode, | 176 uint32 keycode, |
| 177 uint32 state, | 177 uint32 state, |
| 178 const IBusEngineHandlerInterface::KeyEventDoneCallback& callback) { | 178 const IBusEngineHandlerInterface::KeyEventDoneCallback& callback) { |
| 179 message_loop_->PostTask(FROM_HERE, base::Bind(callback, expected_value_)); | 179 message_loop_->PostTask(FROM_HERE, base::Bind(callback, expected_value_)); |
| 180 } | 180 } |
| 181 | 181 |
| 182 private: | 182 private: |
| 183 bool expected_value_; | 183 bool expected_value_; |
| 184 MessageLoop* message_loop_; | 184 base::MessageLoop* message_loop_; |
| 185 | 185 |
| 186 DISALLOW_COPY_AND_ASSIGN(DelayProcessKeyEventHandler); | 186 DISALLOW_COPY_AND_ASSIGN(DelayProcessKeyEventHandler); |
| 187 }; | 187 }; |
| 188 | 188 |
| 189 // Used for UpdatePreedit signal message evaluation. | 189 // Used for UpdatePreedit signal message evaluation. |
| 190 class UpdatePreeditExpectation { | 190 class UpdatePreeditExpectation { |
| 191 public: | 191 public: |
| 192 UpdatePreeditExpectation( | 192 UpdatePreeditExpectation( |
| 193 const IBusText& ibus_text, | 193 const IBusText& ibus_text, |
| 194 uint32 cursor_pos, | 194 uint32 cursor_pos, |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 protected: | 487 protected: |
| 488 // The service to be tested. | 488 // The service to be tested. |
| 489 scoped_ptr<IBusEngineService> service_; | 489 scoped_ptr<IBusEngineService> service_; |
| 490 // The mock engine handler. Do not free, this is owned by IBusEngineService. | 490 // The mock engine handler. Do not free, this is owned by IBusEngineService. |
| 491 scoped_ptr<MockIBusEngineHandler> engine_handler_; | 491 scoped_ptr<MockIBusEngineHandler> engine_handler_; |
| 492 // The mock bus. | 492 // The mock bus. |
| 493 scoped_refptr<dbus::MockBus> mock_bus_; | 493 scoped_refptr<dbus::MockBus> mock_bus_; |
| 494 // The mock exported object. | 494 // The mock exported object. |
| 495 scoped_refptr<dbus::MockExportedObject> mock_exported_object_; | 495 scoped_refptr<dbus::MockExportedObject> mock_exported_object_; |
| 496 // A message loop to emulate asynchronous behavior. | 496 // A message loop to emulate asynchronous behavior. |
| 497 MessageLoop message_loop_; | 497 base::MessageLoop message_loop_; |
| 498 // The map from method call to method call handler. | 498 // The map from method call to method call handler. |
| 499 std::map<std::string, dbus::ExportedObject::MethodCallCallback> | 499 std::map<std::string, dbus::ExportedObject::MethodCallCallback> |
| 500 method_callback_map_; | 500 method_callback_map_; |
| 501 | 501 |
| 502 private: | 502 private: |
| 503 // Used to implement the mock method call. | 503 // Used to implement the mock method call. |
| 504 void OnMethodExported( | 504 void OnMethodExported( |
| 505 const std::string& interface_name, | 505 const std::string& interface_name, |
| 506 const std::string& method_name, | 506 const std::string& method_name, |
| 507 const dbus::ExportedObject::MethodCallCallback& method_callback, | 507 const dbus::ExportedObject::MethodCallCallback& method_callback, |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 RequireSurroundingTextExpectation expectation; | 1112 RequireSurroundingTextExpectation expectation; |
| 1113 EXPECT_CALL(*mock_exported_object_, SendSignal(_)) | 1113 EXPECT_CALL(*mock_exported_object_, SendSignal(_)) |
| 1114 .WillOnce(Invoke(&expectation, | 1114 .WillOnce(Invoke(&expectation, |
| 1115 &RequireSurroundingTextExpectation::Evaluate)); | 1115 &RequireSurroundingTextExpectation::Evaluate)); |
| 1116 | 1116 |
| 1117 // Emit signal. | 1117 // Emit signal. |
| 1118 service_->RequireSurroundingText(); | 1118 service_->RequireSurroundingText(); |
| 1119 } | 1119 } |
| 1120 | 1120 |
| 1121 } // namespace chromeos | 1121 } // namespace chromeos |
| OLD | NEW |