| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ash/test/ash_test_base.h" | 5 #include "ash/test/ash_test_base.h" |
| 6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
| 7 #include "chrome/browser/chromeos/login/screens/user_selection_screen.h" | 7 #include "chrome/browser/chromeos/login/screens/user_selection_screen.h" |
| 8 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 8 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 9 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 9 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
| 10 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller_dele
gate.h" | 10 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller_dele
gate.h" |
| 11 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 11 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 12 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 12 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 13 #include "chrome/test/base/testing_browser_process.h" | 13 #include "chrome/test/base/testing_browser_process.h" |
| 14 #include "chrome/test/base/testing_profile_manager.h" | 14 #include "chrome/test/base/testing_profile_manager.h" |
| 15 #include "components/proximity_auth/screenlock_bridge.h" | 15 #include "components/proximity_auth/screenlock_bridge.h" |
| 16 #include "components/signin/core/account_id/account_id.h" |
| 16 #include "components/user_manager/user.h" | 17 #include "components/user_manager/user.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 const size_t kMaxUsers = 18; // same as in user_selection_screen.cc | 22 const size_t kMaxUsers = 18; // same as in user_selection_screen.cc |
| 22 const char* kOwner = "owner@gmail.com"; | 23 const char* kOwner = "owner@gmail.com"; |
| 23 const char* kUsersPublic[] = {"public0@gmail.com", "public1@gmail.com"}; | 24 const char* kUsersPublic[] = {"public0@gmail.com", "public1@gmail.com"}; |
| 24 const char* kUsers[] = { | 25 const char* kUsers[] = { |
| 25 "a0@gmail.com", "a1@gmail.com", "a2@gmail.com", "a3@gmail.com", | 26 "a0@gmail.com", "a1@gmail.com", "a2@gmail.com", "a3@gmail.com", |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 user_auth_type_map; | 80 user_auth_type_map; |
| 80 scoped_ptr<MultiProfileUserController> controller_; | 81 scoped_ptr<MultiProfileUserController> controller_; |
| 81 | 82 |
| 82 DISALLOW_COPY_AND_ASSIGN(SigninPrepareUserListTest); | 83 DISALLOW_COPY_AND_ASSIGN(SigninPrepareUserListTest); |
| 83 }; | 84 }; |
| 84 | 85 |
| 85 TEST_F(SigninPrepareUserListTest, AlwaysKeepOwnerInList) { | 86 TEST_F(SigninPrepareUserListTest, AlwaysKeepOwnerInList) { |
| 86 EXPECT_LT(kMaxUsers, fake_user_manager_->GetUsers().size()); | 87 EXPECT_LT(kMaxUsers, fake_user_manager_->GetUsers().size()); |
| 87 user_manager::UserList users_to_send = | 88 user_manager::UserList users_to_send = |
| 88 UserSelectionScreen::PrepareUserListForSending( | 89 UserSelectionScreen::PrepareUserListForSending( |
| 89 fake_user_manager_->GetUsers(), kOwner, true /* is signin to add */); | 90 fake_user_manager_->GetUsers(), AccountId::FromUserEmail(kOwner), |
| 91 true /* is signin to add */); |
| 90 | 92 |
| 91 EXPECT_EQ(kMaxUsers, users_to_send.size()); | 93 EXPECT_EQ(kMaxUsers, users_to_send.size()); |
| 92 EXPECT_EQ(kOwner, users_to_send.back()->email()); | 94 EXPECT_EQ(kOwner, users_to_send.back()->email()); |
| 93 | 95 |
| 94 fake_user_manager_->RemoveUserFromList( | 96 fake_user_manager_->RemoveUserFromList( |
| 95 AccountId::FromUserEmail("a16@gmail.com")); | 97 AccountId::FromUserEmail("a16@gmail.com")); |
| 96 fake_user_manager_->RemoveUserFromList( | 98 fake_user_manager_->RemoveUserFromList( |
| 97 AccountId::FromUserEmail("a17@gmail.com")); | 99 AccountId::FromUserEmail("a17@gmail.com")); |
| 98 users_to_send = UserSelectionScreen::PrepareUserListForSending( | 100 users_to_send = UserSelectionScreen::PrepareUserListForSending( |
| 99 fake_user_manager_->GetUsers(), | 101 fake_user_manager_->GetUsers(), AccountId::FromUserEmail(kOwner), |
| 100 kOwner, | |
| 101 true /* is signin to add */); | 102 true /* is signin to add */); |
| 102 | 103 |
| 103 EXPECT_EQ(kMaxUsers, users_to_send.size()); | 104 EXPECT_EQ(kMaxUsers, users_to_send.size()); |
| 104 EXPECT_EQ("a18@gmail.com", users_to_send.back()->email()); | 105 EXPECT_EQ("a18@gmail.com", users_to_send.back()->email()); |
| 105 EXPECT_EQ(kOwner, users_to_send[kMaxUsers-2]->email()); | 106 EXPECT_EQ(kOwner, users_to_send[kMaxUsers-2]->email()); |
| 106 } | 107 } |
| 107 | 108 |
| 108 TEST_F(SigninPrepareUserListTest, PublicAccounts) { | 109 TEST_F(SigninPrepareUserListTest, PublicAccounts) { |
| 109 user_manager::UserList users_to_send = | 110 user_manager::UserList users_to_send = |
| 110 UserSelectionScreen::PrepareUserListForSending( | 111 UserSelectionScreen::PrepareUserListForSending( |
| 111 fake_user_manager_->GetUsers(), kOwner, true /* is signin to add */); | 112 fake_user_manager_->GetUsers(), AccountId::FromUserEmail(kOwner), |
| 113 true /* is signin to add */); |
| 112 | 114 |
| 113 EXPECT_EQ(kMaxUsers, users_to_send.size()); | 115 EXPECT_EQ(kMaxUsers, users_to_send.size()); |
| 114 EXPECT_EQ("a0@gmail.com", users_to_send.front()->email()); | 116 EXPECT_EQ("a0@gmail.com", users_to_send.front()->email()); |
| 115 | 117 |
| 116 users_to_send = UserSelectionScreen::PrepareUserListForSending( | 118 users_to_send = UserSelectionScreen::PrepareUserListForSending( |
| 117 fake_user_manager_->GetUsers(), | 119 fake_user_manager_->GetUsers(), AccountId::FromUserEmail(kOwner), |
| 118 kOwner, | |
| 119 false /* is signin to add */); | 120 false /* is signin to add */); |
| 120 | 121 |
| 121 EXPECT_EQ(kMaxUsers, users_to_send.size()); | 122 EXPECT_EQ(kMaxUsers, users_to_send.size()); |
| 122 EXPECT_EQ("public0@gmail.com", users_to_send.front()->email()); | 123 EXPECT_EQ("public0@gmail.com", users_to_send.front()->email()); |
| 123 } | 124 } |
| 124 | 125 |
| 125 } // namespace chromeos | 126 } // namespace chromeos |
| OLD | NEW |