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 "chrome/browser/profiles/profile_info_cache_unittest.h" | 5 #include "chrome/browser/profiles/profile_info_cache_unittest.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/prefs/testing_pref_service.h" | 9 #include "base/prefs/testing_pref_service.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/time/time.h" |
12 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
14 #include "chrome/browser/prefs/pref_service_syncable.h" | 15 #include "chrome/browser/prefs/pref_service_syncable.h" |
15 #include "chrome/browser/profiles/profile_info_cache.h" | 16 #include "chrome/browser/profiles/profile_info_cache.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/test/base/testing_browser_process.h" | 18 #include "chrome/test/base/testing_browser_process.h" |
18 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
19 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
20 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
21 #include "content/public/test/test_browser_thread_bundle.h" | 22 #include "content/public/test/test_browser_thread_bundle.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 GetCache()->SetHasMigratedToGAIAInfoOfProfileAtIndex(0, true); | 301 GetCache()->SetHasMigratedToGAIAInfoOfProfileAtIndex(0, true); |
301 EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(0)); | 302 EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(0)); |
302 EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(1)); | 303 EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(1)); |
303 | 304 |
304 // Unset migrated state for 2nd profile. | 305 // Unset migrated state for 2nd profile. |
305 GetCache()->SetHasMigratedToGAIAInfoOfProfileAtIndex(1, false); | 306 GetCache()->SetHasMigratedToGAIAInfoOfProfileAtIndex(1, false); |
306 EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(0)); | 307 EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(0)); |
307 EXPECT_FALSE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(1)); | 308 EXPECT_FALSE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(1)); |
308 } | 309 } |
309 | 310 |
| 311 TEST_F(ProfileInfoCacheTest, ProfileActive) { |
| 312 GetCache()->AddProfileToCache( |
| 313 GetProfilePath("path_1"), ASCIIToUTF16("name_1"), |
| 314 base::string16(), 0, std::string()); |
| 315 EXPECT_EQ(base::Time(), GetCache()->GetProfileActive(0)); |
| 316 base::Time before = base::Time::Now(); |
| 317 GetCache()->SetProfileActive(0); |
| 318 base::Time after = base::Time::Now(); |
| 319 EXPECT_LE(before, GetCache()->GetProfileActive(0)); |
| 320 EXPECT_GE(after, GetCache()->GetProfileActive(0)); |
| 321 } |
| 322 |
310 TEST_F(ProfileInfoCacheTest, GAIAName) { | 323 TEST_F(ProfileInfoCacheTest, GAIAName) { |
311 GetCache()->AddProfileToCache( | 324 GetCache()->AddProfileToCache( |
312 GetProfilePath("path_1"), ASCIIToUTF16("name_1"), | 325 GetProfilePath("path_1"), ASCIIToUTF16("name_1"), |
313 base::string16(), 0, std::string()); | 326 base::string16(), 0, std::string()); |
314 base::string16 profile_name(ASCIIToUTF16("profile name 2")); | 327 base::string16 profile_name(ASCIIToUTF16("profile name 2")); |
315 GetCache()->AddProfileToCache( | 328 GetCache()->AddProfileToCache( |
316 GetProfilePath("path_2"), profile_name, base::string16(), 0, | 329 GetProfilePath("path_2"), profile_name, base::string16(), 0, |
317 std::string()); | 330 std::string()); |
318 | 331 |
319 // Sanity check. | 332 // Sanity check. |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 | 514 |
502 ASSERT_EQ(4U, GetCache()->GetNumberOfProfiles()); | 515 ASSERT_EQ(4U, GetCache()->GetNumberOfProfiles()); |
503 | 516 |
504 // Check that the profiles can be extracted from the local state. | 517 // Check that the profiles can be extracted from the local state. |
505 std::vector<base::string16> names = ProfileInfoCache::GetProfileNames(); | 518 std::vector<base::string16> names = ProfileInfoCache::GetProfileNames(); |
506 for (size_t i = 0; i < 4; i++) | 519 for (size_t i = 0; i < 4; i++) |
507 ASSERT_FALSE(names[i].empty()); | 520 ASSERT_FALSE(names[i].empty()); |
508 } | 521 } |
509 | 522 |
510 } // namespace | 523 } // namespace |
OLD | NEW |