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

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: Unit test fixed. Re-sorted methods of StateImpl and IMM. 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 explicit State(MockInputMethodManager* manager);
24
25 virtual scoped_refptr<InputMethodManager::State> Clone() const OVERRIDE;
26 virtual void AddInputMethodExtension(
27 const std::string& extension_id,
28 const InputMethodDescriptors& descriptors,
29 InputMethodEngineInterface* instance) OVERRIDE;
30 virtual void RemoveInputMethodExtension(
31 const std::string& extension_id) OVERRIDE;
32 virtual void ChangeInputMethod(const std::string& input_method_id,
33 bool show_message) OVERRIDE;
34 virtual bool EnableInputMethod(
35 const std::string& new_active_input_method_id) OVERRIDE;
36 virtual void EnableLoginLayouts(
37 const std::string& language_code,
38 const std::vector<std::string>& initial_layouts) OVERRIDE;
39 virtual void EnableLockScreenLayouts() OVERRIDE;
40 virtual void GetInputMethodExtensions(
41 InputMethodDescriptors* result) OVERRIDE;
42 virtual scoped_ptr<InputMethodDescriptors> GetActiveInputMethods()
43 const OVERRIDE;
44 virtual const std::vector<std::string>& GetActiveInputMethodIds()
45 const OVERRIDE;
46 virtual const InputMethodDescriptor* GetInputMethodFromId(
47 const std::string& input_method_id) const OVERRIDE;
48 virtual size_t GetNumActiveInputMethods() const OVERRIDE;
49 virtual void SetEnabledExtensionImes(
50 std::vector<std::string>* ids) OVERRIDE;
51 virtual void SetInputMethodLoginDefault() OVERRIDE;
52 virtual void SetInputMethodLoginDefaultFromVPD(
53 const std::string& locale,
54 const std::string& layout) OVERRIDE;
55 virtual bool SwitchToNextInputMethod() OVERRIDE;
56 virtual bool SwitchToPreviousInputMethod(
57 const ui::Accelerator& accelerator) OVERRIDE;
58 virtual bool SwitchInputMethod(const ui::Accelerator& accelerator) OVERRIDE;
59 virtual InputMethodDescriptor GetCurrentInputMethod() const OVERRIDE;
60 virtual bool ReplaceEnabledInputMethods(
61 const std::vector<std::string>& new_active_input_method_ids) OVERRIDE;
62
63 // The value GetCurrentInputMethod().id() will return.
64 std::string current_input_method_id;
65
66 // The active input method ids cache (actually default only)
67 std::vector<std::string> active_input_method_ids;
68
69 protected:
70 friend base::RefCounted<chromeos::input_method::InputMethodManager::State>;
71 virtual ~State();
72
73 MockInputMethodManager* const manager_;
74 };
75
21 MockInputMethodManager(); 76 MockInputMethodManager();
22 virtual ~MockInputMethodManager(); 77 virtual ~MockInputMethodManager();
23 78
24 // InputMethodManager override: 79 // InputMethodManager override:
25 virtual State GetState() OVERRIDE; 80 virtual UISessionState GetUISessionState() OVERRIDE;
26 virtual void AddObserver(InputMethodManager::Observer* observer) OVERRIDE; 81 virtual void AddObserver(InputMethodManager::Observer* observer) OVERRIDE;
27 virtual void AddCandidateWindowObserver( 82 virtual void AddCandidateWindowObserver(
28 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE; 83 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE;
29 virtual void RemoveObserver(InputMethodManager::Observer* observer) OVERRIDE; 84 virtual void RemoveObserver(InputMethodManager::Observer* observer) OVERRIDE;
30 virtual void RemoveCandidateWindowObserver( 85 virtual void RemoveCandidateWindowObserver(
31 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE; 86 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE;
32 virtual scoped_ptr<InputMethodDescriptors> 87 virtual scoped_ptr<InputMethodDescriptors>
33 GetSupportedInputMethods() const OVERRIDE; 88 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; 89 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; 90 virtual bool IsISOLevel5ShiftUsedByCurrentInputMethod() const OVERRIDE;
68 virtual bool IsAltGrUsedByCurrentInputMethod() const OVERRIDE; 91 virtual bool IsAltGrUsedByCurrentInputMethod() const OVERRIDE;
69 virtual ImeKeyboard* GetImeKeyboard() OVERRIDE; 92 virtual ImeKeyboard* GetImeKeyboard() OVERRIDE;
70 virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE; 93 virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE;
71 virtual ComponentExtensionIMEManager* 94 virtual ComponentExtensionIMEManager*
72 GetComponentExtensionIMEManager() OVERRIDE; 95 GetComponentExtensionIMEManager() OVERRIDE;
73 virtual bool IsLoginKeyboard(const std::string& layout) const OVERRIDE; 96 virtual bool IsLoginKeyboard(const std::string& layout) const OVERRIDE;
74 virtual bool MigrateInputMethods( 97 virtual bool MigrateInputMethods(
75 std::vector<std::string>* input_method_ids) OVERRIDE; 98 std::vector<std::string>* input_method_ids) OVERRIDE;
99 virtual scoped_refptr<InputMethodManager::State> CreateNewState(
100 Profile* profile) OVERRIDE;
101 virtual scoped_refptr<InputMethodManager::State> GetActiveIMEState() OVERRIDE;
102 virtual void SetState(
103 scoped_refptr<InputMethodManager::State> state) OVERRIDE;
76 104
77 // Sets an input method ID which will be returned by GetCurrentInputMethod(). 105 // Sets an input method ID which will be returned by GetCurrentInputMethod().
78 void SetCurrentInputMethodId(const std::string& input_method_id) { 106 void SetCurrentInputMethodId(const std::string& input_method_id);
79 current_input_method_id_ = input_method_id;
80 }
81 107
82 void SetComponentExtensionIMEManager( 108 void SetComponentExtensionIMEManager(
83 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager); 109 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager);
84 110
85 // Set values that will be provided to the InputMethodUtil. 111 // Set values that will be provided to the InputMethodUtil.
86 void set_application_locale(const std::string& value); 112 void set_application_locale(const std::string& value);
87 113
88 // Set the value returned by IsISOLevel5ShiftUsedByCurrentInputMethod 114 // Set the value returned by IsISOLevel5ShiftUsedByCurrentInputMethod
89 void set_mod3_used(bool value) { mod3_used_ = value; } 115 void set_mod3_used(bool value) { mod3_used_ = value; }
90 116
91 // TODO(yusukes): Add more variables for counting the numbers of the API calls 117 // TODO(yusukes): Add more variables for counting the numbers of the API calls
92 int add_observer_count_; 118 int add_observer_count_;
93 int remove_observer_count_; 119 int remove_observer_count_;
94 120
121 protected:
122 scoped_refptr<State> state_;
123
95 private: 124 private:
96 // The value GetCurrentInputMethod().id() will return.
97 std::string current_input_method_id_;
98
99 FakeInputMethodDelegate delegate_; // used by util_ 125 FakeInputMethodDelegate delegate_; // used by util_
100 InputMethodUtil util_; 126 InputMethodUtil util_;
101 FakeImeKeyboard keyboard_; 127 FakeImeKeyboard keyboard_;
102 bool mod3_used_; 128 bool mod3_used_;
103 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager_; 129 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager_;
104 130
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); 131 DISALLOW_COPY_AND_ASSIGN(MockInputMethodManager);
109 }; 132 };
110 133
111 } // namespace input_method 134 } // namespace input_method
112 } // namespace chromeos 135 } // namespace chromeos
113 136
114 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ 137 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698