diff options
author | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-03 20:01:55 +0000 |
---|---|---|
committer | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-03 20:01:55 +0000 |
commit | ed06f38f4e05a4eeb717412ce64eea157b7b1ae9 (patch) | |
tree | 6c94b769f62d320557aba0b607634fa27aae79b2 /chromeos/ime | |
parent | bca77414e34b5d210c1b556441064cf2ae61ffbe (diff) | |
download | chromium_src-ed06f38f4e05a4eeb717412ce64eea157b7b1ae9.zip chromium_src-ed06f38f4e05a4eeb717412ce64eea157b7b1ae9.tar.gz chromium_src-ed06f38f4e05a4eeb717412ce64eea157b7b1ae9.tar.bz2 |
Adding new mock classes for input method handlers.
We need to migrate current tests to ibus independent implementation.
Following tests currently depends to ibus modules.
- ui/base/ime/input_method_ibus_unittests.cc
- chrome/browser/chromeos/input_method/input_method_engein_ibus_browsertest.cc
(to be renamed to input_method_engine_browsertest.cc)
BUG=275262
TEST=None
Review URL: https://chromiumcodereview.appspot.com/23822002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221004 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/ime')
-rw-r--r-- | chromeos/ime/mock_ime_candidate_window_handler.cc | 60 | ||||
-rw-r--r-- | chromeos/ime/mock_ime_candidate_window_handler.h | 75 | ||||
-rw-r--r-- | chromeos/ime/mock_ime_engine_handler.cc | 84 | ||||
-rw-r--r-- | chromeos/ime/mock_ime_engine_handler.h | 90 | ||||
-rw-r--r-- | chromeos/ime/mock_ime_input_context_handler.cc | 68 | ||||
-rw-r--r-- | chromeos/ime/mock_ime_input_context_handler.h | 90 | ||||
-rw-r--r-- | chromeos/ime/mock_ime_property_handler.cc | 34 | ||||
-rw-r--r-- | chromeos/ime/mock_ime_property_handler.h | 40 |
8 files changed, 541 insertions, 0 deletions
diff --git a/chromeos/ime/mock_ime_candidate_window_handler.cc b/chromeos/ime/mock_ime_candidate_window_handler.cc new file mode 100644 index 0000000..d67c942 --- /dev/null +++ b/chromeos/ime/mock_ime_candidate_window_handler.cc @@ -0,0 +1,60 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chromeos/ime/mock_ime_candidate_window_handler.h" + +namespace chromeos { + +MockIMECandidateWindowHandler::MockIMECandidateWindowHandler() + : set_cursor_location_call_count_(0), + update_lookup_table_call_count_(0), + update_auxiliary_text_call_count_(0) { +} + +MockIMECandidateWindowHandler::~MockIMECandidateWindowHandler() { + +} + +void MockIMECandidateWindowHandler::UpdateLookupTable( + const IBusLookupTable& table, + bool visible) { + ++update_lookup_table_call_count_; + last_update_lookup_table_arg_.lookup_table.CopyFrom(table); + last_update_lookup_table_arg_.is_visible = visible; +} + +void MockIMECandidateWindowHandler::HideLookupTable() { +} + +void MockIMECandidateWindowHandler::UpdateAuxiliaryText(const std::string& text, + bool visible) { + ++update_auxiliary_text_call_count_; + last_update_auxiliary_text_arg_.text = text; + last_update_auxiliary_text_arg_.is_visible = visible; +} + +void MockIMECandidateWindowHandler::HideAuxiliaryText() { +} + +void MockIMECandidateWindowHandler::UpdatePreeditText(const std::string& text, + uint32 cursor_pos, + bool visible) { +} + +void MockIMECandidateWindowHandler::HidePreeditText() { +} + +void MockIMECandidateWindowHandler::SetCursorLocation( + const ibus::Rect& cursor_location, + const ibus::Rect& composition_head) { + ++set_cursor_location_call_count_; +} + +void MockIMECandidateWindowHandler::Reset() { + set_cursor_location_call_count_ = 0; + update_lookup_table_call_count_ = 0; + update_auxiliary_text_call_count_ = 0; +} + +} // namespace chromeos diff --git a/chromeos/ime/mock_ime_candidate_window_handler.h b/chromeos/ime/mock_ime_candidate_window_handler.h new file mode 100644 index 0000000..6ee51e5 --- /dev/null +++ b/chromeos/ime/mock_ime_candidate_window_handler.h @@ -0,0 +1,75 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROMEOS_IME_MOCK_IME_CANDIDATE_WINDOW_HANDLER_H_ +#define CHROMEOS_IME_MOCK_IME_CANDIDATE_WINDOW_HANDLER_H_ + +#include "chromeos/dbus/ibus/ibus_lookup_table.h" +#include "chromeos/ime/ibus_bridge.h" + +namespace chromeos { + +class MockIMECandidateWindowHandler + : public IBusPanelCandidateWindowHandlerInterface { + public: + struct UpdateLookupTableArg { + IBusLookupTable lookup_table; + bool is_visible; + }; + + struct UpdateAuxiliaryTextArg { + std::string text; + bool is_visible; + }; + + MockIMECandidateWindowHandler(); + virtual ~MockIMECandidateWindowHandler(); + + // IBusPanelCandidateWindowHandlerInterface override. + virtual void UpdateLookupTable(const IBusLookupTable& table, + bool visible) OVERRIDE; + virtual void HideLookupTable() OVERRIDE; + virtual void UpdateAuxiliaryText(const std::string& text, + bool visible) OVERRIDE; + virtual void HideAuxiliaryText() OVERRIDE; + virtual void UpdatePreeditText(const std::string& text, uint32 cursor_pos, + bool visible) OVERRIDE; + virtual void HidePreeditText() OVERRIDE; + virtual void SetCursorLocation(const ibus::Rect& cursor_location, + const ibus::Rect& composition_head) OVERRIDE; + + int set_cursor_location_call_count() const { + return set_cursor_location_call_count_; + } + + int update_lookup_table_call_count() const { + return update_lookup_table_call_count_; + } + + int update_auxiliary_text_call_count() const { + return update_auxiliary_text_call_count_; + } + + const UpdateLookupTableArg& last_update_lookup_table_arg() { + return last_update_lookup_table_arg_; + } + + const UpdateAuxiliaryTextArg& last_update_auxiliary_text_arg() { + return last_update_auxiliary_text_arg_; + } + + // Resets all call count. + void Reset(); + + private: + int set_cursor_location_call_count_; + int update_lookup_table_call_count_; + int update_auxiliary_text_call_count_; + UpdateLookupTableArg last_update_lookup_table_arg_; + UpdateAuxiliaryTextArg last_update_auxiliary_text_arg_; +}; + +} // namespace chromeos + +#endif // CHROMEOS_IME_MOCK_IME_CANDIDATE_WINDOW_HANDLER_H_ diff --git a/chromeos/ime/mock_ime_engine_handler.cc b/chromeos/ime/mock_ime_engine_handler.cc new file mode 100644 index 0000000..4f730ca --- /dev/null +++ b/chromeos/ime/mock_ime_engine_handler.cc @@ -0,0 +1,84 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chromeos/ime/mock_ime_engine_handler.h" + +namespace chromeos { + +MockIMEEngineHandler::MockIMEEngineHandler() + : focus_in_call_count_(0), + focus_out_call_count_(0), + set_surrounding_text_call_count_(0), + process_key_event_call_count_(0), + reset_call_count_(0), + last_set_surrounding_cursor_pos_(0), + last_set_surrounding_anchor_pos_(0), + last_processed_keysym_(0), + last_processed_keycode_(0), + last_processed_state_(0) { +} + +MockIMEEngineHandler::~MockIMEEngineHandler() { +} + +void MockIMEEngineHandler::FocusIn() { + ++focus_in_call_count_; +} + +void MockIMEEngineHandler::FocusOut() { + ++focus_out_call_count_; +} + +void MockIMEEngineHandler::Enable() { +} + +void MockIMEEngineHandler::Disable() { +} + +void MockIMEEngineHandler::PropertyActivate( + const std::string& property_name, + ibus::IBusPropertyState property_state) { +} + +void MockIMEEngineHandler::PropertyShow(const std::string& property_name) { +} + +void MockIMEEngineHandler::PropertyHide(const std::string& property_name) { +} + +void MockIMEEngineHandler::SetCapability(IBusCapability capability) { +} + +void MockIMEEngineHandler::Reset() { + ++reset_call_count_; +} + +void MockIMEEngineHandler::ProcessKeyEvent( + uint32 keysym, + uint32 keycode, + uint32 state, + const KeyEventDoneCallback& callback) { + ++process_key_event_call_count_; + last_processed_keysym_ = keysym; + last_processed_keycode_ = keycode; + last_processed_state_ = state; + last_passed_callback_ = callback; +} + +void MockIMEEngineHandler::CandidateClicked(uint32 index, + ibus::IBusMouseButton button, + uint32 state) { +} + +void MockIMEEngineHandler::SetSurroundingText(const std::string& text, + uint32 cursor_pos, + uint32 anchor_pos) { + ++set_surrounding_text_call_count_; + last_set_surrounding_text_ = text; + last_set_surrounding_cursor_pos_ = cursor_pos; + last_set_surrounding_anchor_pos_ = anchor_pos; +} + +} // namespace chromeos + diff --git a/chromeos/ime/mock_ime_engine_handler.h b/chromeos/ime/mock_ime_engine_handler.h new file mode 100644 index 0000000..1a58047 --- /dev/null +++ b/chromeos/ime/mock_ime_engine_handler.h @@ -0,0 +1,90 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROMEOS_IME_MOCK_IME_ENGINE_HANDLER_H_ +#define CHROMEOS_IME_MOCK_IME_ENGINE_HANDLER_H_ + +#include "chromeos/ime/ibus_bridge.h" + +namespace chromeos { + +class MockIMEEngineHandler : public IBusEngineHandlerInterface { + public: + MockIMEEngineHandler(); + virtual ~MockIMEEngineHandler(); + + virtual void FocusIn() OVERRIDE; + virtual void FocusOut() OVERRIDE; + virtual void Enable() OVERRIDE; + virtual void Disable() OVERRIDE; + virtual void PropertyActivate( + const std::string& property_name, + ibus::IBusPropertyState property_state) OVERRIDE; + virtual void PropertyShow(const std::string& property_name) OVERRIDE; + virtual void PropertyHide(const std::string& property_name) OVERRIDE; + virtual void SetCapability(IBusCapability capability) OVERRIDE; + virtual void Reset() OVERRIDE; + virtual void ProcessKeyEvent(uint32 keysym, uint32 keycode, uint32 state, + const KeyEventDoneCallback& callback) OVERRIDE; + virtual void CandidateClicked(uint32 index, ibus::IBusMouseButton button, + uint32 state) OVERRIDE; + virtual void SetSurroundingText(const std::string& text, uint32 cursor_pos, + uint32 anchor_pos) OVERRIDE; + + int focus_in_call_count() const { return focus_in_call_count_; } + int focus_out_call_count() const { return focus_out_call_count_; } + int reset_call_count() const { return reset_call_count_; } + int set_surrounding_text_call_count() const { + return set_surrounding_text_call_count_; + } + int process_key_event_call_count() const { + return process_key_event_call_count_; + } + + std::string last_set_surrounding_text() const { + return last_set_surrounding_text_; + } + + uint32 last_set_surrounding_cursor_pos() const { + return last_set_surrounding_cursor_pos_; + } + + uint32 last_set_surrounding_anchor_pos() const { + return last_set_surrounding_anchor_pos_; + } + + uint32 last_processed_keysym() const { + return last_processed_keysym_; + } + + uint32 last_processed_keycode() const { + return last_processed_keycode_; + } + + uint32 last_processed_state() const { + return last_processed_state_; + } + + const KeyEventDoneCallback& last_passed_callback() const { + return last_passed_callback_; + } + + private: + int focus_in_call_count_; + int focus_out_call_count_; + int set_surrounding_text_call_count_; + int process_key_event_call_count_; + int reset_call_count_; + std::string last_set_surrounding_text_; + uint32 last_set_surrounding_cursor_pos_; + uint32 last_set_surrounding_anchor_pos_; + uint32 last_processed_keysym_; + uint32 last_processed_keycode_; + uint32 last_processed_state_; + KeyEventDoneCallback last_passed_callback_; +}; + +} // namespace chromeos + +#endif // CHROMEOS_IME_MOCK_IME_ENGINE_HANDLER_H_ diff --git a/chromeos/ime/mock_ime_input_context_handler.cc b/chromeos/ime/mock_ime_input_context_handler.cc new file mode 100644 index 0000000..67281c1 --- /dev/null +++ b/chromeos/ime/mock_ime_input_context_handler.cc @@ -0,0 +1,68 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chromeos/ime/mock_ime_input_context_handler.h" + +#include "chromeos/dbus/ibus/ibus_text.h" + +namespace chromeos { + +MockIMEInputContextHandler::MockIMEInputContextHandler() + : commit_text_call_count_(0), + forward_key_event_call_count_(0), + update_preedit_text_call_count_(0), + show_preedit_text_call_count_(0), + hide_preedit_text_call_count_(0), + delete_surrounding_text_call_count_(0) { +} + +MockIMEInputContextHandler::~MockIMEInputContextHandler() { +} + +void MockIMEInputContextHandler::CommitText(const IBusText& text) { + ++commit_text_call_count_; + last_commit_text_ = text.text(); +} + +void MockIMEInputContextHandler::ForwardKeyEvent(uint32 keyval, + uint32 keycode, + uint32 state) { + ++forward_key_event_call_count_; +} + +void MockIMEInputContextHandler::UpdatePreeditText(const IBusText& text, + uint32 cursor_pos, + bool visible) { + ++update_preedit_text_call_count_; + last_update_preedit_arg_.ibus_text.CopyFrom(text); + last_update_preedit_arg_.cursor_pos = cursor_pos; + last_update_preedit_arg_.is_visible = visible; +} + +void MockIMEInputContextHandler::ShowPreeditText() { + ++show_preedit_text_call_count_; +} + +void MockIMEInputContextHandler::HidePreeditText() { + ++hide_preedit_text_call_count_; +} + +void MockIMEInputContextHandler::DeleteSurroundingText(int32 offset, + uint32 length) { + ++delete_surrounding_text_call_count_; + last_delete_surrounding_text_arg_.offset = offset; + last_delete_surrounding_text_arg_.length = length; +} + +void MockIMEInputContextHandler::Reset() { + commit_text_call_count_ = 0; + forward_key_event_call_count_ = 0; + update_preedit_text_call_count_ = 0; + show_preedit_text_call_count_ = 0; + hide_preedit_text_call_count_ = 0; + delete_surrounding_text_call_count_ = 0; + last_commit_text_.clear(); +} + +} // namespace chromeos diff --git a/chromeos/ime/mock_ime_input_context_handler.h b/chromeos/ime/mock_ime_input_context_handler.h new file mode 100644 index 0000000..054c2ed --- /dev/null +++ b/chromeos/ime/mock_ime_input_context_handler.h @@ -0,0 +1,90 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROMEOS_IME_MOCK_IME_INPUT_CONTEXT_HANDLER_H_ +#define CHROMEOS_IME_MOCK_IME_INPUT_CONTEXT_HANDLER_H_ + +#include "chromeos/dbus/ibus/ibus_text.h" +#include "chromeos/ime/ibus_bridge.h" + +namespace chromeos { + +class CHROMEOS_EXPORT MockIMEInputContextHandler + : public IBusInputContextHandlerInterface { + public: + struct UpdatePreeditTextArg { + IBusText ibus_text; + uint32 cursor_pos; + bool is_visible; + }; + + struct DeleteSurroundingTextArg { + int32 offset; + uint32 length; + }; + + MockIMEInputContextHandler(); + virtual ~MockIMEInputContextHandler(); + + virtual void CommitText(const IBusText& text) OVERRIDE; + virtual void ForwardKeyEvent(uint32 keyval, uint32 keycode, + uint32 state) OVERRIDE; + virtual void UpdatePreeditText(const IBusText& text, + uint32 cursor_pos, + bool visible) OVERRIDE; + virtual void ShowPreeditText() OVERRIDE; + virtual void HidePreeditText() OVERRIDE; + virtual void DeleteSurroundingText(int32 offset, uint32 length) OVERRIDE; + + int commit_text_call_count() const { return commit_text_call_count_; } + int forward_key_event_call_count() const { + return forward_key_event_call_count_; + } + + int update_preedit_text_call_count() const { + return update_preedit_text_call_count_; + } + + int show_preedit_text_call_count() const { + return show_preedit_text_call_count_; + } + + int hide_preedit_text_call_count() const { + return hide_preedit_text_call_count_; + } + + int delete_surrounding_text_call_count() const { + return delete_surrounding_text_call_count_; + } + + const std::string& last_commit_text() const { + return last_commit_text_; + }; + + const UpdatePreeditTextArg& last_update_preedit_arg() const { + return last_update_preedit_arg_; + } + + const DeleteSurroundingTextArg& last_delete_surrounding_text_arg() const { + return last_delete_surrounding_text_arg_; + } + + // Resets all call count. + void Reset(); + + private: + int commit_text_call_count_; + int forward_key_event_call_count_; + int update_preedit_text_call_count_; + int show_preedit_text_call_count_; + int hide_preedit_text_call_count_; + int delete_surrounding_text_call_count_; + std::string last_commit_text_; + UpdatePreeditTextArg last_update_preedit_arg_; + DeleteSurroundingTextArg last_delete_surrounding_text_arg_; +}; + +} // namespace chromeos + +#endif // CHROMEOS_IME_MOCK_IME_INPUT_CONTEXT_HANDLER_H_ diff --git a/chromeos/ime/mock_ime_property_handler.cc b/chromeos/ime/mock_ime_property_handler.cc new file mode 100644 index 0000000..ead2acd --- /dev/null +++ b/chromeos/ime/mock_ime_property_handler.cc @@ -0,0 +1,34 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chromeos/ime/mock_ime_property_handler.h" + +namespace chromeos { + +MockIMEPropertyHandler::MockIMEPropertyHandler() + : register_properties_call_count_(0) { +} + +MockIMEPropertyHandler::~MockIMEPropertyHandler() { +} + +void MockIMEPropertyHandler::RegisterProperties( + const IBusPropertyList& properties) { + ++register_properties_call_count_; + last_registered_properties_.clear(); + last_registered_properties_.resize(properties.size()); + for (size_t i = 0; i < properties.size(); ++i) { + last_registered_properties_[i] = new IBusProperty(); + last_registered_properties_[i]->CopyFrom(*properties[i]); + } +} + +void MockIMEPropertyHandler::UpdateProperty(const IBusProperty& property) { +} + +void MockIMEPropertyHandler::Reset() { + register_properties_call_count_ = 0; +} + +} // namespace chromeos diff --git a/chromeos/ime/mock_ime_property_handler.h b/chromeos/ime/mock_ime_property_handler.h new file mode 100644 index 0000000..e1d69c7 --- /dev/null +++ b/chromeos/ime/mock_ime_property_handler.h @@ -0,0 +1,40 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROMEOS_IME_MOCK_IME_PROPERTY_HANDLER_H_ +#define CHROMEOS_IME_MOCK_IME_PROPERTY_HANDLER_H_ + +#include "chromeos/dbus/ibus/ibus_property.h" +#include "chromeos/ime/ibus_bridge.h" + +namespace chromeos { + +class CHROMEOS_EXPORT MockIMEPropertyHandler : + public IBusPanelPropertyHandlerInterface { + public: + MockIMEPropertyHandler(); + virtual ~MockIMEPropertyHandler(); + + virtual void RegisterProperties(const IBusPropertyList& properties) OVERRIDE; + virtual void UpdateProperty(const IBusProperty& property) OVERRIDE; + + int register_properties_call_count() { + return register_properties_call_count_; + } + + const IBusPropertyList& last_registered_properties() { + return last_registered_properties_; + } + + // Resets all call count. + void Reset(); + + private: + int register_properties_call_count_; + IBusPropertyList last_registered_properties_; +}; + +} // namespace chromeos + +#endif // CHROMEOS_IME_MOCK_IME_PROPERTY_HANDLER_H_ |