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 28 matching lines...) Expand all Loading... |
39 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
40 #include "content/public/common/content_switches.h" | 40 #include "content/public/common/content_switches.h" |
41 #include "content/public/test/test_browser_thread_bundle.h" | 41 #include "content/public/test/test_browser_thread_bundle.h" |
42 #include "grit/generated_resources.h" | 42 #include "grit/generated_resources.h" |
43 #include "testing/gmock/include/gmock/gmock.h" | 43 #include "testing/gmock/include/gmock/gmock.h" |
44 #include "testing/gtest/include/gtest/gtest.h" | 44 #include "testing/gtest/include/gtest/gtest.h" |
45 #include "ui/base/l10n/l10n_util.h" | 45 #include "ui/base/l10n/l10n_util.h" |
46 | 46 |
47 #if defined(OS_CHROMEOS) | 47 #if defined(OS_CHROMEOS) |
48 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" | 48 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" |
49 #include "chrome/browser/chromeos/login/users/user_manager.h" | 49 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" |
50 #include "chrome/browser/chromeos/settings/cros_settings.h" | 50 #include "chrome/browser/chromeos/settings/cros_settings.h" |
51 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 51 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
52 #include "chromeos/chromeos_switches.h" | 52 #include "chromeos/chromeos_switches.h" |
53 #include "chromeos/login/user_names.h" | 53 #include "chromeos/login/user_names.h" |
| 54 #include "components/user_manager/user_manager.h" |
54 #endif | 55 #endif |
55 | 56 |
56 using base::ASCIIToUTF16; | 57 using base::ASCIIToUTF16; |
57 using content::BrowserThread; | 58 using content::BrowserThread; |
58 | 59 |
59 namespace { | 60 namespace { |
60 | 61 |
61 // This global variable is used to check that value returned to different | 62 // This global variable is used to check that value returned to different |
62 // observers is the same. | 63 // observers is the same. |
63 Profile* g_created_profile; | 64 Profile* g_created_profile; |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 // This switch is needed to skip non-test specific behavior in | 398 // This switch is needed to skip non-test specific behavior in |
398 // ProfileManager (accessing DBusThreadManager). | 399 // ProfileManager (accessing DBusThreadManager). |
399 cl->AppendSwitch(switches::kTestType); | 400 cl->AppendSwitch(switches::kTestType); |
400 | 401 |
401 cl->AppendSwitchASCII(chromeos::switches::kLoginProfile, | 402 cl->AppendSwitchASCII(chromeos::switches::kLoginProfile, |
402 std::string(chrome::kProfileDirPrefix) + | 403 std::string(chrome::kProfileDirPrefix) + |
403 chromeos::login::kGuestUserName); | 404 chromeos::login::kGuestUserName); |
404 cl->AppendSwitch(chromeos::switches::kGuestSession); | 405 cl->AppendSwitch(chromeos::switches::kGuestSession); |
405 cl->AppendSwitch(::switches::kIncognito); | 406 cl->AppendSwitch(::switches::kIncognito); |
406 | 407 |
407 chromeos::UserManager::Get()->UserLoggedIn(chromeos::login::kGuestUserName, | 408 user_manager::UserManager::Get()->UserLoggedIn( |
408 chromeos::login::kGuestUserName, | 409 chromeos::login::kGuestUserName, |
409 false); | 410 chromeos::login::kGuestUserName, |
| 411 false); |
410 #endif | 412 #endif |
411 } | 413 } |
412 }; | 414 }; |
413 | 415 |
414 TEST_F(ProfileManagerGuestTest, GetLastUsedProfileAllowedByPolicy) { | 416 TEST_F(ProfileManagerGuestTest, GetLastUsedProfileAllowedByPolicy) { |
415 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 417 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
416 ASSERT_TRUE(profile_manager); | 418 ASSERT_TRUE(profile_manager); |
417 | 419 |
418 Profile* profile = profile_manager->GetLastUsedProfileAllowedByPolicy(); | 420 Profile* profile = profile_manager->GetLastUsedProfileAllowedByPolicy(); |
419 ASSERT_TRUE(profile); | 421 ASSERT_TRUE(profile); |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 dest_path2.BaseName().MaybeAsASCII()); | 1208 dest_path2.BaseName().MaybeAsASCII()); |
1207 profile_manager->ScheduleProfileForDeletion(dest_path2, | 1209 profile_manager->ScheduleProfileForDeletion(dest_path2, |
1208 ProfileManager::CreateCallback()); | 1210 ProfileManager::CreateCallback()); |
1209 // Spin the message loop so that all the callbacks can finish running. | 1211 // Spin the message loop so that all the callbacks can finish running. |
1210 base::RunLoop().RunUntilIdle(); | 1212 base::RunLoop().RunUntilIdle(); |
1211 | 1213 |
1212 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); | 1214 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); |
1213 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); | 1215 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); |
1214 } | 1216 } |
1215 #endif // !defined(OS_MACOSX) | 1217 #endif // !defined(OS_MACOSX) |
OLD | NEW |