| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include <sys/types.h> | 5 #include <sys/types.h> |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" | 12 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" |
| 13 #include "chrome/browser/chromeos/login/login_manager_test.h" | 13 #include "chrome/browser/chromeos/login/login_manager_test.h" |
| 14 #include "chrome/browser/chromeos/login/startup_utils.h" | 14 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 15 #include "chrome/browser/chromeos/login/user_adding_screen.h" | 15 #include "chrome/browser/chromeos/login/user_adding_screen.h" |
| 16 #include "chrome/browser/chromeos/preferences.h" | 16 #include "chrome/browser/chromeos/preferences.h" |
| 17 #include "chrome/browser/chromeos/settings/cros_settings.h" | 17 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 18 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" | 18 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" |
| 19 #include "chrome/browser/chromeos/system/fake_input_device_settings.h" | 19 #include "chrome/browser/chromeos/system/fake_input_device_settings.h" |
| 20 #include "chrome/browser/feedback/tracing_manager.h" | 20 #include "chrome/browser/feedback/tracing_manager.h" |
| 21 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" | 21 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" |
| 22 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 24 #include "chromeos/chromeos_switches.h" | 24 #include "chromeos/chromeos_switches.h" |
| 25 #include "chromeos/ime/fake_xkeyboard.h" | 25 #include "chromeos/ime/fake_ime_keyboard.h" |
| 26 #include "content/public/test/test_utils.h" | 26 #include "content/public/test/test_utils.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 28 #include "ui/events/event_utils.h" | 28 #include "ui/events/event_utils.h" |
| 29 | 29 |
| 30 namespace chromeos { | 30 namespace chromeos { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 const char* kTestUsers[] = {"test-user1@gmail.com", "test-user2@gmail.com"}; | 34 const char* kTestUsers[] = {"test-user1@gmail.com", "test-user2@gmail.com"}; |
| 35 | 35 |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| 38 class PreferencesTest : public LoginManagerTest { | 38 class PreferencesTest : public LoginManagerTest { |
| 39 public: | 39 public: |
| 40 PreferencesTest() | 40 PreferencesTest() |
| 41 : LoginManagerTest(true), | 41 : LoginManagerTest(true), |
| 42 input_settings_(NULL), | 42 input_settings_(NULL), |
| 43 xkeyboard_(NULL) {} | 43 keyboard_(NULL) {} |
| 44 | 44 |
| 45 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 45 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 46 LoginManagerTest::SetUpCommandLine(command_line); | 46 LoginManagerTest::SetUpCommandLine(command_line); |
| 47 command_line->AppendSwitch(::switches::kMultiProfiles); | 47 command_line->AppendSwitch(::switches::kMultiProfiles); |
| 48 command_line->AppendSwitch(switches::kStubCrosSettings); | 48 command_line->AppendSwitch(switches::kStubCrosSettings); |
| 49 } | 49 } |
| 50 | 50 |
| 51 virtual void SetUpOnMainThread() OVERRIDE { | 51 virtual void SetUpOnMainThread() OVERRIDE { |
| 52 LoginManagerTest::SetUpOnMainThread(); | 52 LoginManagerTest::SetUpOnMainThread(); |
| 53 input_settings_ = new system::FakeInputDeviceSettings(); | 53 input_settings_ = new system::FakeInputDeviceSettings(); |
| 54 system::InputDeviceSettings::SetSettingsForTesting(input_settings_); | 54 system::InputDeviceSettings::SetSettingsForTesting(input_settings_); |
| 55 xkeyboard_ = new input_method::FakeXKeyboard(); | 55 keyboard_ = new input_method::FakeImeKeyboard(); |
| 56 static_cast<input_method::InputMethodManagerImpl*>( | 56 static_cast<input_method::InputMethodManagerImpl*>( |
| 57 input_method::InputMethodManager::Get()) | 57 input_method::InputMethodManager::Get()) |
| 58 ->SetXKeyboardForTesting(xkeyboard_); | 58 ->SetImeKeyboardForTesting(keyboard_); |
| 59 CrosSettings::Get()->SetString(kDeviceOwner, kTestUsers[0]); | 59 CrosSettings::Get()->SetString(kDeviceOwner, kTestUsers[0]); |
| 60 } | 60 } |
| 61 | 61 |
| 62 // Sets set of preferences in given |prefs|. Value of prefernece depends of | 62 // Sets set of preferences in given |prefs|. Value of prefernece depends of |
| 63 // |variant| value. For opposite |variant| values all preferences recieve | 63 // |variant| value. For opposite |variant| values all preferences recieve |
| 64 // different values. | 64 // different values. |
| 65 void SetPrefs(PrefService* prefs, bool variant) { | 65 void SetPrefs(PrefService* prefs, bool variant) { |
| 66 prefs->SetBoolean(prefs::kTapToClickEnabled, variant); | 66 prefs->SetBoolean(prefs::kTapToClickEnabled, variant); |
| 67 prefs->SetBoolean(prefs::kPrimaryMouseButtonRight, !variant); | 67 prefs->SetBoolean(prefs::kPrimaryMouseButtonRight, !variant); |
| 68 prefs->SetBoolean(prefs::kTapDraggingEnabled, variant); | 68 prefs->SetBoolean(prefs::kTapDraggingEnabled, variant); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 90 EXPECT_EQ(prefs->GetBoolean(prefs::kEnableTouchpadThreeFingerClick), | 90 EXPECT_EQ(prefs->GetBoolean(prefs::kEnableTouchpadThreeFingerClick), |
| 91 input_settings_->current_touchpad_settings() | 91 input_settings_->current_touchpad_settings() |
| 92 .GetThreeFingerClick()); | 92 .GetThreeFingerClick()); |
| 93 EXPECT_EQ(prefs->GetInteger(prefs::kMouseSensitivity), | 93 EXPECT_EQ(prefs->GetInteger(prefs::kMouseSensitivity), |
| 94 input_settings_->current_mouse_settings().GetSensitivity()); | 94 input_settings_->current_mouse_settings().GetSensitivity()); |
| 95 EXPECT_EQ(prefs->GetInteger(prefs::kTouchpadSensitivity), | 95 EXPECT_EQ(prefs->GetInteger(prefs::kTouchpadSensitivity), |
| 96 input_settings_->current_touchpad_settings().GetSensitivity()); | 96 input_settings_->current_touchpad_settings().GetSensitivity()); |
| 97 EXPECT_EQ(prefs->GetBoolean(prefs::kTouchHudProjectionEnabled), | 97 EXPECT_EQ(prefs->GetBoolean(prefs::kTouchHudProjectionEnabled), |
| 98 ash::Shell::GetInstance()->is_touch_hud_projection_enabled()); | 98 ash::Shell::GetInstance()->is_touch_hud_projection_enabled()); |
| 99 EXPECT_EQ(prefs->GetBoolean(prefs::kLanguageXkbAutoRepeatEnabled), | 99 EXPECT_EQ(prefs->GetBoolean(prefs::kLanguageXkbAutoRepeatEnabled), |
| 100 xkeyboard_->auto_repeat_is_enabled_); | 100 keyboard_->auto_repeat_is_enabled_); |
| 101 input_method::AutoRepeatRate rate = xkeyboard_->last_auto_repeat_rate_; | 101 input_method::AutoRepeatRate rate = keyboard_->last_auto_repeat_rate_; |
| 102 EXPECT_EQ(prefs->GetInteger(prefs::kLanguageXkbAutoRepeatDelay), | 102 EXPECT_EQ(prefs->GetInteger(prefs::kLanguageXkbAutoRepeatDelay), |
| 103 (int)rate.initial_delay_in_ms); | 103 (int)rate.initial_delay_in_ms); |
| 104 EXPECT_EQ(prefs->GetInteger(prefs::kLanguageXkbAutoRepeatInterval), | 104 EXPECT_EQ(prefs->GetInteger(prefs::kLanguageXkbAutoRepeatInterval), |
| 105 (int)rate.repeat_interval_in_ms); | 105 (int)rate.repeat_interval_in_ms); |
| 106 EXPECT_EQ( | 106 EXPECT_EQ( |
| 107 prefs->GetString(prefs::kLanguageCurrentInputMethod), | 107 prefs->GetString(prefs::kLanguageCurrentInputMethod), |
| 108 input_method::InputMethodManager::Get()->GetCurrentInputMethod().id()); | 108 input_method::InputMethodManager::Get()->GetCurrentInputMethod().id()); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void CheckLocalStateCorrespondsToPrefs(PrefService* prefs) { | 111 void CheckLocalStateCorrespondsToPrefs(PrefService* prefs) { |
| 112 PrefService* local_state = g_browser_process->local_state(); | 112 PrefService* local_state = g_browser_process->local_state(); |
| 113 EXPECT_EQ(local_state->GetBoolean(prefs::kOwnerTapToClickEnabled), | 113 EXPECT_EQ(local_state->GetBoolean(prefs::kOwnerTapToClickEnabled), |
| 114 prefs->GetBoolean(prefs::kTapToClickEnabled)); | 114 prefs->GetBoolean(prefs::kTapToClickEnabled)); |
| 115 EXPECT_EQ(local_state->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight), | 115 EXPECT_EQ(local_state->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight), |
| 116 prefs->GetBoolean(prefs::kPrimaryMouseButtonRight)); | 116 prefs->GetBoolean(prefs::kPrimaryMouseButtonRight)); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void DisableAnimations() { | 119 void DisableAnimations() { |
| 120 // Disable animations for user transitions. | 120 // Disable animations for user transitions. |
| 121 chrome::MultiUserWindowManagerChromeOS* manager = | 121 chrome::MultiUserWindowManagerChromeOS* manager = |
| 122 static_cast<chrome::MultiUserWindowManagerChromeOS*>( | 122 static_cast<chrome::MultiUserWindowManagerChromeOS*>( |
| 123 chrome::MultiUserWindowManager::GetInstance()); | 123 chrome::MultiUserWindowManager::GetInstance()); |
| 124 manager->SetAnimationSpeedForTest( | 124 manager->SetAnimationSpeedForTest( |
| 125 chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_DISABLED); | 125 chrome::MultiUserWindowManagerChromeOS::ANIMATION_SPEED_DISABLED); |
| 126 } | 126 } |
| 127 | 127 |
| 128 private: | 128 private: |
| 129 system::FakeInputDeviceSettings* input_settings_; | 129 system::FakeInputDeviceSettings* input_settings_; |
| 130 input_method::FakeXKeyboard* xkeyboard_; | 130 input_method::FakeImeKeyboard* keyboard_; |
| 131 | 131 |
| 132 DISALLOW_COPY_AND_ASSIGN(PreferencesTest); | 132 DISALLOW_COPY_AND_ASSIGN(PreferencesTest); |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 IN_PROC_BROWSER_TEST_F(PreferencesTest, PRE_MultiProfiles) { | 135 IN_PROC_BROWSER_TEST_F(PreferencesTest, PRE_MultiProfiles) { |
| 136 RegisterUser(kTestUsers[0]); | 136 RegisterUser(kTestUsers[0]); |
| 137 RegisterUser(kTestUsers[1]); | 137 RegisterUser(kTestUsers[1]); |
| 138 chromeos::StartupUtils::MarkOobeCompleted(); | 138 chromeos::StartupUtils::MarkOobeCompleted(); |
| 139 } | 139 } |
| 140 | 140 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 !prefs1->GetBoolean(prefs::kTapToClickEnabled)); | 201 !prefs1->GetBoolean(prefs::kTapToClickEnabled)); |
| 202 CheckLocalStateCorrespondsToPrefs(prefs1); | 202 CheckLocalStateCorrespondsToPrefs(prefs1); |
| 203 | 203 |
| 204 // Switch user back. | 204 // Switch user back. |
| 205 user_manager->SwitchActiveUser(kTestUsers[0]); | 205 user_manager->SwitchActiveUser(kTestUsers[0]); |
| 206 CheckSettingsCorrespondToPrefs(prefs1); | 206 CheckSettingsCorrespondToPrefs(prefs1); |
| 207 CheckLocalStateCorrespondsToPrefs(prefs1); | 207 CheckLocalStateCorrespondsToPrefs(prefs1); |
| 208 } | 208 } |
| 209 | 209 |
| 210 } // namespace chromeos | 210 } // namespace chromeos |
| OLD | NEW |