| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chromeos/dbus/ibus/mock_ibus_engine_service.h" | |
| 6 | |
| 7 #include "chromeos/dbus/ibus/ibus_text.h" | |
| 8 | |
| 9 namespace chromeos { | |
| 10 | |
| 11 MockIBusEngineService::MockIBusEngineService() | |
| 12 : update_preedit_call_count_(0), | |
| 13 update_auxiliary_text_call_count_(0), | |
| 14 forward_key_event_call_count_(0), | |
| 15 delete_surrounding_text_call_count_(0), | |
| 16 last_update_preedit_arg_(new UpdatePreeditArg()), | |
| 17 last_update_aux_text_arg_(new UpdateAuxiliaryTextArg()), | |
| 18 last_delete_surrounding_text_arg_(new DeleteSurroundingTextArg()), | |
| 19 current_engine_(NULL) { | |
| 20 } | |
| 21 | |
| 22 MockIBusEngineService::~MockIBusEngineService() { | |
| 23 } | |
| 24 | |
| 25 void MockIBusEngineService::SetEngine(IBusEngineHandlerInterface* handler) { | |
| 26 current_engine_ = handler; | |
| 27 } | |
| 28 | |
| 29 void MockIBusEngineService::UnsetEngine(IBusEngineHandlerInterface* handler) { | |
| 30 current_engine_ = NULL; | |
| 31 } | |
| 32 | |
| 33 void MockIBusEngineService::UpdatePreedit(const IBusText& ibus_text, | |
| 34 uint32 cursor_pos, | |
| 35 bool is_visible, | |
| 36 IBusEnginePreeditFocusOutMode mode) { | |
| 37 ++update_preedit_call_count_; | |
| 38 last_update_preedit_arg_->ibus_text.CopyFrom(ibus_text); | |
| 39 last_update_preedit_arg_->cursor_pos = cursor_pos; | |
| 40 last_update_preedit_arg_->is_visible = is_visible; | |
| 41 } | |
| 42 | |
| 43 void MockIBusEngineService::UpdateAuxiliaryText(const IBusText& ibus_text, | |
| 44 bool is_visible) { | |
| 45 ++update_auxiliary_text_call_count_; | |
| 46 last_update_aux_text_arg_->ibus_text.CopyFrom(ibus_text); | |
| 47 last_update_aux_text_arg_->is_visible = is_visible; | |
| 48 } | |
| 49 | |
| 50 void MockIBusEngineService::ForwardKeyEvent(uint32 keyval, | |
| 51 uint32 keycode, | |
| 52 uint32 state) { | |
| 53 ++forward_key_event_call_count_; | |
| 54 } | |
| 55 | |
| 56 void MockIBusEngineService::RequireSurroundingText() { | |
| 57 } | |
| 58 | |
| 59 void MockIBusEngineService::DeleteSurroundingText(int32 offset,uint32 length) { | |
| 60 ++delete_surrounding_text_call_count_; | |
| 61 last_delete_surrounding_text_arg_->offset = offset; | |
| 62 last_delete_surrounding_text_arg_->length = length; | |
| 63 } | |
| 64 | |
| 65 IBusEngineHandlerInterface* MockIBusEngineService::GetEngine() const { | |
| 66 return current_engine_; | |
| 67 } | |
| 68 | |
| 69 void MockIBusEngineService::Clear() { | |
| 70 update_preedit_call_count_ = 0; | |
| 71 update_auxiliary_text_call_count_ = 0; | |
| 72 forward_key_event_call_count_ = 0; | |
| 73 delete_surrounding_text_call_count_ = 0; | |
| 74 last_update_preedit_arg_.reset(new UpdatePreeditArg()); | |
| 75 last_update_aux_text_arg_.reset(new UpdateAuxiliaryTextArg()); | |
| 76 last_delete_surrounding_text_arg_.reset(new DeleteSurroundingTextArg()); | |
| 77 } | |
| 78 | |
| 79 } // namespace chromeos | |
| OLD | NEW |