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

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

Issue 2605843002: Add MockInputMethodManager under ui/base/ime/chromeos/ (Closed)
Patch Set: Addressed comments. Created 3 years, 11 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
(Empty)
1 // Copyright 2017 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_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_IMPL_H_
7
8 #include <stddef.h>
9
10 #include "base/macros.h"
11 #include "ui/base/ime/chromeos/component_extension_ime_manager.h"
12 #include "ui/base/ime/chromeos/fake_ime_keyboard.h"
13 #include "ui/base/ime/chromeos/fake_input_method_delegate.h"
14 #include "ui/base/ime/chromeos/input_method_manager.h"
15 #include "ui/base/ime/chromeos/input_method_whitelist.h"
16 #include "ui/base/ime/chromeos/mock_input_method_manager.h"
17
18 namespace chromeos {
19 namespace input_method {
20
21 // The mock implementation of InputMethodManager for testing.
22 class MockInputMethodManagerImpl : public MockInputMethodManager {
23 public:
24 class State : public MockInputMethodManager::State {
25 public:
26 explicit State(MockInputMethodManagerImpl* manager);
27
28 // MockInputMethodManager::State:
29 scoped_refptr<InputMethodManager::State> Clone() const override;
30 std::unique_ptr<InputMethodDescriptors> GetActiveInputMethods()
31 const override;
32 const InputMethodDescriptor* GetInputMethodFromId(
33 const std::string& input_method_id) const override;
34 InputMethodDescriptor GetCurrentInputMethod() const override;
35
36 // The value GetCurrentInputMethod().id() will return.
37 std::string current_input_method_id;
38
39 protected:
40 friend base::RefCounted<InputMethodManager::State>;
41 ~State() override;
42
43 private:
44 MockInputMethodManager* const manager_;
45
46 DISALLOW_COPY_AND_ASSIGN(State);
47 };
48
49 MockInputMethodManagerImpl();
50 ~MockInputMethodManagerImpl() override;
51
52 // MockInputMethodManager:
53 void AddObserver(InputMethodManager::Observer* observer) override;
54 void RemoveObserver(InputMethodManager::Observer* observer) override;
55 std::unique_ptr<InputMethodDescriptors> GetSupportedInputMethods()
56 const override;
57 bool IsISOLevel5ShiftUsedByCurrentInputMethod() const override;
58 ImeKeyboard* GetImeKeyboard() override;
59 InputMethodUtil* GetInputMethodUtil() override;
60 ComponentExtensionIMEManager* GetComponentExtensionIMEManager() override;
61 scoped_refptr<InputMethodManager::State> CreateNewState(
62 Profile* profile) override;
63 scoped_refptr<InputMethodManager::State> GetActiveIMEState() override;
64 void SetState(scoped_refptr<InputMethodManager::State> state) override;
65
66 // Sets an input method ID which will be returned by GetCurrentInputMethod().
67 void SetCurrentInputMethodId(const std::string& input_method_id);
68
69 void SetComponentExtensionIMEManager(
70 std::unique_ptr<ComponentExtensionIMEManager> comp_ime_manager);
71
72 // Set values that will be provided to the InputMethodUtil.
73 void set_application_locale(const std::string& value);
74
75 // Set the value returned by IsISOLevel5ShiftUsedByCurrentInputMethod
76 void set_mod3_used(bool value) { mod3_used_ = value; }
77
78 int add_observer_count() const { return add_observer_count_; }
79 int remove_observer_count() const { return remove_observer_count_; }
80
81 protected:
82 scoped_refptr<State> state_;
83
84 private:
85 // TODO(yusukes): Add more variables for counting the numbers of the API calls
86 int add_observer_count_;
87 int remove_observer_count_;
88 FakeInputMethodDelegate delegate_; // used by util_
89 std::unique_ptr<InputMethodUtil> util_;
90 FakeImeKeyboard keyboard_;
91 bool mod3_used_;
92 std::unique_ptr<ComponentExtensionIMEManager> comp_ime_manager_;
93
94 DISALLOW_COPY_AND_ASSIGN(MockInputMethodManagerImpl);
95 };
96
97 } // namespace input_method
98 } // namespace chromeos
99
100 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_IMPL_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698