Skip to content

Commit 3f3ab47

Browse files
tonikitooChromium LUCI CQ
authored andcommitted
Make SetUserLastInputMethodPreferenceForTesting() a static class method
... of InputMethodPersistence. Manipulating the local state is InputMethodPersistence's responsibility. This CL makes SetUserLastInputMethodPreferenceForTesting static public method of it. No behavior change expected. [email protected], [email protected] Bug: 446058312 Change-Id: Ib517bd9a149c0cb5cc29118416ae0750c24d31d4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7046709 Reviewed-by: Hidehiko Abe <[email protected]> Commit-Queue: Antonio Gomes <[email protected]> Reviewed-by: Jun Ishiguro <[email protected]> Cr-Commit-Position: refs/heads/main@{#1532373}
1 parent 5fe1e59 commit 3f3ab47

File tree

3 files changed

+29
-23
lines changed

3 files changed

+29
-23
lines changed

chrome/browser/ash/input_method/input_method_persistence.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ AccountId GetUserAccount(Profile* profile) {
4444
return user->GetAccountId();
4545
}
4646

47-
static void SetUserLastInputMethodPreference(
48-
const AccountId& account_id,
49-
const std::string& input_method_id) {
47+
void SetUserLastInputMethodPreference(const AccountId& account_id,
48+
const std::string& input_method_id) {
5049
if (!account_id.is_valid()) {
5150
return;
5251
}
@@ -159,7 +158,8 @@ void InputMethodPersistence::PersistUserInputMethod(
159158
user_prefs->SetString(::prefs::kLanguageCurrentInputMethod, input_method_id);
160159
}
161160

162-
void SetUserLastInputMethodPreferenceForTesting(
161+
// static
162+
void InputMethodPersistence::SetUserLastInputMethodPreferenceForTesting(
163163
const AccountId& account_id,
164164
const std::string& input_method) {
165165
SetUserLastInputMethodPreference(account_id, input_method);

chrome/browser/ash/input_method/input_method_persistence.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,18 @@ class InputMethodPersistence : public InputMethodManager::Observer {
4444
void SetUserLastLoginInputMethodId(const std::string& input_method_id,
4545
Profile* profile);
4646

47+
// Update user last input method ID into known_user data.
48+
static void SetUserLastInputMethodPreferenceForTesting(
49+
const AccountId& account_id,
50+
const std::string& input_method);
51+
4752
private:
4853
void PersistUserInputMethod(const std::string& input_method_id,
4954
Profile* profile);
5055

5156
raw_ptr<InputMethodManager> input_method_manager_;
5257
};
5358

54-
void SetUserLastInputMethodPreferenceForTesting(
55-
const AccountId& account_id,
56-
const std::string& input_method);
57-
5859
} // namespace input_method
5960
} // namespace ash
6061

chrome/browser/ash/login/login_ui_keyboard_browsertest.cc

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,12 @@ class LoginUIKeyboardTest : public LoginManagerTest {
104104
// Should be called from PRE_ test so that local_state is saved to disk, and
105105
// reloaded in the main test.
106106
void InitUserLastInputMethod() {
107-
input_method::SetUserLastInputMethodPreferenceForTesting(
108-
test_users_[0], user_input_methods[0]);
109-
input_method::SetUserLastInputMethodPreferenceForTesting(
110-
test_users_[1], user_input_methods[1]);
107+
input_method::InputMethodPersistence::
108+
SetUserLastInputMethodPreferenceForTesting(test_users_[0],
109+
user_input_methods[0]);
110+
input_method::InputMethodPersistence::
111+
SetUserLastInputMethodPreferenceForTesting(test_users_[1],
112+
user_input_methods[1]);
111113
}
112114

113115
protected:
@@ -261,15 +263,18 @@ class LoginUIKeyboardTestWithUsersAndOwner : public LoginManagerTest {
261263
// Should be called from PRE_ test so that local_state is saved to disk, and
262264
// reloaded in the main test.
263265
void InitUserLastInputMethod() {
264-
input_method::SetUserLastInputMethodPreferenceForTesting(
265-
AccountId::FromUserEmailGaiaId(kTestUser1, kTestUser1GaiaId),
266-
user_input_methods[0]);
267-
input_method::SetUserLastInputMethodPreferenceForTesting(
268-
AccountId::FromUserEmailGaiaId(kTestUser2, kTestUser2GaiaId),
269-
user_input_methods[1]);
270-
input_method::SetUserLastInputMethodPreferenceForTesting(
271-
AccountId::FromUserEmailGaiaId(kTestUser3, kTestUser3GaiaId),
272-
user_input_methods[2]);
266+
input_method::InputMethodPersistence::
267+
SetUserLastInputMethodPreferenceForTesting(
268+
AccountId::FromUserEmailGaiaId(kTestUser1, kTestUser1GaiaId),
269+
user_input_methods[0]);
270+
input_method::InputMethodPersistence::
271+
SetUserLastInputMethodPreferenceForTesting(
272+
AccountId::FromUserEmailGaiaId(kTestUser2, kTestUser2GaiaId),
273+
user_input_methods[1]);
274+
input_method::InputMethodPersistence::
275+
SetUserLastInputMethodPreferenceForTesting(
276+
AccountId::FromUserEmailGaiaId(kTestUser3, kTestUser3GaiaId),
277+
user_input_methods[2]);
273278

274279
PrefService* local_state = g_browser_process->local_state();
275280
local_state->SetString(language_prefs::kPreferredKeyboardLayout,
@@ -477,8 +482,8 @@ IN_PROC_BROWSER_TEST_F(FirstLoginKeyboardTest,
477482
locker_tester.Lock();
478483

479484
// Clear user input method.
480-
input_method::SetUserLastInputMethodPreferenceForTesting(test_user_,
481-
std::string());
485+
input_method::InputMethodPersistence::
486+
SetUserLastInputMethodPreferenceForTesting(test_user_, std::string());
482487
EXPECT_TRUE(lock_screen_utils::GetUserLastInputMethodId(test_user_).empty());
483488

484489
locker_tester.UnlockWithPassword(test_user_, "password");

0 commit comments

Comments
 (0)