mock_input_method_manager.h revision 424c4d7b64af9d0d8fd9624f381f469654d5e3d2
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#ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ 6#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ 7 8#include "chrome/browser/chromeos/input_method/input_method_util.h" 9#include "chromeos/ime/fake_input_method_delegate.h" 10#include "chromeos/ime/input_method_manager.h" 11#include "chromeos/ime/input_method_whitelist.h" 12#include "chromeos/ime/mock_xkeyboard.h" 13 14namespace chromeos { 15namespace input_method { 16 17// The mock implementation of InputMethodManager for testing. 18class MockInputMethodManager : public InputMethodManager { 19 public: 20 MockInputMethodManager(); 21 virtual ~MockInputMethodManager(); 22 23 // InputMethodManager override: 24 virtual void AddObserver(InputMethodManager::Observer* observer) OVERRIDE; 25 virtual void AddCandidateWindowObserver( 26 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE; 27 virtual void RemoveObserver(InputMethodManager::Observer* observer) OVERRIDE; 28 virtual void RemoveCandidateWindowObserver( 29 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE; 30 virtual scoped_ptr<InputMethodDescriptors> 31 GetSupportedInputMethods() const OVERRIDE; 32 virtual scoped_ptr<InputMethodDescriptors> 33 GetActiveInputMethods() const OVERRIDE; 34 virtual const std::vector<std::string>& GetActiveInputMethodIds() const 35 OVERRIDE; 36 virtual size_t GetNumActiveInputMethods() const OVERRIDE; 37 virtual void EnableLayouts(const std::string& language_code, 38 const std::string& initial_layout) OVERRIDE; 39 virtual bool EnableInputMethods( 40 const std::vector<std::string>& new_active_input_method_ids) OVERRIDE; 41 virtual bool EnableInputMethod( 42 const std::string& new_active_input_method_id) OVERRIDE; 43 virtual bool MigrateOldInputMethods( 44 std::vector<std::string>* input_method_ids) OVERRIDE; 45 virtual bool MigrateKoreanKeyboard( 46 const std::string& keyboard_id, 47 std::vector<std::string>* input_method_ids) OVERRIDE; 48 virtual void ChangeInputMethod(const std::string& input_method_id) OVERRIDE; 49 virtual void ActivateInputMethodProperty(const std::string& key) OVERRIDE; 50 virtual void AddInputMethodExtension( 51 const std::string& id, 52 const std::string& name, 53 const std::vector<std::string>& layouts, 54 const std::vector<std::string>& languages, 55 const GURL& options_url, 56 InputMethodEngine* instance) OVERRIDE; 57 virtual void RemoveInputMethodExtension(const std::string& id) OVERRIDE; 58 virtual void GetInputMethodExtensions( 59 InputMethodDescriptors* result) OVERRIDE; 60 virtual void SetEnabledExtensionImes(std::vector<std::string>* ids) OVERRIDE; 61 virtual void SetInputMethodDefault() OVERRIDE; 62 virtual bool SwitchToNextInputMethod() OVERRIDE; 63 virtual bool SwitchToPreviousInputMethod( 64 const ui::Accelerator& accelerator) OVERRIDE; 65 virtual bool SwitchInputMethod(const ui::Accelerator& accelerator) OVERRIDE; 66 virtual InputMethodDescriptor GetCurrentInputMethod() const OVERRIDE; 67 virtual InputMethodPropertyList 68 GetCurrentInputMethodProperties() const OVERRIDE; 69 virtual XKeyboard* GetXKeyboard() OVERRIDE; 70 virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE; 71 virtual ComponentExtensionIMEManager* 72 GetComponentExtensionIMEManager() OVERRIDE; 73 virtual bool IsLoginKeyboard(const std::string& layout) const OVERRIDE; 74 75 // Sets an input method ID which will be returned by GetCurrentInputMethod(). 76 void SetCurrentInputMethodId(const std::string& input_method_id) { 77 current_input_method_id_ = input_method_id; 78 } 79 80 // Set values that will be provided to the InputMethodUtil. 81 void set_application_locale(const std::string& value); 82 void set_hardware_keyboard_layout(const std::string& value); 83 84 // TODO(yusukes): Add more variables for counting the numbers of the API calls 85 int add_observer_count_; 86 int remove_observer_count_; 87 88 private: 89 // The value GetCurrentInputMethod().id() will return. 90 std::string current_input_method_id_; 91 92 InputMethodWhitelist whitelist_; 93 FakeInputMethodDelegate delegate_; // used by util_ 94 InputMethodUtil util_; 95 MockXKeyboard xkeyboard_; 96 97 // The active input method ids cache (actually default only) 98 std::vector<std::string> active_input_method_ids_; 99 100 DISALLOW_COPY_AND_ASSIGN(MockInputMethodManager); 101}; 102 103} // namespace input_method 104} // namespace chromeos 105 106#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ 107