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/prefs/pref_service_syncable.h" | 16 #include "chrome/browser/prefs/pref_service_syncable.h" |
17 #include "chrome/browser/profiles/profile_avatar_downloader.h" | 17 #include "chrome/browser/profiles/profile_avatar_downloader.h" |
18 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 18 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
19 #include "chrome/browser/profiles/profile_info_cache.h" | 19 #include "chrome/browser/profiles/profile_info_cache.h" |
20 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "chrome/common/chrome_paths.h" |
21 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/common/pref_names.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/test/test_browser_thread_bundle.h" | 26 #include "content/public/test/test_browser_thread_bundle.h" |
26 #include "content/public/test/test_utils.h" | 27 #include "content/public/test/test_utils.h" |
27 #include "third_party/skia/include/core/SkBitmap.h" | 28 #include "third_party/skia/include/core/SkBitmap.h" |
28 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
29 #include "ui/gfx/image/image.h" | 30 #include "ui/gfx/image/image.h" |
30 #include "ui/gfx/image/image_unittest_util.h" | 31 #include "ui/gfx/image/image_unittest_util.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 GetCache()->GetIndexOfProfileWithPath(profile_path)); | 82 GetCache()->GetIndexOfProfileWithPath(profile_path)); |
82 EXPECT_TRUE(profile_names_.find(profile_name) != profile_names_.end()); | 83 EXPECT_TRUE(profile_names_.find(profile_name) != profile_names_.end()); |
83 } | 84 } |
84 | 85 |
85 ProfileInfoCache* ProfileNameVerifierObserver::GetCache() { | 86 ProfileInfoCache* ProfileNameVerifierObserver::GetCache() { |
86 return testing_profile_manager_->profile_info_cache(); | 87 return testing_profile_manager_->profile_info_cache(); |
87 } | 88 } |
88 | 89 |
89 ProfileInfoCacheTest::ProfileInfoCacheTest() | 90 ProfileInfoCacheTest::ProfileInfoCacheTest() |
90 : testing_profile_manager_(TestingBrowserProcess::GetGlobal()), | 91 : testing_profile_manager_(TestingBrowserProcess::GetGlobal()), |
91 name_observer_(&testing_profile_manager_) { | 92 name_observer_(&testing_profile_manager_), |
| 93 user_data_dir_override_(chrome::DIR_USER_DATA) { |
92 } | 94 } |
93 | 95 |
94 ProfileInfoCacheTest::~ProfileInfoCacheTest() { | 96 ProfileInfoCacheTest::~ProfileInfoCacheTest() { |
95 } | 97 } |
96 | 98 |
97 void ProfileInfoCacheTest::SetUp() { | 99 void ProfileInfoCacheTest::SetUp() { |
98 ASSERT_TRUE(testing_profile_manager_.SetUp()); | 100 ASSERT_TRUE(testing_profile_manager_.SetUp()); |
99 testing_profile_manager_.profile_info_cache()->AddObserver(&name_observer_); | 101 testing_profile_manager_.profile_info_cache()->AddObserver(&name_observer_); |
100 } | 102 } |
101 | 103 |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 // High res avatar downloading is only supported on desktop. | 545 // High res avatar downloading is only supported on desktop. |
544 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS) | 546 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS) |
545 TEST_F(ProfileInfoCacheTest, DownloadHighResAvatarTest) { | 547 TEST_F(ProfileInfoCacheTest, DownloadHighResAvatarTest) { |
546 switches::EnableNewAvatarMenuForTesting( | 548 switches::EnableNewAvatarMenuForTesting( |
547 base::CommandLine::ForCurrentProcess()); | 549 base::CommandLine::ForCurrentProcess()); |
548 | 550 |
549 // The TestingProfileManager's ProfileInfoCache doesn't download avatars. | 551 // The TestingProfileManager's ProfileInfoCache doesn't download avatars. |
550 ProfileInfoCache profile_info_cache(g_browser_process->local_state(), | 552 ProfileInfoCache profile_info_cache(g_browser_process->local_state(), |
551 testing_profile_manager_.profile_manager()->user_data_dir()); | 553 testing_profile_manager_.profile_manager()->user_data_dir()); |
552 | 554 |
553 // // Make sure there are no avatars already on disk. | 555 // Make sure there are no avatars already on disk. |
554 const size_t kIconIndex = 0; | 556 const size_t kIconIndex = 0; |
555 base::FilePath icon_path = | 557 base::FilePath icon_path = |
556 profiles::GetPathOfHighResAvatarAtIndex(kIconIndex); | 558 profiles::GetPathOfHighResAvatarAtIndex(kIconIndex); |
557 EXPECT_FALSE(base::PathExists(icon_path)); | 559 EXPECT_FALSE(base::PathExists(icon_path)); |
558 | 560 |
559 EXPECT_EQ(0U, profile_info_cache.GetNumberOfProfiles()); | 561 EXPECT_EQ(0U, profile_info_cache.GetNumberOfProfiles()); |
560 base::FilePath path_1 = GetProfilePath("path_1"); | 562 base::FilePath path_1 = GetProfilePath("path_1"); |
561 profile_info_cache.AddProfileToCache(path_1, ASCIIToUTF16("name_1"), | 563 profile_info_cache.AddProfileToCache(path_1, ASCIIToUTF16("name_1"), |
562 base::string16(), kIconIndex, std::string()); | 564 base::string16(), kIconIndex, std::string()); |
563 EXPECT_EQ(1U, profile_info_cache.GetNumberOfProfiles()); | 565 EXPECT_EQ(1U, profile_info_cache.GetNumberOfProfiles()); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 // Profile names should have been preserved. | 687 // Profile names should have been preserved. |
686 EXPECT_EQ(name_1, GetCache()->GetNameOfProfileAtIndex( | 688 EXPECT_EQ(name_1, GetCache()->GetNameOfProfileAtIndex( |
687 GetCache()->GetIndexOfProfileWithPath(path_1))); | 689 GetCache()->GetIndexOfProfileWithPath(path_1))); |
688 EXPECT_EQ(name_2, GetCache()->GetNameOfProfileAtIndex( | 690 EXPECT_EQ(name_2, GetCache()->GetNameOfProfileAtIndex( |
689 GetCache()->GetIndexOfProfileWithPath(path_2))); | 691 GetCache()->GetIndexOfProfileWithPath(path_2))); |
690 EXPECT_EQ(name_3, GetCache()->GetNameOfProfileAtIndex( | 692 EXPECT_EQ(name_3, GetCache()->GetNameOfProfileAtIndex( |
691 GetCache()->GetIndexOfProfileWithPath(path_3))); | 693 GetCache()->GetIndexOfProfileWithPath(path_3))); |
692 EXPECT_EQ(name_4, GetCache()->GetNameOfProfileAtIndex( | 694 EXPECT_EQ(name_4, GetCache()->GetNameOfProfileAtIndex( |
693 GetCache()->GetIndexOfProfileWithPath(path_4))); | 695 GetCache()->GetIndexOfProfileWithPath(path_4))); |
694 } | 696 } |
OLD | NEW |