OLD | NEW |
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 TEST_F(ProfileListChromeOSTest, ModifyingNameResortsCorrectly) { | 221 TEST_F(ProfileListChromeOSTest, ModifyingNameResortsCorrectly) { |
222 base::string16 name1(ASCIIToUTF16("Alpha")); | 222 base::string16 name1(ASCIIToUTF16("Alpha")); |
223 base::string16 name2(ASCIIToUTF16("Beta")); | 223 base::string16 name2(ASCIIToUTF16("Beta")); |
224 base::string16 newname1(ASCIIToUTF16("Gamma")); | 224 base::string16 newname1(ASCIIToUTF16("Gamma")); |
225 | 225 |
226 AddProfile(name1, true); | 226 AddProfile(name1, true); |
227 AddProfile(name2, true); | 227 AddProfile(name2, true); |
228 | 228 |
229 AvatarMenu* menu = GetAvatarMenu(); | 229 AvatarMenu* menu = GetAvatarMenu(); |
230 | 230 EXPECT_EQ(0, change_count()); |
231 ASSERT_EQ(2U, menu->GetNumberOfItems()); | 231 ASSERT_EQ(2U, menu->GetNumberOfItems()); |
232 | 232 |
233 const AvatarMenu::Item& item1 = menu->GetItemAt(0); | 233 const AvatarMenu::Item& item1 = menu->GetItemAt(0); |
234 EXPECT_EQ(0U, item1.menu_index); | 234 EXPECT_EQ(0U, item1.menu_index); |
235 EXPECT_EQ(name1, item1.name); | 235 EXPECT_EQ(name1, item1.name); |
236 | 236 |
237 const AvatarMenu::Item& item2 = menu->GetItemAt(1); | 237 const AvatarMenu::Item& item2 = menu->GetItemAt(1); |
238 EXPECT_EQ(1U, item2.menu_index); | 238 EXPECT_EQ(1U, item2.menu_index); |
239 EXPECT_EQ(name2, item2.name); | 239 EXPECT_EQ(name2, item2.name); |
240 | 240 |
241 // Change name of the first profile, to trigger resorting of the profiles: | 241 // Change name of the first profile, to trigger resorting of the profiles: |
242 // now the first menu item should be named "beta", and the second be "gamma". | 242 // now the first menu item should be named "beta", and the second be "gamma". |
243 GetFakeChromeUserManager()->SaveUserDisplayName( | 243 GetFakeChromeUserManager()->SaveUserDisplayName( |
244 base::UTF16ToASCII(name1) + "@example.com", newname1); | 244 base::UTF16ToASCII(name1) + "@example.com", newname1); |
245 manager()->profile_info_cache()->SetNameOfProfileAtIndex(0, newname1); | 245 manager()->profile_info_cache()->SetNameOfProfileAtIndex(0, newname1); |
| 246 EXPECT_EQ(1, change_count()); |
246 | 247 |
247 const AvatarMenu::Item& item1next = menu->GetItemAt(0); | 248 const AvatarMenu::Item& item1next = menu->GetItemAt(0); |
248 EXPECT_GT(change_count(), 1); | |
249 EXPECT_EQ(0U, item1next.menu_index); | 249 EXPECT_EQ(0U, item1next.menu_index); |
250 EXPECT_EQ(name2, item1next.name); | 250 EXPECT_EQ(name2, item1next.name); |
251 | 251 |
252 const AvatarMenu::Item& item2next = menu->GetItemAt(1); | 252 const AvatarMenu::Item& item2next = menu->GetItemAt(1); |
253 EXPECT_EQ(1U, item2next.menu_index); | 253 EXPECT_EQ(1U, item2next.menu_index); |
254 EXPECT_EQ(newname1, item2next.name); | 254 EXPECT_EQ(newname1, item2next.name); |
255 } | 255 } |
256 | 256 |
257 TEST_F(ProfileListChromeOSTest, ChangeOnNotify) { | 257 TEST_F(ProfileListChromeOSTest, ChangeOnNotify) { |
258 base::string16 name1(ASCIIToUTF16("p1.com")); | 258 base::string16 name1(ASCIIToUTF16("p1.com")); |
259 base::string16 name2(ASCIIToUTF16("p2.com")); | 259 base::string16 name2(ASCIIToUTF16("p2.com")); |
260 | 260 |
261 AddProfile(name1, true); | 261 AddProfile(name1, true); |
262 AddProfile(name2, true); | 262 AddProfile(name2, true); |
263 | 263 |
264 AvatarMenu* menu = GetAvatarMenu(); | 264 AvatarMenu* menu = GetAvatarMenu(); |
265 EXPECT_EQ(2U, menu->GetNumberOfItems()); | 265 EXPECT_EQ(2U, menu->GetNumberOfItems()); |
| 266 EXPECT_EQ(0, change_count()); |
266 | 267 |
267 base::string16 name3(ASCIIToUTF16("p3.com")); | 268 base::string16 name3(ASCIIToUTF16("p3.com")); |
268 AddProfile(name3, true); | 269 AddProfile(name3, true); |
269 | 270 |
270 // Four changes happened via the call to CreateTestingProfile: adding the | 271 // Three changes happened via the call to CreateTestingProfile: adding the |
271 // profile to the cache, setting the user name, rebuilding the list of | 272 // profile to the cache, setting the user name (which rebuilt the list of |
272 // profiles after the name change, and changing the avatar. | 273 // profiles after the name change), and changing the avatar. |
273 // TODO(michaelpg): Determine why actual change number does not match comment. | 274 EXPECT_EQ(change_count(), 3); |
274 EXPECT_GE(change_count(), 4); | |
275 ASSERT_EQ(3U, menu->GetNumberOfItems()); | 275 ASSERT_EQ(3U, menu->GetNumberOfItems()); |
276 | 276 |
277 const AvatarMenu::Item& item1 = menu->GetItemAt(0); | 277 const AvatarMenu::Item& item1 = menu->GetItemAt(0); |
278 EXPECT_EQ(0U, item1.menu_index); | 278 EXPECT_EQ(0U, item1.menu_index); |
279 EXPECT_EQ(name1, item1.name); | 279 EXPECT_EQ(name1, item1.name); |
280 | 280 |
281 const AvatarMenu::Item& item2 = menu->GetItemAt(1); | 281 const AvatarMenu::Item& item2 = menu->GetItemAt(1); |
282 EXPECT_EQ(1U, item2.menu_index); | 282 EXPECT_EQ(1U, item2.menu_index); |
283 EXPECT_EQ(name2, item2.name); | 283 EXPECT_EQ(name2, item2.name); |
284 | 284 |
(...skipping 11 matching lines...) Expand all Loading... |
296 | 296 |
297 // Should only show avatar menu with multiple users. | 297 // Should only show avatar menu with multiple users. |
298 EXPECT_FALSE(AvatarMenu::ShouldShowAvatarMenu()); | 298 EXPECT_FALSE(AvatarMenu::ShouldShowAvatarMenu()); |
299 | 299 |
300 AddProfile(name2, false); | 300 AddProfile(name2, false); |
301 | 301 |
302 EXPECT_FALSE(AvatarMenu::ShouldShowAvatarMenu()); | 302 EXPECT_FALSE(AvatarMenu::ShouldShowAvatarMenu()); |
303 } | 303 } |
304 | 304 |
305 } // namespace chromeos | 305 } // namespace chromeos |
OLD | NEW |