Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(705)

Side by Side Diff: chrome/browser/profiles/profile_info_cache_unittest.cc

Issue 12767006: [Cleanup] Remove StringPrintf from global namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, once more Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/prefs/testing_pref_service.h" 7 #include "base/prefs/testing_pref_service.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 testing_profile_manager_.DeleteProfileInfoCache(); 112 testing_profile_manager_.DeleteProfileInfoCache();
113 } 113 }
114 114
115 namespace { 115 namespace {
116 116
117 TEST_F(ProfileInfoCacheTest, AddProfiles) { 117 TEST_F(ProfileInfoCacheTest, AddProfiles) {
118 EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles()); 118 EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles());
119 119
120 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 120 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
121 for (uint32 i = 0; i < 4; ++i) { 121 for (uint32 i = 0; i < 4; ++i) {
122 base::FilePath profile_path = GetProfilePath(StringPrintf("path_%ud", i)); 122 base::FilePath profile_path =
123 string16 profile_name = ASCIIToUTF16(StringPrintf("name_%ud", i)); 123 GetProfilePath(base::StringPrintf("path_%ud", i));
124 string16 profile_name = ASCIIToUTF16(base::StringPrintf("name_%ud", i));
124 const SkBitmap* icon = rb.GetImageNamed( 125 const SkBitmap* icon = rb.GetImageNamed(
125 ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex( 126 ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex(
126 i)).ToSkBitmap(); 127 i)).ToSkBitmap();
127 128
128 GetCache()->AddProfileToCache(profile_path, profile_name, string16(), i, 129 GetCache()->AddProfileToCache(profile_path, profile_name, string16(), i,
129 false); 130 false);
130 GetCache()->SetBackgroundStatusOfProfileAtIndex(i, true); 131 GetCache()->SetBackgroundStatusOfProfileAtIndex(i, true);
131 string16 gaia_name = ASCIIToUTF16(StringPrintf("gaia_%ud", i)); 132 string16 gaia_name = ASCIIToUTF16(base::StringPrintf("gaia_%ud", i));
132 GetCache()->SetGAIANameOfProfileAtIndex(i, gaia_name); 133 GetCache()->SetGAIANameOfProfileAtIndex(i, gaia_name);
133 134
134 EXPECT_EQ(i + 1, GetCache()->GetNumberOfProfiles()); 135 EXPECT_EQ(i + 1, GetCache()->GetNumberOfProfiles());
135 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i)); 136 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i));
136 EXPECT_EQ(profile_path, GetCache()->GetPathOfProfileAtIndex(i)); 137 EXPECT_EQ(profile_path, GetCache()->GetPathOfProfileAtIndex(i));
137 const SkBitmap* actual_icon = GetCache()->GetAvatarIconOfProfileAtIndex( 138 const SkBitmap* actual_icon = GetCache()->GetAvatarIconOfProfileAtIndex(
138 i).ToSkBitmap(); 139 i).ToSkBitmap();
139 EXPECT_EQ(icon->width(), actual_icon->width()); 140 EXPECT_EQ(icon->width(), actual_icon->width());
140 EXPECT_EQ(icon->height(), actual_icon->height()); 141 EXPECT_EQ(icon->height(), actual_icon->height());
141 } 142 }
142 143
143 // Reset the cache and test the it reloads correctly. 144 // Reset the cache and test the it reloads correctly.
144 ResetCache(); 145 ResetCache();
145 146
146 EXPECT_EQ(4u, GetCache()->GetNumberOfProfiles()); 147 EXPECT_EQ(4u, GetCache()->GetNumberOfProfiles());
147 for (uint32 i = 0; i < 4; ++i) { 148 for (uint32 i = 0; i < 4; ++i) {
148 base::FilePath profile_path = GetProfilePath(StringPrintf("path_%ud", i)); 149 base::FilePath profile_path =
150 GetProfilePath(base::StringPrintf("path_%ud", i));
149 EXPECT_EQ(i, GetCache()->GetIndexOfProfileWithPath(profile_path)); 151 EXPECT_EQ(i, GetCache()->GetIndexOfProfileWithPath(profile_path));
150 string16 profile_name = ASCIIToUTF16(StringPrintf("name_%ud", i)); 152 string16 profile_name = ASCIIToUTF16(base::StringPrintf("name_%ud", i));
151 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i)); 153 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i));
152 EXPECT_EQ(i, GetCache()->GetAvatarIconIndexOfProfileAtIndex(i)); 154 EXPECT_EQ(i, GetCache()->GetAvatarIconIndexOfProfileAtIndex(i));
153 EXPECT_EQ(true, GetCache()->GetBackgroundStatusOfProfileAtIndex(i)); 155 EXPECT_EQ(true, GetCache()->GetBackgroundStatusOfProfileAtIndex(i));
154 string16 gaia_name = ASCIIToUTF16(StringPrintf("gaia_%ud", i)); 156 string16 gaia_name = ASCIIToUTF16(base::StringPrintf("gaia_%ud", i));
155 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(i)); 157 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(i));
156 } 158 }
157 } 159 }
158 160
159 TEST_F(ProfileInfoCacheTest, DeleteProfile) { 161 TEST_F(ProfileInfoCacheTest, DeleteProfile) {
160 EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles()); 162 EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles());
161 163
162 base::FilePath path_1 = GetProfilePath("path_1"); 164 base::FilePath path_1 = GetProfilePath("path_1");
163 GetCache()->AddProfileToCache(path_1, ASCIIToUTF16("name_1"), string16(), 165 GetCache()->AddProfileToCache(path_1, ASCIIToUTF16("name_1"), string16(),
164 0, false); 166 0, false);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 GetCache()->SetIsUsingGAIANameOfProfileAtIndex(0, true); 409 GetCache()->SetIsUsingGAIANameOfProfileAtIndex(0, true);
408 GetCache()->SetIsUsingGAIAPictureOfProfileAtIndex(0, true); 410 GetCache()->SetIsUsingGAIAPictureOfProfileAtIndex(0, true);
409 411
410 // Verify that the profile name and picture are not empty. 412 // Verify that the profile name and picture are not empty.
411 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(0)); 413 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(0));
412 EXPECT_TRUE(gfx::test::IsEqual( 414 EXPECT_TRUE(gfx::test::IsEqual(
413 profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(0))); 415 profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(0)));
414 } 416 }
415 417
416 } // namespace 418 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698