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 for (uint32 i = 0; i < 4; ++i) { | |
469 base::FilePath profile_path = | |
470 GetProfilePath(base::StringPrintf("path%ctest%u", | |
471 i % 2 ? '_' : '.', | |
472 i)); | |
473 string16 profile_name = ASCIIToUTF16(base::StringPrintf("name_%u", i)); | |
xiyuan
2013/09/14 18:39:56
nit: It's easier to read if we put the profile_pat
michaelpg
2013/09/14 19:30:24
Done.
| |
474 | |
475 GetCache()->AddProfileToCache(profile_path, profile_name, string16(), i, | |
476 ""); | |
477 | |
478 EXPECT_EQ(profile_path, GetCache()->GetPathOfProfileAtIndex(i)); | |
479 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i)); | |
480 } | |
481 | |
482 ASSERT_EQ(4U, GetCache()->GetNumberOfProfiles()); | |
483 | |
484 // Check that the profiles can be extracted from the local state. | |
485 std::vector<string16> names = ProfileInfoCache::GetProfileNames(); | |
486 for (size_t i = 0; i < 4; i++) | |
487 ASSERT_FALSE(names[i].empty()); | |
488 } | |
489 | |
462 } // namespace | 490 } // namespace |
OLD | NEW |