4bfd2c25ba592c5c4549b842b0e9b54126c33864
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / input_method / mock_input_method_manager.h
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/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"
14
15 namespace chromeos {
16 namespace input_method {
17
18 // The mock implementation of InputMethodManager for testing.
19 class MockInputMethodManager : public InputMethodManager {
20  public:
21   MockInputMethodManager();
22   virtual ~MockInputMethodManager();
23
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
36       OVERRIDE;
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       Profile* profile,
51       const std::string& id,
52       InputMethodEngineInterface* instance) OVERRIDE;
53   virtual void RemoveInputMethodExtension(Profile* profile,
54                                           const std::string& id) OVERRIDE;
55   virtual void GetInputMethodExtensions(
56       InputMethodDescriptors* result) OVERRIDE;
57   virtual void SetEnabledExtensionImes(std::vector<std::string>* ids) OVERRIDE;
58   virtual void SetInputMethodLoginDefault() OVERRIDE;
59   virtual void SetInputMethodLoginDefaultFromVPD(
60       const std::string& locale, const std::string& layout) OVERRIDE;
61   virtual bool SwitchToNextInputMethod() OVERRIDE;
62   virtual bool SwitchToPreviousInputMethod(
63       const ui::Accelerator& accelerator) OVERRIDE;
64   virtual bool SwitchInputMethod(const ui::Accelerator& accelerator) OVERRIDE;
65   virtual InputMethodDescriptor GetCurrentInputMethod() const OVERRIDE;
66   virtual bool IsISOLevel5ShiftUsedByCurrentInputMethod() const OVERRIDE;
67   virtual bool IsAltGrUsedByCurrentInputMethod() const OVERRIDE;
68   virtual ImeKeyboard* GetImeKeyboard() OVERRIDE;
69   virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE;
70   virtual ComponentExtensionIMEManager*
71       GetComponentExtensionIMEManager() OVERRIDE;
72   virtual bool IsLoginKeyboard(const std::string& layout) const OVERRIDE;
73   virtual bool MigrateInputMethods(
74        std::vector<std::string>* input_method_ids) OVERRIDE;
75
76   // Sets an input method ID which will be returned by GetCurrentInputMethod().
77   void SetCurrentInputMethodId(const std::string& input_method_id) {
78     current_input_method_id_ = input_method_id;
79   }
80
81   void SetComponentExtensionIMEManager(
82       scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager);
83
84   // Set values that will be provided to the InputMethodUtil.
85   void set_application_locale(const std::string& value);
86
87   // Set the value returned by IsISOLevel5ShiftUsedByCurrentInputMethod
88   void set_mod3_used(bool value) { mod3_used_ = value; }
89
90   // TODO(yusukes): Add more variables for counting the numbers of the API calls
91   int add_observer_count_;
92   int remove_observer_count_;
93
94  private:
95   // The value GetCurrentInputMethod().id() will return.
96   std::string current_input_method_id_;
97
98   InputMethodWhitelist whitelist_;
99   FakeInputMethodDelegate delegate_;  // used by util_
100   InputMethodUtil util_;
101   FakeImeKeyboard keyboard_;
102   bool mod3_used_;
103   scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager_;
104
105   // The active input method ids cache (actually default only)
106   std::vector<std::string> active_input_method_ids_;
107
108   DISALLOW_COPY_AND_ASSIGN(MockInputMethodManager);
109 };
110
111 }  // namespace input_method
112 }  // namespace chromeos
113
114 #endif  // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_