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/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/prefs/testing_pref_service.h" | 11 #include "base/prefs/testing_pref_service.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
17 #include "chrome/browser/prefs/pref_service_syncable.h" | 17 #include "chrome/browser/prefs/pref_service_syncable.h" |
18 #include "chrome/browser/profiles/profile_avatar_downloader.h" | 18 #include "chrome/browser/profiles/profile_avatar_downloader.h" |
19 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 19 #include "chrome/browser/profiles/profile_avatar_icon_util.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_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/common/pref_names.h" |
23 #include "chrome/test/base/testing_browser_process.h" | 24 #include "chrome/test/base/testing_browser_process.h" |
24 #include "components/signin/core/common/profile_management_switches.h" | 25 #include "components/signin/core/common/profile_management_switches.h" |
25 #include "content/public/browser/notification_observer.h" | 26 #include "content/public/browser/notification_observer.h" |
26 #include "content/public/browser/notification_registrar.h" | 27 #include "content/public/browser/notification_registrar.h" |
27 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
28 #include "content/public/test/test_browser_thread_bundle.h" | 29 #include "content/public/test/test_browser_thread_bundle.h" |
29 #include "content/public/test/test_utils.h" | 30 #include "content/public/test/test_utils.h" |
30 #include "third_party/skia/include/core/SkBitmap.h" | 31 #include "third_party/skia/include/core/SkBitmap.h" |
31 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
32 #include "ui/gfx/image/image.h" | 33 #include "ui/gfx/image/image.h" |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 GetCache()->AddProfileToCache(profile_path, profile_name, base::string16(), | 524 GetCache()->AddProfileToCache(profile_path, profile_name, base::string16(), |
524 i, ""); | 525 i, ""); |
525 | 526 |
526 EXPECT_EQ(profile_path, GetCache()->GetPathOfProfileAtIndex(i)); | 527 EXPECT_EQ(profile_path, GetCache()->GetPathOfProfileAtIndex(i)); |
527 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i)); | 528 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i)); |
528 } | 529 } |
529 | 530 |
530 ASSERT_EQ(4U, GetCache()->GetNumberOfProfiles()); | 531 ASSERT_EQ(4U, GetCache()->GetNumberOfProfiles()); |
531 | 532 |
532 // Check that the profiles can be extracted from the local state. | 533 // Check that the profiles can be extracted from the local state. |
533 std::vector<base::string16> names = ProfileInfoCache::GetProfileNames(); | 534 std::vector<base::string16> names; |
| 535 PrefService* local_state = g_browser_process->local_state(); |
| 536 const base::DictionaryValue* cache = local_state->GetDictionary( |
| 537 prefs::kProfileInfoCache); |
| 538 base::string16 name; |
| 539 for (base::DictionaryValue::Iterator it(*cache); !it.IsAtEnd(); |
| 540 it.Advance()) { |
| 541 const base::DictionaryValue* info = NULL; |
| 542 it.value().GetAsDictionary(&info); |
| 543 info->GetString("name", &name); |
| 544 names.push_back(name); |
| 545 } |
| 546 |
534 for (size_t i = 0; i < 4; i++) | 547 for (size_t i = 0; i < 4; i++) |
535 ASSERT_FALSE(names[i].empty()); | 548 ASSERT_FALSE(names[i].empty()); |
536 } | 549 } |
537 | 550 |
538 // High res avatar downloading is only supported on desktop. | 551 // High res avatar downloading is only supported on desktop. |
539 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS) | 552 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS) |
540 TEST_F(ProfileInfoCacheTest, DownloadHighResAvatarTest) { | 553 TEST_F(ProfileInfoCacheTest, DownloadHighResAvatarTest) { |
541 switches::EnableNewAvatarMenuForTesting( | 554 switches::EnableNewAvatarMenuForTesting( |
542 base::CommandLine::ForCurrentProcess()); | 555 base::CommandLine::ForCurrentProcess()); |
543 | 556 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 // Profile names should have been preserved. | 685 // Profile names should have been preserved. |
673 EXPECT_EQ(name_1, GetCache()->GetNameOfProfileAtIndex( | 686 EXPECT_EQ(name_1, GetCache()->GetNameOfProfileAtIndex( |
674 GetCache()->GetIndexOfProfileWithPath(path_1))); | 687 GetCache()->GetIndexOfProfileWithPath(path_1))); |
675 EXPECT_EQ(name_2, GetCache()->GetNameOfProfileAtIndex( | 688 EXPECT_EQ(name_2, GetCache()->GetNameOfProfileAtIndex( |
676 GetCache()->GetIndexOfProfileWithPath(path_2))); | 689 GetCache()->GetIndexOfProfileWithPath(path_2))); |
677 EXPECT_EQ(name_3, GetCache()->GetNameOfProfileAtIndex( | 690 EXPECT_EQ(name_3, GetCache()->GetNameOfProfileAtIndex( |
678 GetCache()->GetIndexOfProfileWithPath(path_3))); | 691 GetCache()->GetIndexOfProfileWithPath(path_3))); |
679 EXPECT_EQ(name_4, GetCache()->GetNameOfProfileAtIndex( | 692 EXPECT_EQ(name_4, GetCache()->GetNameOfProfileAtIndex( |
680 GetCache()->GetIndexOfProfileWithPath(path_4))); | 693 GetCache()->GetIndexOfProfileWithPath(path_4))); |
681 } | 694 } |
OLD | NEW |