93191268b4d83c1bc20652c8bcb7931cf1ca3558
[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       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;
73
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;
77   }
78
79   void SetComponentExtensionIMEManager(
80       scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager);
81
82   // Set values that will be provided to the InputMethodUtil.
83   void set_application_locale(const std::string& value);
84
85   // Set the value returned by IsISOLevel5ShiftUsedByCurrentInputMethod
86   void set_mod3_used(bool value) { mod3_used_ = value; }
87
88   // TODO(yusukes): Add more variables for counting the numbers of the API calls
89   int add_observer_count_;
90   int remove_observer_count_;
91
92  private:
93   // The value GetCurrentInputMethod().id() will return.
94   std::string current_input_method_id_;
95
96   InputMethodWhitelist whitelist_;
97   FakeInputMethodDelegate delegate_;  // used by util_
98   InputMethodUtil util_;
99   FakeImeKeyboard keyboard_;
100   bool mod3_used_;
101   scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager_;
102
103   // The active input method ids cache (actually default only)
104   std::vector<std::string> active_input_method_ids_;
105
106   DISALLOW_COPY_AND_ASSIGN(MockInputMethodManager);
107 };
108
109 }  // namespace input_method
110 }  // namespace chromeos
111
112 #endif  // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_