Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: chrome/browser/chromeos/input_method/mock_input_method_manager.h

Issue 419293002: IME refactoring: ChromeOS introduce input methods State. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_
7 7
8 #include "chrome/browser/chromeos/input_method/input_method_util.h" 8 #include "chrome/browser/chromeos/input_method/input_method_util.h"
9 #include "chromeos/ime/component_extension_ime_manager.h" 9 #include "chromeos/ime/component_extension_ime_manager.h"
10 #include "chromeos/ime/fake_ime_keyboard.h" 10 #include "chromeos/ime/fake_ime_keyboard.h"
11 #include "chromeos/ime/fake_input_method_delegate.h" 11 #include "chromeos/ime/fake_input_method_delegate.h"
12 #include "chromeos/ime/input_method_manager.h" 12 #include "chromeos/ime/input_method_manager.h"
13 #include "chromeos/ime/input_method_whitelist.h" 13 #include "chromeos/ime/input_method_whitelist.h"
14 14
15 namespace chromeos { 15 namespace chromeos {
16 namespace input_method { 16 namespace input_method {
17 17
18 // The mock implementation of InputMethodManager for testing. 18 // The mock implementation of InputMethodManager for testing.
19 class MockInputMethodManager : public InputMethodManager { 19 class MockInputMethodManager : public InputMethodManager {
20 public: 20 public:
21 class State : public InputMethodManager::State {
22 public:
23 State();
24
25 virtual void AddInputMethodExtension(
26 const std::string& extension_id,
27 const InputMethodDescriptors& descriptors,
28 InputMethodEngineInterface* instance) OVERRIDE;
29 virtual void RemoveInputMethodExtension(
30 const std::string& extension_id) OVERRIDE;
31 virtual void ChangeInputMethod(const std::string& input_method_id,
32 bool show_message) OVERRIDE;
33 virtual bool EnableInputMethod(
34 const std::string& new_active_input_method_id) OVERRIDE;
35 virtual void EnableLoginLayouts(
36 const std::string& language_code,
37 const std::vector<std::string>& initial_layouts) OVERRIDE;
38 virtual void EnableLockScreenLayouts() OVERRIDE;
39 virtual void GetInputMethodExtensions(
40 InputMethodDescriptors* result) OVERRIDE;
41 virtual scoped_ptr<InputMethodDescriptors> GetActiveInputMethods()
42 const OVERRIDE;
43 virtual const std::vector<std::string>& GetActiveInputMethodIds()
44 const OVERRIDE;
45 virtual const InputMethodDescriptor* GetInputMethodFromId(
46 const std::string& input_method_id) const OVERRIDE;
47 virtual size_t GetNumActiveInputMethods() const OVERRIDE;
48 virtual void SetEnabledExtensionImes(
49 std::vector<std::string>* ids) OVERRIDE;
50 virtual void SetInputMethodLoginDefault() OVERRIDE;
51 virtual void SetInputMethodLoginDefaultFromVPD(
52 const std::string& locale,
53 const std::string& layout) OVERRIDE;
54 virtual bool SwitchToNextInputMethod() OVERRIDE;
55 virtual bool SwitchToPreviousInputMethod(
56 const ui::Accelerator& accelerator) OVERRIDE;
57 virtual bool SwitchInputMethod(const ui::Accelerator& accelerator) OVERRIDE;
58 virtual InputMethodDescriptor GetCurrentInputMethod() const OVERRIDE;
59 virtual bool ReplaceEnabledInputMethods(
60 const std::vector<std::string>& new_active_input_method_ids) OVERRIDE;
61
62 // The value GetCurrentInputMethod().id() will return.
63 std::string current_input_method_id;
64
65 // The active input method ids cache (actually default only)
66 std::vector<std::string> active_input_method_ids;
67
68 protected:
69 friend base::RefCounted<chromeos::input_method::InputMethodManager::State>;
70 virtual ~State();
71 };
72
21 MockInputMethodManager(); 73 MockInputMethodManager();
22 virtual ~MockInputMethodManager(); 74 virtual ~MockInputMethodManager();
23 75
24 // InputMethodManager override: 76 // InputMethodManager override:
25 virtual void InitializeComponentExtension() OVERRIDE; 77 virtual void InitializeComponentExtension(Profile* profile) OVERRIDE;
26 virtual void AddObserver(InputMethodManager::Observer* observer) OVERRIDE; 78 virtual void AddObserver(InputMethodManager::Observer* observer) OVERRIDE;
27 virtual void AddCandidateWindowObserver( 79 virtual void AddCandidateWindowObserver(
28 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE; 80 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE;
29 virtual void RemoveObserver(InputMethodManager::Observer* observer) OVERRIDE; 81 virtual void RemoveObserver(InputMethodManager::Observer* observer) OVERRIDE;
30 virtual void RemoveCandidateWindowObserver( 82 virtual void RemoveCandidateWindowObserver(
31 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE; 83 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE;
32 virtual scoped_ptr<InputMethodDescriptors> 84 virtual scoped_ptr<InputMethodDescriptors>
33 GetSupportedInputMethods() const OVERRIDE; 85 GetSupportedInputMethods() const OVERRIDE;
34 virtual scoped_ptr<InputMethodDescriptors>
35 GetActiveInputMethods() const OVERRIDE;
36 virtual const std::vector<std::string>& GetActiveInputMethodIds() const
37 OVERRIDE;
38 virtual size_t GetNumActiveInputMethods() const OVERRIDE;
39 virtual const InputMethodDescriptor* GetInputMethodFromId(
40 const std::string& input_method_id) const OVERRIDE;
41 virtual void EnableLoginLayouts(
42 const std::string& language_code,
43 const std::vector<std::string>& initial_layout) OVERRIDE;
44 virtual bool ReplaceEnabledInputMethods(
45 const std::vector<std::string>& new_active_input_method_ids) OVERRIDE;
46 virtual bool EnableInputMethod(
47 const std::string& new_active_input_method_id) OVERRIDE;
48 virtual void ChangeInputMethod(const std::string& input_method_id) OVERRIDE;
49 virtual void ActivateInputMethodMenuItem(const std::string& key) OVERRIDE; 86 virtual void ActivateInputMethodMenuItem(const std::string& key) OVERRIDE;
50 virtual void AddInputMethodExtension(
51 const std::string& extension_id,
52 const InputMethodDescriptors& descriptors,
53 InputMethodEngineInterface* instance) OVERRIDE;
54 virtual void RemoveInputMethodExtension(
55 const std::string& extension_id) OVERRIDE;
56 virtual void GetInputMethodExtensions(
57 InputMethodDescriptors* result) OVERRIDE;
58 virtual void SetEnabledExtensionImes(std::vector<std::string>* ids) OVERRIDE;
59 virtual void SetInputMethodLoginDefault() OVERRIDE;
60 virtual void SetInputMethodLoginDefaultFromVPD(
61 const std::string& locale, const std::string& layout) 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 bool IsISOLevel5ShiftUsedByCurrentInputMethod() const OVERRIDE; 87 virtual bool IsISOLevel5ShiftUsedByCurrentInputMethod() const OVERRIDE;
68 virtual bool IsAltGrUsedByCurrentInputMethod() const OVERRIDE; 88 virtual bool IsAltGrUsedByCurrentInputMethod() const OVERRIDE;
69 virtual ImeKeyboard* GetImeKeyboard() OVERRIDE; 89 virtual ImeKeyboard* GetImeKeyboard() OVERRIDE;
70 virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE; 90 virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE;
71 virtual ComponentExtensionIMEManager* 91 virtual ComponentExtensionIMEManager*
72 GetComponentExtensionIMEManager() OVERRIDE; 92 GetComponentExtensionIMEManager() OVERRIDE;
73 virtual bool IsLoginKeyboard(const std::string& layout) const OVERRIDE; 93 virtual bool IsLoginKeyboard(const std::string& layout) const OVERRIDE;
74 virtual bool MigrateInputMethods( 94 virtual bool MigrateInputMethods(
75 std::vector<std::string>* input_method_ids) OVERRIDE; 95 std::vector<std::string>* input_method_ids) OVERRIDE;
96 virtual scoped_refptr<InputMethodManager::State> GetDefaultState(
97 Profile* profile) OVERRIDE;
98 virtual scoped_refptr<InputMethodManager::State> GetActiveIMEState() OVERRIDE;
99 virtual scoped_refptr<InputMethodManager::State> CloneState(
100 const InputMethodManager::State* state) OVERRIDE;
101 virtual void SetState(
102 scoped_refptr<InputMethodManager::State> state) OVERRIDE;
76 103
77 // Sets an input method ID which will be returned by GetCurrentInputMethod(). 104 // Sets an input method ID which will be returned by GetCurrentInputMethod().
78 void SetCurrentInputMethodId(const std::string& input_method_id) { 105 void SetCurrentInputMethodId(const std::string& input_method_id);
79 current_input_method_id_ = input_method_id;
80 }
81 106
82 void SetComponentExtensionIMEManager( 107 void SetComponentExtensionIMEManager(
83 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager); 108 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager);
84 109
85 // Set values that will be provided to the InputMethodUtil. 110 // Set values that will be provided to the InputMethodUtil.
86 void set_application_locale(const std::string& value); 111 void set_application_locale(const std::string& value);
87 112
88 // Set the value returned by IsISOLevel5ShiftUsedByCurrentInputMethod 113 // Set the value returned by IsISOLevel5ShiftUsedByCurrentInputMethod
89 void set_mod3_used(bool value) { mod3_used_ = value; } 114 void set_mod3_used(bool value) { mod3_used_ = value; }
90 115
91 // TODO(yusukes): Add more variables for counting the numbers of the API calls 116 // TODO(yusukes): Add more variables for counting the numbers of the API calls
92 int add_observer_count_; 117 int add_observer_count_;
93 int remove_observer_count_; 118 int remove_observer_count_;
94 119
120 protected:
121 scoped_refptr<State> state_;
122
95 private: 123 private:
96 // The value GetCurrentInputMethod().id() will return.
97 std::string current_input_method_id_;
98
99 FakeInputMethodDelegate delegate_; // used by util_ 124 FakeInputMethodDelegate delegate_; // used by util_
100 InputMethodUtil util_; 125 InputMethodUtil util_;
101 FakeImeKeyboard keyboard_; 126 FakeImeKeyboard keyboard_;
102 bool mod3_used_; 127 bool mod3_used_;
103 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager_; 128 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager_;
104 129
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); 130 DISALLOW_COPY_AND_ASSIGN(MockInputMethodManager);
109 }; 131 };
110 132
111 } // namespace input_method 133 } // namespace input_method
112 } // namespace chromeos 134 } // namespace chromeos
113 135
114 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ 136 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698