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/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "chrome/test/base/test_browser_window.h" | 32 #include "chrome/test/base/test_browser_window.h" |
33 #include "chrome/test/base/testing_browser_process.h" | 33 #include "chrome/test/base/testing_browser_process.h" |
34 #include "chrome/test/base/testing_profile.h" | 34 #include "chrome/test/base/testing_profile.h" |
35 #include "content/public/browser/notification_service.h" | 35 #include "content/public/browser/notification_service.h" |
36 #include "content/public/test/test_browser_thread.h" | 36 #include "content/public/test/test_browser_thread.h" |
37 #include "testing/gmock/include/gmock/gmock.h" | 37 #include "testing/gmock/include/gmock/gmock.h" |
38 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
39 | 39 |
40 #if defined(OS_CHROMEOS) | 40 #if defined(OS_CHROMEOS) |
41 #include "chrome/browser/chromeos/cros/cros_library.h" | 41 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 42 #include "chrome/browser/chromeos/login/mock_user_manager.h" |
42 #include "chromeos/chromeos_switches.h" | 43 #include "chromeos/chromeos_switches.h" |
43 #endif | 44 #endif |
44 | 45 |
45 using content::BrowserThread; | 46 using content::BrowserThread; |
46 | 47 |
47 namespace { | 48 namespace { |
48 | 49 |
49 // This global variable is used to check that value returned to different | 50 // This global variable is used to check that value returned to different |
50 // observers is the same. | 51 // observers is the same. |
51 Profile* g_created_profile; | 52 Profile* g_created_profile; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 std::string profile_dir("my_user"); | 169 std::string profile_dir("my_user"); |
169 | 170 |
170 cl->AppendSwitchASCII(chromeos::switches::kLoginProfile, profile_dir); | 171 cl->AppendSwitchASCII(chromeos::switches::kLoginProfile, profile_dir); |
171 | 172 |
172 base::FilePath expected_default = | 173 base::FilePath expected_default = |
173 base::FilePath().AppendASCII(chrome::kInitialProfile); | 174 base::FilePath().AppendASCII(chrome::kInitialProfile); |
174 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 175 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
175 EXPECT_EQ(expected_default.value(), | 176 EXPECT_EQ(expected_default.value(), |
176 profile_manager->GetInitialProfileDir().value()); | 177 profile_manager->GetInitialProfileDir().value()); |
177 | 178 |
| 179 scoped_ptr<chromeos::MockUserManager> mock_user_manager; |
| 180 mock_user_manager.reset(new chromeos::MockUserManager()); |
| 181 mock_user_manager->SetActiveUser("user@gmail.com"); |
| 182 chromeos::User* active_user = mock_user_manager->GetActiveUser(); |
178 profile_manager->Observe(chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 183 profile_manager->Observe(chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
179 content::NotificationService::AllSources(), | 184 content::NotificationService::AllSources(), |
180 content::NotificationService::NoDetails()); | 185 content::Details<const chromeos::User>(active_user)); |
181 base::FilePath expected_logged_in(profile_dir); | 186 base::FilePath expected_logged_in(profile_dir); |
182 EXPECT_EQ(expected_logged_in.value(), | 187 EXPECT_EQ(expected_logged_in.value(), |
183 profile_manager->GetInitialProfileDir().value()); | 188 profile_manager->GetInitialProfileDir().value()); |
184 VLOG(1) << temp_dir_.path().Append( | 189 VLOG(1) << temp_dir_.path().Append( |
185 profile_manager->GetInitialProfileDir()).value(); | 190 profile_manager->GetInitialProfileDir()).value(); |
186 } | 191 } |
187 | 192 |
188 #endif | 193 #endif |
189 | 194 |
190 TEST_F(ProfileManagerTest, CreateAndUseTwoProfiles) { | 195 TEST_F(ProfileManagerTest, CreateAndUseTwoProfiles) { |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 browser2b.reset(); | 601 browser2b.reset(); |
597 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); | 602 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); |
598 ASSERT_EQ(1U, last_opened_profiles.size()); | 603 ASSERT_EQ(1U, last_opened_profiles.size()); |
599 EXPECT_EQ(profile1, last_opened_profiles[0]); | 604 EXPECT_EQ(profile1, last_opened_profiles[0]); |
600 | 605 |
601 browser1.reset(); | 606 browser1.reset(); |
602 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); | 607 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); |
603 ASSERT_EQ(0U, last_opened_profiles.size()); | 608 ASSERT_EQ(0U, last_opened_profiles.size()); |
604 } | 609 } |
605 #endif // !defined(OS_ANDROID) | 610 #endif // !defined(OS_ANDROID) |
OLD | NEW |