| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| 11 #include "base/system_monitor/system_monitor.h" | 11 #include "base/system_monitor/system_monitor.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/extensions/extension_event_router_forwarder.h" | 16 #include "chrome/browser/extensions/extension_event_router_forwarder.h" |
| 17 #include "chrome/browser/io_thread.h" | 17 #include "chrome/browser/io_thread.h" |
| 18 #include "chrome/browser/prefs/browser_prefs.h" | 18 #include "chrome/browser/prefs/browser_prefs.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/profiles/profile_info_cache.h" | 20 #include "chrome/browser/profiles/profile_info_cache.h" |
| 21 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
| 22 #include "chrome/common/chrome_constants.h" | 22 #include "chrome/common/chrome_constants.h" |
| 23 #include "chrome/common/chrome_notification_types.h" | 23 #include "chrome/common/chrome_notification_types.h" |
| 24 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
| 25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
| 27 #include "chrome/test/base/testing_browser_process.h" | 27 #include "chrome/test/base/testing_browser_process.h" |
| 28 #include "chrome/test/base/testing_pref_service.h" | 28 #include "chrome/test/base/testing_pref_service.h" |
| 29 #include "content/browser/browser_thread.h" | 29 #include "content/browser/browser_thread.h" |
| 30 #include "content/common/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
| 31 #include "testing/gmock/include/gmock/gmock.h" | 31 #include "testing/gmock/include/gmock/gmock.h" |
| 32 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
| 33 | 33 |
| 34 #if defined(OS_CHROMEOS) | 34 #if defined(OS_CHROMEOS) |
| 35 #include "chrome/browser/chromeos/cros/cros_library.h" | 35 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 // This global variable is used to check that value returned to different | 39 // This global variable is used to check that value returned to different |
| 40 // observers is the same. | 40 // observers is the same. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 132 |
| 133 cl->AppendSwitchASCII(switches::kLoginProfile, profile_dir); | 133 cl->AppendSwitchASCII(switches::kLoginProfile, profile_dir); |
| 134 cl->AppendSwitch(switches::kTestType); | 134 cl->AppendSwitch(switches::kTestType); |
| 135 | 135 |
| 136 FilePath expected_default = | 136 FilePath expected_default = |
| 137 FilePath().AppendASCII(chrome::kInitialProfile); | 137 FilePath().AppendASCII(chrome::kInitialProfile); |
| 138 EXPECT_EQ(expected_default.value(), | 138 EXPECT_EQ(expected_default.value(), |
| 139 profile_manager_->GetInitialProfileDir().value()); | 139 profile_manager_->GetInitialProfileDir().value()); |
| 140 | 140 |
| 141 profile_manager_->Observe(chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 141 profile_manager_->Observe(chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
| 142 NotificationService::AllSources(), | 142 content::NotificationService::AllSources(), |
| 143 NotificationService::NoDetails()); | 143 content::NotificationService::NoDetails()); |
| 144 FilePath expected_logged_in(profile_dir); | 144 FilePath expected_logged_in(profile_dir); |
| 145 EXPECT_EQ(expected_logged_in.value(), | 145 EXPECT_EQ(expected_logged_in.value(), |
| 146 profile_manager_->GetInitialProfileDir().value()); | 146 profile_manager_->GetInitialProfileDir().value()); |
| 147 VLOG(1) << temp_dir_.path().Append( | 147 VLOG(1) << temp_dir_.path().Append( |
| 148 profile_manager_->GetInitialProfileDir()).value(); | 148 profile_manager_->GetInitialProfileDir()).value(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 #endif | 151 #endif |
| 152 | 152 |
| 153 TEST_F(ProfileManagerTest, CreateAndUseTwoProfiles) { | 153 TEST_F(ProfileManagerTest, CreateAndUseTwoProfiles) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_3"), | 257 cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_3"), |
| 258 ASCIIToUTF16("name_3"), string16(), 0); | 258 ASCIIToUTF16("name_3"), string16(), 0); |
| 259 cache.SetBackgroundStatusOfProfileAtIndex(0, true); | 259 cache.SetBackgroundStatusOfProfileAtIndex(0, true); |
| 260 cache.SetBackgroundStatusOfProfileAtIndex(2, true); | 260 cache.SetBackgroundStatusOfProfileAtIndex(2, true); |
| 261 EXPECT_EQ(3u, cache.GetNumberOfProfiles()); | 261 EXPECT_EQ(3u, cache.GetNumberOfProfiles()); |
| 262 | 262 |
| 263 profile_manager_->AutoloadProfiles(); | 263 profile_manager_->AutoloadProfiles(); |
| 264 | 264 |
| 265 EXPECT_EQ(2u, profile_manager_->GetLoadedProfiles().size()); | 265 EXPECT_EQ(2u, profile_manager_->GetLoadedProfiles().size()); |
| 266 } | 266 } |
| OLD | NEW |