| 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 <cstdlib> | 5 #include <cstdlib> |
| 6 #include <cstring> | 6 #include <cstring> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 namespace chromeos { | 34 namespace chromeos { |
| 35 | 35 |
| 36 class UnittestProfileManager : public ::ProfileManagerWithoutInit { | 36 class UnittestProfileManager : public ::ProfileManagerWithoutInit { |
| 37 public: | 37 public: |
| 38 explicit UnittestProfileManager(const base::FilePath& user_data_dir) | 38 explicit UnittestProfileManager(const base::FilePath& user_data_dir) |
| 39 : ::ProfileManagerWithoutInit(user_data_dir) {} | 39 : ::ProfileManagerWithoutInit(user_data_dir) {} |
| 40 | 40 |
| 41 protected: | 41 protected: |
| 42 virtual Profile* CreateProfileHelper( | 42 virtual Profile* CreateProfileHelper( |
| 43 const base::FilePath& file_path) OVERRIDE { | 43 const base::FilePath& file_path) override { |
| 44 if (!base::PathExists(file_path)) { | 44 if (!base::PathExists(file_path)) { |
| 45 if (!base::CreateDirectory(file_path)) | 45 if (!base::CreateDirectory(file_path)) |
| 46 return NULL; | 46 return NULL; |
| 47 } | 47 } |
| 48 return new TestingProfile(file_path, NULL); | 48 return new TestingProfile(file_path, NULL); |
| 49 } | 49 } |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 | 52 |
| 53 class UserManagerTest : public testing::Test { | 53 class UserManagerTest : public testing::Test { |
| 54 protected: | 54 protected: |
| 55 virtual void SetUp() OVERRIDE { | 55 virtual void SetUp() override { |
| 56 CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 56 CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 57 command_line.AppendSwitch(::switches::kTestType); | 57 command_line.AppendSwitch(::switches::kTestType); |
| 58 command_line.AppendSwitch( | 58 command_line.AppendSwitch( |
| 59 chromeos::switches::kIgnoreUserProfileMappingForTests); | 59 chromeos::switches::kIgnoreUserProfileMappingForTests); |
| 60 | 60 |
| 61 cros_settings_ = CrosSettings::Get(); | 61 cros_settings_ = CrosSettings::Get(); |
| 62 | 62 |
| 63 // Replace the real DeviceSettingsProvider with a stub. | 63 // Replace the real DeviceSettingsProvider with a stub. |
| 64 device_settings_provider_ = | 64 device_settings_provider_ = |
| 65 cros_settings_->GetProvider(chromeos::kReportDeviceVersionInfo); | 65 cros_settings_->GetProvider(chromeos::kReportDeviceVersionInfo); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 77 | 77 |
| 78 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 78 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 79 TestingBrowserProcess::GetGlobal()->SetProfileManager( | 79 TestingBrowserProcess::GetGlobal()->SetProfileManager( |
| 80 new UnittestProfileManager(temp_dir_.path())); | 80 new UnittestProfileManager(temp_dir_.path())); |
| 81 | 81 |
| 82 chromeos::DBusThreadManager::Initialize(); | 82 chromeos::DBusThreadManager::Initialize(); |
| 83 | 83 |
| 84 ResetUserManager(); | 84 ResetUserManager(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 virtual void TearDown() OVERRIDE { | 87 virtual void TearDown() override { |
| 88 // Unregister the in-memory local settings instance. | 88 // Unregister the in-memory local settings instance. |
| 89 local_state_.reset(); | 89 local_state_.reset(); |
| 90 | 90 |
| 91 // Restore the real DeviceSettingsProvider. | 91 // Restore the real DeviceSettingsProvider. |
| 92 EXPECT_TRUE( | 92 EXPECT_TRUE( |
| 93 cros_settings_->RemoveSettingsProvider(&stub_settings_provider_)); | 93 cros_settings_->RemoveSettingsProvider(&stub_settings_provider_)); |
| 94 cros_settings_->AddSettingsProvider(device_settings_provider_); | 94 cros_settings_->AddSettingsProvider(device_settings_provider_); |
| 95 | 95 |
| 96 // Shut down the DeviceSettingsService. | 96 // Shut down the DeviceSettingsService. |
| 97 DeviceSettingsService::Get()->UnsetSessionManager(); | 97 DeviceSettingsService::Get()->UnsetSessionManager(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 "user0@invalid.domain", "user0@invalid.domain", false); | 214 "user0@invalid.domain", "user0@invalid.domain", false); |
| 215 ResetUserManager(); | 215 ResetUserManager(); |
| 216 | 216 |
| 217 const user_manager::UserList* users = | 217 const user_manager::UserList* users = |
| 218 &user_manager::UserManager::Get()->GetUsers(); | 218 &user_manager::UserManager::Get()->GetUsers(); |
| 219 EXPECT_EQ(1U, users->size()); | 219 EXPECT_EQ(1U, users->size()); |
| 220 EXPECT_EQ((*users)[0]->email(), "owner@invalid.domain"); | 220 EXPECT_EQ((*users)[0]->email(), "owner@invalid.domain"); |
| 221 } | 221 } |
| 222 | 222 |
| 223 } // namespace chromeos | 223 } // namespace chromeos |
| OLD | NEW |