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

Side by Side Diff: chrome/browser/chromeos/profiles/profile_list_chromeos_unittest.cc

Issue 1425093004: Revert of This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <string> 5 #include <string>
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 new ScopedUserManagerEnabler(new FakeChromeUserManager)); 65 new ScopedUserManagerEnabler(new FakeChromeUserManager));
66 } 66 }
67 67
68 FakeChromeUserManager* GetFakeChromeUserManager() { 68 FakeChromeUserManager* GetFakeChromeUserManager() {
69 return static_cast<FakeChromeUserManager*>( 69 return static_cast<FakeChromeUserManager*>(
70 user_manager::UserManager::Get()); 70 user_manager::UserManager::Get());
71 } 71 }
72 72
73 void AddProfile(base::string16 name, bool log_in) { 73 void AddProfile(base::string16 name, bool log_in) {
74 std::string email_string = base::UTF16ToASCII(name) + "@example.com"; 74 std::string email_string = base::UTF16ToASCII(name) + "@example.com";
75 const AccountId account_id(AccountId::FromUserEmail(email_string));
76 75
77 // Add a user to the fake user manager. 76 // Add a user to the fake user manager.
78 GetFakeChromeUserManager()->AddUser(account_id); 77 GetFakeChromeUserManager()->AddUser(email_string);
79 if (log_in) 78 if (log_in)
80 GetFakeChromeUserManager()->LoginUser(account_id); 79 GetFakeChromeUserManager()->LoginUser(email_string);
81 80
82 // Create a profile for the user. 81 // Create a profile for the user.
83 manager()->CreateTestingProfile(account_id.GetUserEmail()); 82 manager()->CreateTestingProfile(email_string);
84 } 83 }
85 84
86 AvatarMenu* GetAvatarMenu() { 85 AvatarMenu* GetAvatarMenu() {
87 // Reset the MockObserver. 86 // Reset the MockObserver.
88 mock_observer_.reset(new MockObserver()); 87 mock_observer_.reset(new MockObserver());
89 EXPECT_EQ(0, change_count()); 88 EXPECT_EQ(0, change_count());
90 89
91 // Reset the menu. 90 // Reset the menu.
92 avatar_menu_.reset(new AvatarMenu( 91 avatar_menu_.reset(new AvatarMenu(
93 manager()->profile_info_cache(), 92 manager()->profile_info_cache(),
94 mock_observer_.get(), 93 mock_observer_.get(),
95 NULL)); 94 NULL));
96 avatar_menu_->RebuildMenu(); 95 avatar_menu_->RebuildMenu();
97 EXPECT_EQ(0, change_count()); 96 EXPECT_EQ(0, change_count());
98 return avatar_menu_.get(); 97 return avatar_menu_.get();
99 } 98 }
100 99
101 void ActiveUserChanged(const base::string16& name) { 100 void ActiveUserChanged(const base::string16& name) {
102 std::string email_string = base::UTF16ToASCII(name) + "@example.com"; 101 std::string email_string = base::UTF16ToASCII(name) + "@example.com";
103 const AccountId account_id(AccountId::FromUserEmail(email_string)); 102 GetFakeChromeUserManager()->SwitchActiveUser(email_string);
104 GetFakeChromeUserManager()->SwitchActiveUser(account_id);
105 } 103 }
106 104
107 TestingProfileManager* manager() { return &manager_; } 105 TestingProfileManager* manager() { return &manager_; }
108 106
109 int change_count() const { return mock_observer_->change_count(); } 107 int change_count() const { return mock_observer_->change_count(); }
110 108
111 private: 109 private:
112 content::TestBrowserThreadBundle thread_bundle_; 110 content::TestBrowserThreadBundle thread_bundle_;
113 TestingProfileManager manager_; 111 TestingProfileManager manager_;
114 scoped_ptr<MockObserver> mock_observer_; 112 scoped_ptr<MockObserver> mock_observer_;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 base::string16 supervised_name(ASCIIToUTF16("p2@example.com")); 160 base::string16 supervised_name(ASCIIToUTF16("p2@example.com"));
163 161
164 AddProfile(name1, true); 162 AddProfile(name1, true);
165 163
166 // Add a managed user profile. 164 // Add a managed user profile.
167 ProfileInfoCache* cache = manager()->profile_info_cache(); 165 ProfileInfoCache* cache = manager()->profile_info_cache();
168 manager()->profile_info_cache()->AddProfileToCache( 166 manager()->profile_info_cache()->AddProfileToCache(
169 cache->GetUserDataDir().AppendASCII("p2"), supervised_name, std::string(), 167 cache->GetUserDataDir().AppendASCII("p2"), supervised_name, std::string(),
170 base::string16(), 0, "TEST_ID"); 168 base::string16(), 0, "TEST_ID");
171 169
172 GetFakeChromeUserManager()->AddUser( 170 GetFakeChromeUserManager()->AddUser(base::UTF16ToASCII(supervised_name));
173 AccountId::FromUserEmail(base::UTF16ToASCII(supervised_name)));
174 171
175 AvatarMenu* menu = GetAvatarMenu(); 172 AvatarMenu* menu = GetAvatarMenu();
176 ASSERT_EQ(1U, menu->GetNumberOfItems()); 173 ASSERT_EQ(1U, menu->GetNumberOfItems());
177 174
178 const AvatarMenu::Item& item1 = menu->GetItemAt(0); 175 const AvatarMenu::Item& item1 = menu->GetItemAt(0);
179 EXPECT_EQ(0U, item1.menu_index); 176 EXPECT_EQ(0U, item1.menu_index);
180 EXPECT_EQ(name1, item1.name); 177 EXPECT_EQ(name1, item1.name);
181 } 178 }
182 179
183 TEST_F(ProfileListChromeOSTest, ShowAddProfileLink) { 180 TEST_F(ProfileListChromeOSTest, ShowAddProfileLink) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 EXPECT_EQ(0U, item1.menu_index); 236 EXPECT_EQ(0U, item1.menu_index);
240 EXPECT_EQ(name1, item1.name); 237 EXPECT_EQ(name1, item1.name);
241 238
242 const AvatarMenu::Item& item2 = menu->GetItemAt(1); 239 const AvatarMenu::Item& item2 = menu->GetItemAt(1);
243 EXPECT_EQ(1U, item2.menu_index); 240 EXPECT_EQ(1U, item2.menu_index);
244 EXPECT_EQ(name2, item2.name); 241 EXPECT_EQ(name2, item2.name);
245 242
246 // Change name of the first profile, to trigger resorting of the profiles: 243 // Change name of the first profile, to trigger resorting of the profiles:
247 // now the first menu item should be named "beta", and the second be "gamma". 244 // now the first menu item should be named "beta", and the second be "gamma".
248 GetFakeChromeUserManager()->SaveUserDisplayName( 245 GetFakeChromeUserManager()->SaveUserDisplayName(
249 AccountId::FromUserEmail(base::UTF16ToASCII(name1) + "@example.com"), 246 base::UTF16ToASCII(name1) + "@example.com", newname1);
250 newname1);
251 manager()->profile_info_cache()->SetNameOfProfileAtIndex(0, newname1); 247 manager()->profile_info_cache()->SetNameOfProfileAtIndex(0, newname1);
252 EXPECT_EQ(1, change_count()); 248 EXPECT_EQ(1, change_count());
253 249
254 const AvatarMenu::Item& item1next = menu->GetItemAt(0); 250 const AvatarMenu::Item& item1next = menu->GetItemAt(0);
255 EXPECT_EQ(0U, item1next.menu_index); 251 EXPECT_EQ(0U, item1next.menu_index);
256 EXPECT_EQ(name2, item1next.name); 252 EXPECT_EQ(name2, item1next.name);
257 253
258 const AvatarMenu::Item& item2next = menu->GetItemAt(1); 254 const AvatarMenu::Item& item2next = menu->GetItemAt(1);
259 EXPECT_EQ(1U, item2next.menu_index); 255 EXPECT_EQ(1U, item2next.menu_index);
260 EXPECT_EQ(newname1, item2next.name); 256 EXPECT_EQ(newname1, item2next.name);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 298
303 // Should only show avatar menu with multiple users. 299 // Should only show avatar menu with multiple users.
304 EXPECT_FALSE(AvatarMenu::ShouldShowAvatarMenu()); 300 EXPECT_FALSE(AvatarMenu::ShouldShowAvatarMenu());
305 301
306 AddProfile(name2, false); 302 AddProfile(name2, false);
307 303
308 EXPECT_FALSE(AvatarMenu::ShouldShowAvatarMenu()); 304 EXPECT_FALSE(AvatarMenu::ShouldShowAvatarMenu());
309 } 305 }
310 306
311 } // namespace chromeos 307 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698