| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 class UnittestProfileManager : public ::ProfileManagerWithoutInit { | 57 class UnittestProfileManager : public ::ProfileManagerWithoutInit { |
| 58 public: | 58 public: |
| 59 explicit UnittestProfileManager(const base::FilePath& user_data_dir) | 59 explicit UnittestProfileManager(const base::FilePath& user_data_dir) |
| 60 : ::ProfileManagerWithoutInit(user_data_dir) {} | 60 : ::ProfileManagerWithoutInit(user_data_dir) {} |
| 61 | 61 |
| 62 protected: | 62 protected: |
| 63 virtual Profile* CreateProfileHelper( | 63 virtual Profile* CreateProfileHelper( |
| 64 const base::FilePath& file_path) OVERRIDE { | 64 const base::FilePath& file_path) OVERRIDE { |
| 65 if (!base::PathExists(file_path)) { | 65 if (!base::PathExists(file_path)) { |
| 66 if (!file_util::CreateDirectory(file_path)) | 66 if (!base::CreateDirectory(file_path)) |
| 67 return NULL; | 67 return NULL; |
| 68 } | 68 } |
| 69 return new TestingProfile(file_path, NULL); | 69 return new TestingProfile(file_path, NULL); |
| 70 } | 70 } |
| 71 | 71 |
| 72 virtual Profile* CreateProfileAsyncHelper(const base::FilePath& path, | 72 virtual Profile* CreateProfileAsyncHelper(const base::FilePath& path, |
| 73 Delegate* delegate) OVERRIDE { | 73 Delegate* delegate) OVERRIDE { |
| 74 // This is safe while all file operations are done on the FILE thread. | 74 // This is safe while all file operations are done on the FILE thread. |
| 75 BrowserThread::PostTask( | 75 BrowserThread::PostTask( |
| 76 BrowserThread::FILE, FROM_HERE, | 76 BrowserThread::FILE, FROM_HERE, |
| 77 base::Bind(base::IgnoreResult(&file_util::CreateDirectory), path)); | 77 base::Bind(base::IgnoreResult(&base::CreateDirectory), path)); |
| 78 | 78 |
| 79 return new TestingProfile(path, this); | 79 return new TestingProfile(path, this); |
| 80 } | 80 } |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 } // namespace | 83 } // namespace |
| 84 | 84 |
| 85 class ProfileManagerTest : public testing::Test { | 85 class ProfileManagerTest : public testing::Test { |
| 86 protected: | 86 protected: |
| 87 class MockObserver { | 87 class MockObserver { |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 dest_path2.BaseName().MaybeAsASCII()); | 860 dest_path2.BaseName().MaybeAsASCII()); |
| 861 profile_manager->ScheduleProfileForDeletion(dest_path2, | 861 profile_manager->ScheduleProfileForDeletion(dest_path2, |
| 862 ProfileManager::CreateCallback()); | 862 ProfileManager::CreateCallback()); |
| 863 // Spin the message loop so that all the callbacks can finish running. | 863 // Spin the message loop so that all the callbacks can finish running. |
| 864 base::RunLoop().RunUntilIdle(); | 864 base::RunLoop().RunUntilIdle(); |
| 865 | 865 |
| 866 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); | 866 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); |
| 867 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); | 867 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); |
| 868 } | 868 } |
| 869 #endif // !defined(OS_MACOSX) | 869 #endif // !defined(OS_MACOSX) |
| OLD | NEW |