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.
5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_
8 #include "chrome/browser/chromeos/input_method/input_method_util.h"
9 #include "chromeos/ime/component_extension_ime_manager.h"
10 #include "chromeos/ime/fake_ime_keyboard.h"
11 #include "chromeos/ime/fake_input_method_delegate.h"
12 #include "chromeos/ime/input_method_manager.h"
13 #include "chromeos/ime/input_method_whitelist.h"
16 namespace input_method {
18 // The mock implementation of InputMethodManager for testing.
19 class MockInputMethodManager : public InputMethodManager {
21 MockInputMethodManager();
22 virtual ~MockInputMethodManager();
24 // InputMethodManager override:
25 virtual void AddObserver(InputMethodManager::Observer* observer) OVERRIDE;
26 virtual void AddCandidateWindowObserver(
27 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE;
28 virtual void RemoveObserver(InputMethodManager::Observer* observer) OVERRIDE;
29 virtual void RemoveCandidateWindowObserver(
30 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE;
31 virtual scoped_ptr<InputMethodDescriptors>
32 GetSupportedInputMethods() const OVERRIDE;
33 virtual scoped_ptr<InputMethodDescriptors>
34 GetActiveInputMethods() const OVERRIDE;
35 virtual const std::vector<std::string>& GetActiveInputMethodIds() const
37 virtual size_t GetNumActiveInputMethods() const OVERRIDE;
38 virtual const InputMethodDescriptor* GetInputMethodFromId(
39 const std::string& input_method_id) const OVERRIDE;
40 virtual void EnableLoginLayouts(
41 const std::string& language_code,
42 const std::vector<std::string>& initial_layout) OVERRIDE;
43 virtual bool ReplaceEnabledInputMethods(
44 const std::vector<std::string>& new_active_input_method_ids) OVERRIDE;
45 virtual bool EnableInputMethod(
46 const std::string& new_active_input_method_id) OVERRIDE;
47 virtual void ChangeInputMethod(const std::string& input_method_id) OVERRIDE;
48 virtual void ActivateInputMethodMenuItem(const std::string& key) OVERRIDE;
49 virtual void AddInputMethodExtension(
50 const std::string& id,
51 InputMethodEngineInterface* instance) OVERRIDE;
52 virtual void RemoveInputMethodExtension(const std::string& id) OVERRIDE;
53 virtual void GetInputMethodExtensions(
54 InputMethodDescriptors* result) OVERRIDE;
55 virtual void SetEnabledExtensionImes(std::vector<std::string>* ids) OVERRIDE;
56 virtual void SetInputMethodLoginDefault() OVERRIDE;
57 virtual void SetInputMethodLoginDefaultFromVPD(
58 const std::string& locale, const std::string& layout) OVERRIDE;
59 virtual bool SwitchToNextInputMethod() OVERRIDE;
60 virtual bool SwitchToPreviousInputMethod(
61 const ui::Accelerator& accelerator) OVERRIDE;
62 virtual bool SwitchInputMethod(const ui::Accelerator& accelerator) OVERRIDE;
63 virtual InputMethodDescriptor GetCurrentInputMethod() const OVERRIDE;
64 virtual bool IsISOLevel5ShiftUsedByCurrentInputMethod() const OVERRIDE;
65 virtual bool IsAltGrUsedByCurrentInputMethod() const OVERRIDE;
66 virtual ImeKeyboard* GetImeKeyboard() OVERRIDE;
67 virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE;
68 virtual ComponentExtensionIMEManager*
69 GetComponentExtensionIMEManager() OVERRIDE;
70 virtual bool IsLoginKeyboard(const std::string& layout) const OVERRIDE;
71 virtual bool MigrateInputMethods(
72 std::vector<std::string>* input_method_ids) OVERRIDE;
74 // Sets an input method ID which will be returned by GetCurrentInputMethod().
75 void SetCurrentInputMethodId(const std::string& input_method_id) {
76 current_input_method_id_ = input_method_id;
79 void SetComponentExtensionIMEManager(
80 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager);
82 // Set values that will be provided to the InputMethodUtil.
83 void set_application_locale(const std::string& value);
85 // Set the value returned by IsISOLevel5ShiftUsedByCurrentInputMethod
86 void set_mod3_used(bool value) { mod3_used_ = value; }
88 // TODO(yusukes): Add more variables for counting the numbers of the API calls
89 int add_observer_count_;
90 int remove_observer_count_;
93 // The value GetCurrentInputMethod().id() will return.
94 std::string current_input_method_id_;
96 InputMethodWhitelist whitelist_;
97 FakeInputMethodDelegate delegate_; // used by util_
98 InputMethodUtil util_;
99 FakeImeKeyboard keyboard_;
101 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager_;
103 // The active input method ids cache (actually default only)
104 std::vector<std::string> active_input_method_ids_;
106 DISALLOW_COPY_AND_ASSIGN(MockInputMethodManager);
109 } // namespace input_method
110 } // namespace chromeos
112 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_