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/files/file_util.h" | 8 #include "base/files/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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // observers is the same. | 65 // observers is the same. |
66 Profile* g_created_profile; | 66 Profile* g_created_profile; |
67 | 67 |
68 class UnittestProfileManager : public ::ProfileManagerWithoutInit { | 68 class UnittestProfileManager : public ::ProfileManagerWithoutInit { |
69 public: | 69 public: |
70 explicit UnittestProfileManager(const base::FilePath& user_data_dir) | 70 explicit UnittestProfileManager(const base::FilePath& user_data_dir) |
71 : ::ProfileManagerWithoutInit(user_data_dir) {} | 71 : ::ProfileManagerWithoutInit(user_data_dir) {} |
72 | 72 |
73 protected: | 73 protected: |
74 virtual Profile* CreateProfileHelper( | 74 virtual Profile* CreateProfileHelper( |
75 const base::FilePath& file_path) OVERRIDE { | 75 const base::FilePath& file_path) override { |
76 if (!base::PathExists(file_path)) { | 76 if (!base::PathExists(file_path)) { |
77 if (!base::CreateDirectory(file_path)) | 77 if (!base::CreateDirectory(file_path)) |
78 return NULL; | 78 return NULL; |
79 } | 79 } |
80 return new TestingProfile(file_path, NULL); | 80 return new TestingProfile(file_path, NULL); |
81 } | 81 } |
82 | 82 |
83 virtual Profile* CreateProfileAsyncHelper(const base::FilePath& path, | 83 virtual Profile* CreateProfileAsyncHelper(const base::FilePath& path, |
84 Delegate* delegate) OVERRIDE { | 84 Delegate* delegate) override { |
85 // This is safe while all file operations are done on the FILE thread. | 85 // This is safe while all file operations are done on the FILE thread. |
86 BrowserThread::PostTask( | 86 BrowserThread::PostTask( |
87 BrowserThread::FILE, FROM_HERE, | 87 BrowserThread::FILE, FROM_HERE, |
88 base::Bind(base::IgnoreResult(&base::CreateDirectory), path)); | 88 base::Bind(base::IgnoreResult(&base::CreateDirectory), path)); |
89 | 89 |
90 return new TestingProfile(path, this); | 90 return new TestingProfile(path, this); |
91 } | 91 } |
92 }; | 92 }; |
93 | 93 |
94 } // namespace | 94 } // namespace |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 EXPECT_EQ(expected_path, guest_path); | 386 EXPECT_EQ(expected_path, guest_path); |
387 } | 387 } |
388 | 388 |
389 class UnittestGuestProfileManager : public UnittestProfileManager { | 389 class UnittestGuestProfileManager : public UnittestProfileManager { |
390 public: | 390 public: |
391 explicit UnittestGuestProfileManager(const base::FilePath& user_data_dir) | 391 explicit UnittestGuestProfileManager(const base::FilePath& user_data_dir) |
392 : UnittestProfileManager(user_data_dir) {} | 392 : UnittestProfileManager(user_data_dir) {} |
393 | 393 |
394 protected: | 394 protected: |
395 virtual Profile* CreateProfileHelper( | 395 virtual Profile* CreateProfileHelper( |
396 const base::FilePath& file_path) OVERRIDE { | 396 const base::FilePath& file_path) override { |
397 TestingProfile::Builder builder; | 397 TestingProfile::Builder builder; |
398 builder.SetGuestSession(); | 398 builder.SetGuestSession(); |
399 builder.SetPath(file_path); | 399 builder.SetPath(file_path); |
400 TestingProfile* testing_profile = builder.Build().release(); | 400 TestingProfile* testing_profile = builder.Build().release(); |
401 return testing_profile; | 401 return testing_profile; |
402 } | 402 } |
403 }; | 403 }; |
404 | 404 |
405 class ProfileManagerGuestTest : public ProfileManagerTest { | 405 class ProfileManagerGuestTest : public ProfileManagerTest { |
406 protected: | 406 protected: |
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 dest_path2.BaseName().MaybeAsASCII()); | 1290 dest_path2.BaseName().MaybeAsASCII()); |
1291 profile_manager->ScheduleProfileForDeletion(dest_path2, | 1291 profile_manager->ScheduleProfileForDeletion(dest_path2, |
1292 ProfileManager::CreateCallback()); | 1292 ProfileManager::CreateCallback()); |
1293 // Spin the message loop so that all the callbacks can finish running. | 1293 // Spin the message loop so that all the callbacks can finish running. |
1294 base::RunLoop().RunUntilIdle(); | 1294 base::RunLoop().RunUntilIdle(); |
1295 | 1295 |
1296 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); | 1296 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); |
1297 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); | 1297 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); |
1298 } | 1298 } |
1299 #endif // !defined(OS_MACOSX) | 1299 #endif // !defined(OS_MACOSX) |
OLD | NEW |