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

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

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 #include "chrome/browser/chromeos/input_method/mock_input_method_manager_impl.h"
6
7 #include <utility>
8
9 #include "chrome/browser/chromeos/input_method/input_method_util.h"
10
11 namespace chromeos {
12 namespace input_method {
13
14 MockInputMethodManagerImpl::State::State(MockInputMethodManagerImpl* manager)
15 : manager_(manager) {
16 active_input_method_ids.push_back("xkb:us::eng");
17 }
18
19 scoped_refptr<InputMethodManager::State>
20 MockInputMethodManagerImpl::State::Clone() const {
21 NOTIMPLEMENTED();
22 return manager_->GetActiveIMEState();
23 }
24
25 std::unique_ptr<InputMethodDescriptors>
26 MockInputMethodManagerImpl::State::GetActiveInputMethods() const {
27 std::unique_ptr<InputMethodDescriptors> result;
28 #if _LIBCPP_STD_VER > 11
29 result = std::make_unique<InputMethodDescriptors>();
30 #else
31 result.reset(new InputMethodDescriptors);
32 #endif
33 result->push_back(InputMethodUtil::GetFallbackInputMethodDescriptor());
34 return result;
35 }
36
37 const InputMethodDescriptor*
38 MockInputMethodManagerImpl::State::GetInputMethodFromId(
39 const std::string& input_method_id) const {
40 static const InputMethodDescriptor defaultInputMethod =
41 InputMethodUtil::GetFallbackInputMethodDescriptor();
42 for (size_t i = 0; i < active_input_method_ids.size(); i++) {
43 if (input_method_id == active_input_method_ids[i]) {
44 return &defaultInputMethod;
45 }
46 }
47 return nullptr;
48 }
49
50 InputMethodDescriptor MockInputMethodManagerImpl::State::GetCurrentInputMethod()
51 const {
52 InputMethodDescriptor descriptor =
53 InputMethodUtil::GetFallbackInputMethodDescriptor();
54 if (!current_input_method_id.empty()) {
55 return InputMethodDescriptor(
56 current_input_method_id, descriptor.name(), descriptor.indicator(),
57 descriptor.keyboard_layouts(), descriptor.language_codes(), true,
58 GURL(), // options page url.
59 GURL()); // input view page url.
60 }
61 return descriptor;
62 }
63
64 MockInputMethodManagerImpl::State::~State() {}
65
66 MockInputMethodManagerImpl::MockInputMethodManagerImpl()
67 : state_(new State(this)),
68 add_observer_count_(0),
69 remove_observer_count_(0),
70 util_(new InputMethodUtil(&delegate_)),
71 mod3_used_(false) {}
72
73 MockInputMethodManagerImpl::~MockInputMethodManagerImpl() {}
74
75 void MockInputMethodManagerImpl::AddObserver(
76 InputMethodManager::Observer* observer) {
77 ++add_observer_count_;
78 }
79
80 void MockInputMethodManagerImpl::RemoveObserver(
81 InputMethodManager::Observer* observer) {
82 ++remove_observer_count_;
83 }
84
85 std::unique_ptr<InputMethodDescriptors>
86 MockInputMethodManagerImpl::GetSupportedInputMethods() const {
87 std::unique_ptr<InputMethodDescriptors> result;
88 #if _LIBCPP_STD_VER > 11
89 result = std::make_unique<InputMethodDescriptors>();
90 #else
91 result.reset(new InputMethodDescriptors);
92 #endif
93 result->push_back(InputMethodUtil::GetFallbackInputMethodDescriptor());
94 return result;
95 }
96
97 bool MockInputMethodManagerImpl::IsISOLevel5ShiftUsedByCurrentInputMethod()
98 const {
99 return mod3_used_;
100 }
101
102 ImeKeyboard* MockInputMethodManagerImpl::GetImeKeyboard() {
103 return &keyboard_;
104 }
105
106 InputMethodUtil* MockInputMethodManagerImpl::GetInputMethodUtil() {
107 return util_.get();
108 }
109
110 ComponentExtensionIMEManager*
111 MockInputMethodManagerImpl::GetComponentExtensionIMEManager() {
112 return comp_ime_manager_.get();
113 }
114
115 scoped_refptr<InputMethodManager::State>
116 MockInputMethodManagerImpl::CreateNewState(Profile* profile) {
117 NOTIMPLEMENTED();
118 return state_;
119 }
120
121 scoped_refptr<InputMethodManager::State>
122 MockInputMethodManagerImpl::GetActiveIMEState() {
123 return scoped_refptr<InputMethodManager::State>(state_.get());
124 }
125
126 void MockInputMethodManagerImpl::SetState(
127 scoped_refptr<InputMethodManager::State> state) {
128 state_ = scoped_refptr<MockInputMethodManagerImpl::State>(
129 static_cast<MockInputMethodManagerImpl::State*>(state.get()));
130 }
131
132 void MockInputMethodManagerImpl::SetCurrentInputMethodId(
133 const std::string& input_method_id) {
134 state_->current_input_method_id = input_method_id;
135 }
136
137 void MockInputMethodManagerImpl::SetComponentExtensionIMEManager(
138 std::unique_ptr<ComponentExtensionIMEManager> comp_ime_manager) {
139 comp_ime_manager_ = std::move(comp_ime_manager);
140 }
141
142 void MockInputMethodManagerImpl::set_application_locale(
143 const std::string& value) {
144 delegate_.set_active_locale(value);
145 }
146
147 } // namespace input_method
148 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/input_method/mock_input_method_manager_impl.h ('k') | chrome/browser/chromeos/preferences_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698