| 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/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 23 #include "chromeos/chromeos_switches.h" | 23 #include "chromeos/chromeos_switches.h" |
| 24 #include "chromeos/ime/fake_xkeyboard.h" | 24 #include "chromeos/ime/fake_keyboard_controller.h" |
| 25 #include "content/public/test/test_utils.h" | 25 #include "content/public/test/test_utils.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 27 #include "ui/events/event_utils.h" | 27 #include "ui/events/event_utils.h" |
| 28 | 28 |
| 29 namespace chromeos { | 29 namespace chromeos { |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 const char* kTestUsers[] = {"test-user1@gmail.com", "test-user2@gmail.com"}; | 33 const char* kTestUsers[] = {"test-user1@gmail.com", "test-user2@gmail.com"}; |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 class PreferencesTest : public LoginManagerTest { | 37 class PreferencesTest : public LoginManagerTest { |
| 38 public: | 38 public: |
| 39 PreferencesTest() | 39 PreferencesTest() |
| 40 : LoginManagerTest(true), | 40 : LoginManagerTest(true), |
| 41 input_settings_(NULL), | 41 input_settings_(NULL), |
| 42 xkeyboard_(NULL) {} | 42 xkeyboard_(NULL) {} |
| 43 | 43 |
| 44 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 44 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 45 LoginManagerTest::SetUpCommandLine(command_line); | 45 LoginManagerTest::SetUpCommandLine(command_line); |
| 46 command_line->AppendSwitch(::switches::kMultiProfiles); | 46 command_line->AppendSwitch(::switches::kMultiProfiles); |
| 47 command_line->AppendSwitch(switches::kStubCrosSettings); | 47 command_line->AppendSwitch(switches::kStubCrosSettings); |
| 48 } | 48 } |
| 49 | 49 |
| 50 virtual void SetUpOnMainThread() OVERRIDE { | 50 virtual void SetUpOnMainThread() OVERRIDE { |
| 51 LoginManagerTest::SetUpOnMainThread(); | 51 LoginManagerTest::SetUpOnMainThread(); |
| 52 input_settings_ = new system::FakeInputDeviceSettings(); | 52 input_settings_ = new system::FakeInputDeviceSettings(); |
| 53 system::InputDeviceSettings::SetSettingsForTesting(input_settings_); | 53 system::InputDeviceSettings::SetSettingsForTesting(input_settings_); |
| 54 xkeyboard_ = new input_method::FakeXKeyboard(); | 54 xkeyboard_ = new input_method::FakeKeyboardController(); |
| 55 static_cast<input_method::InputMethodManagerImpl*>( | 55 static_cast<input_method::InputMethodManagerImpl*>( |
| 56 input_method::InputMethodManager::Get()) | 56 input_method::InputMethodManager::Get()) |
| 57 ->SetXKeyboardForTesting(xkeyboard_); | 57 ->SetKeyboardControllerForTesting(xkeyboard_); |
| 58 CrosSettings::Get()->SetString(kDeviceOwner, kTestUsers[0]); | 58 CrosSettings::Get()->SetString(kDeviceOwner, kTestUsers[0]); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Sets set of preferences in given |prefs|. Value of prefernece depends of | 61 // Sets set of preferences in given |prefs|. Value of prefernece depends of |
| 62 // |variant| value. For opposite |variant| values all preferences recieve | 62 // |variant| value. For opposite |variant| values all preferences recieve |
| 63 // different values. | 63 // different values. |
| 64 void SetPrefs(PrefService* prefs, bool variant) { | 64 void SetPrefs(PrefService* prefs, bool variant) { |
| 65 prefs->SetBoolean(prefs::kTapToClickEnabled, variant); | 65 prefs->SetBoolean(prefs::kTapToClickEnabled, variant); |
| 66 prefs->SetBoolean(prefs::kPrimaryMouseButtonRight, !variant); | 66 prefs->SetBoolean(prefs::kPrimaryMouseButtonRight, !variant); |
| 67 prefs->SetBoolean(prefs::kTapDraggingEnabled, variant); | 67 prefs->SetBoolean(prefs::kTapDraggingEnabled, variant); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 void CheckLocalStateCorrespondsToPrefs(PrefService* prefs) { | 112 void CheckLocalStateCorrespondsToPrefs(PrefService* prefs) { |
| 113 PrefService* local_state = g_browser_process->local_state(); | 113 PrefService* local_state = g_browser_process->local_state(); |
| 114 EXPECT_EQ(local_state->GetBoolean(prefs::kOwnerTapToClickEnabled), | 114 EXPECT_EQ(local_state->GetBoolean(prefs::kOwnerTapToClickEnabled), |
| 115 prefs->GetBoolean(prefs::kTapToClickEnabled)); | 115 prefs->GetBoolean(prefs::kTapToClickEnabled)); |
| 116 EXPECT_EQ(local_state->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight), | 116 EXPECT_EQ(local_state->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight), |
| 117 prefs->GetBoolean(prefs::kPrimaryMouseButtonRight)); | 117 prefs->GetBoolean(prefs::kPrimaryMouseButtonRight)); |
| 118 } | 118 } |
| 119 | 119 |
| 120 private: | 120 private: |
| 121 system::FakeInputDeviceSettings* input_settings_; | 121 system::FakeInputDeviceSettings* input_settings_; |
| 122 input_method::FakeXKeyboard* xkeyboard_; | 122 input_method::FakeKeyboardController* xkeyboard_; |
| 123 | 123 |
| 124 DISALLOW_COPY_AND_ASSIGN(PreferencesTest); | 124 DISALLOW_COPY_AND_ASSIGN(PreferencesTest); |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 IN_PROC_BROWSER_TEST_F(PreferencesTest, PRE_MultiProfiles) { | 127 IN_PROC_BROWSER_TEST_F(PreferencesTest, PRE_MultiProfiles) { |
| 128 RegisterUser(kTestUsers[0]); | 128 RegisterUser(kTestUsers[0]); |
| 129 RegisterUser(kTestUsers[1]); | 129 RegisterUser(kTestUsers[1]); |
| 130 chromeos::StartupUtils::MarkOobeCompleted(); | 130 chromeos::StartupUtils::MarkOobeCompleted(); |
| 131 } | 131 } |
| 132 | 132 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 !prefs1->GetBoolean(prefs::kTapToClickEnabled)); | 192 !prefs1->GetBoolean(prefs::kTapToClickEnabled)); |
| 193 CheckLocalStateCorrespondsToPrefs(prefs1); | 193 CheckLocalStateCorrespondsToPrefs(prefs1); |
| 194 | 194 |
| 195 // Switch user back. | 195 // Switch user back. |
| 196 user_manager->SwitchActiveUser(kTestUsers[0]); | 196 user_manager->SwitchActiveUser(kTestUsers[0]); |
| 197 CheckSettingsCorrespondToPrefs(prefs1); | 197 CheckSettingsCorrespondToPrefs(prefs1); |
| 198 CheckLocalStateCorrespondsToPrefs(prefs1); | 198 CheckLocalStateCorrespondsToPrefs(prefs1); |
| 199 } | 199 } |
| 200 | 200 |
| 201 } // namespace chromeos | 201 } // namespace chromeos |
| OLD | NEW |