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> |
| 8 |
7 #include "base/prefs/testing_pref_service.h" | 9 #include "base/prefs/testing_pref_service.h" |
8 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/prefs/pref_service_syncable.h" | 14 #include "chrome/browser/prefs/pref_service_syncable.h" |
13 #include "chrome/browser/profiles/profile_info_cache.h" | 15 #include "chrome/browser/profiles/profile_info_cache.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/test/base/testing_browser_process.h" | 17 #include "chrome/test/base/testing_browser_process.h" |
16 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 managed_user_name, 0, "TEST_ID"); | 454 managed_user_name, 0, "TEST_ID"); |
453 for (size_t i = 0; i < GetCache()->GetNumberOfProfiles(); i++) { | 455 for (size_t i = 0; i < GetCache()->GetNumberOfProfiles(); i++) { |
454 bool is_managed = | 456 bool is_managed = |
455 GetCache()->GetNameOfProfileAtIndex(i) == managed_user_name; | 457 GetCache()->GetNameOfProfileAtIndex(i) == managed_user_name; |
456 EXPECT_EQ(is_managed, GetCache()->ProfileIsManagedAtIndex(i)); | 458 EXPECT_EQ(is_managed, GetCache()->ProfileIsManagedAtIndex(i)); |
457 std::string managed_user_id = is_managed ? "TEST_ID" : ""; | 459 std::string managed_user_id = is_managed ? "TEST_ID" : ""; |
458 EXPECT_EQ(managed_user_id, GetCache()->GetManagedUserIdOfProfileAtIndex(i)); | 460 EXPECT_EQ(managed_user_id, GetCache()->GetManagedUserIdOfProfileAtIndex(i)); |
459 } | 461 } |
460 } | 462 } |
461 | 463 |
| 464 TEST_F(ProfileInfoCacheTest, AddStubProfile) { |
| 465 EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles()); |
| 466 |
| 467 // Add some profiles with and without a '.' in their paths. |
| 468 const struct { |
| 469 const char* profile_path; |
| 470 const char* profile_name; |
| 471 } kTestCases[] = { |
| 472 { "path.test0", "name_0" }, |
| 473 { "path_test1", "name_1" }, |
| 474 { "path.test2", "name_2" }, |
| 475 { "path_test3", "name_3" }, |
| 476 }; |
| 477 |
| 478 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
| 479 base::FilePath profile_path = GetProfilePath(kTestCases[i].profile_path); |
| 480 string16 profile_name = ASCIIToUTF16(kTestCases[i].profile_name); |
| 481 |
| 482 GetCache()->AddProfileToCache(profile_path, profile_name, string16(), i, |
| 483 ""); |
| 484 |
| 485 EXPECT_EQ(profile_path, GetCache()->GetPathOfProfileAtIndex(i)); |
| 486 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i)); |
| 487 } |
| 488 |
| 489 ASSERT_EQ(4U, GetCache()->GetNumberOfProfiles()); |
| 490 |
| 491 // Check that the profiles can be extracted from the local state. |
| 492 std::vector<string16> names = ProfileInfoCache::GetProfileNames(); |
| 493 for (size_t i = 0; i < 4; i++) |
| 494 ASSERT_FALSE(names[i].empty()); |
| 495 } |
| 496 |
462 } // namespace | 497 } // namespace |
OLD | NEW |