| 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_list_desktop.h" | 5 #include "chrome/browser/profiles/profile_list_desktop.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 219 |
| 220 const AvatarMenu::Item& item2 = model->GetItemAt(1); | 220 const AvatarMenu::Item& item2 = model->GetItemAt(1); |
| 221 EXPECT_EQ(1U, item2.menu_index); | 221 EXPECT_EQ(1U, item2.menu_index); |
| 222 EXPECT_EQ(ASCIIToUTF16(name2), item2.name); | 222 EXPECT_EQ(ASCIIToUTF16(name2), item2.name); |
| 223 | 223 |
| 224 // Change name of the first profile, to trigger resorting of the profiles: | 224 // Change name of the first profile, to trigger resorting of the profiles: |
| 225 // now the first model should be named "beta", and the second be "gamma". | 225 // now the first model should be named "beta", and the second be "gamma". |
| 226 manager()->profile_info_cache()->SetNameOfProfileAtIndex(0, | 226 manager()->profile_info_cache()->SetNameOfProfileAtIndex(0, |
| 227 ASCIIToUTF16(newname1)); | 227 ASCIIToUTF16(newname1)); |
| 228 const AvatarMenu::Item& item1next = model->GetItemAt(0); | 228 const AvatarMenu::Item& item1next = model->GetItemAt(0); |
| 229 EXPECT_GT(change_count(), 1); | 229 EXPECT_EQ(1, change_count()); |
| 230 EXPECT_EQ(0U, item1next.menu_index); | 230 EXPECT_EQ(0U, item1next.menu_index); |
| 231 EXPECT_EQ(ASCIIToUTF16(name2), item1next.name); | 231 EXPECT_EQ(ASCIIToUTF16(name2), item1next.name); |
| 232 | 232 |
| 233 const AvatarMenu::Item& item2next = model->GetItemAt(1); | 233 const AvatarMenu::Item& item2next = model->GetItemAt(1); |
| 234 EXPECT_EQ(1U, item2next.menu_index); | 234 EXPECT_EQ(1U, item2next.menu_index); |
| 235 EXPECT_EQ(ASCIIToUTF16(newname1), item2next.name); | 235 EXPECT_EQ(ASCIIToUTF16(newname1), item2next.name); |
| 236 } | 236 } |
| 237 | 237 |
| 238 TEST_F(ProfileListDesktopTest, ChangeOnNotify) { | 238 TEST_F(ProfileListDesktopTest, ChangeOnNotify) { |
| 239 manager()->CreateTestingProfile("Test 1"); | 239 manager()->CreateTestingProfile("Test 1"); |
| 240 manager()->CreateTestingProfile("Test 2"); | 240 manager()->CreateTestingProfile("Test 2"); |
| 241 | 241 |
| 242 AvatarMenu* model = GetAvatarMenu(); | 242 AvatarMenu* model = GetAvatarMenu(); |
| 243 EXPECT_EQ(0, change_count()); | 243 EXPECT_EQ(0, change_count()); |
| 244 EXPECT_EQ(2U, model->GetNumberOfItems()); | 244 EXPECT_EQ(2U, model->GetNumberOfItems()); |
| 245 | 245 |
| 246 manager()->CreateTestingProfile("Test 3"); | 246 manager()->CreateTestingProfile("Test 3"); |
| 247 | 247 |
| 248 // Four changes happened via the call to CreateTestingProfile: adding the | 248 // Three changes happened via the call to CreateTestingProfile: adding the |
| 249 // profile to the cache, setting the user name, rebuilding the list of | 249 // profile to the cache, setting the user name (which rebuilds the list of |
| 250 // profiles after the name change, and changing the avatar. | 250 // profiles after the name change) and changing the avatar. |
| 251 // On Windows, an extra change happens to set the shortcut name for the | 251 // On Windows, an extra change happens to set the shortcut name for the |
| 252 // profile. | 252 // profile. |
| 253 // TODO(michaelpg): Determine why five changes happen on ChromeOS and | 253 EXPECT_GE(3, change_count()); |
| 254 // investigate other platforms. | |
| 255 EXPECT_GE(change_count(), 4); | |
| 256 ASSERT_EQ(3U, model->GetNumberOfItems()); | 254 ASSERT_EQ(3U, model->GetNumberOfItems()); |
| 257 | 255 |
| 258 const AvatarMenu::Item& item1 = model->GetItemAt(0); | 256 const AvatarMenu::Item& item1 = model->GetItemAt(0); |
| 259 EXPECT_EQ(0U, item1.menu_index); | 257 EXPECT_EQ(0U, item1.menu_index); |
| 260 EXPECT_EQ(ASCIIToUTF16("Test 1"), item1.name); | 258 EXPECT_EQ(ASCIIToUTF16("Test 1"), item1.name); |
| 261 | 259 |
| 262 const AvatarMenu::Item& item2 = model->GetItemAt(1); | 260 const AvatarMenu::Item& item2 = model->GetItemAt(1); |
| 263 EXPECT_EQ(1U, item2.menu_index); | 261 EXPECT_EQ(1U, item2.menu_index); |
| 264 EXPECT_EQ(ASCIIToUTF16("Test 2"), item2.name); | 262 EXPECT_EQ(ASCIIToUTF16("Test 2"), item2.name); |
| 265 | 263 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 base::string16 supervised_user_label = | 352 base::string16 supervised_user_label = |
| 355 l10n_util::GetStringUTF16(IDS_SUPERVISED_USER_AVATAR_LABEL); | 353 l10n_util::GetStringUTF16(IDS_SUPERVISED_USER_AVATAR_LABEL); |
| 356 const AvatarMenu::Item& item1 = model->GetItemAt(0); | 354 const AvatarMenu::Item& item1 = model->GetItemAt(0); |
| 357 EXPECT_NE(item1.sync_state, supervised_user_label); | 355 EXPECT_NE(item1.sync_state, supervised_user_label); |
| 358 | 356 |
| 359 const AvatarMenu::Item& item2 = model->GetItemAt(1); | 357 const AvatarMenu::Item& item2 = model->GetItemAt(1); |
| 360 EXPECT_EQ(item2.sync_state, supervised_user_label); | 358 EXPECT_EQ(item2.sync_state, supervised_user_label); |
| 361 } | 359 } |
| 362 | 360 |
| 363 } // namespace | 361 } // namespace |
| OLD | NEW |