| 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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
| 6 #include "chrome/browser/chromeos/login/screens/user_selection_screen.h" | 6 #include "chrome/browser/chromeos/login/screens/user_selection_screen.h" |
| 7 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" | 7 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" |
| 8 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 8 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
| 9 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller_dele
gate.h" | 9 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller_dele
gate.h" |
| 10 #include "chrome/browser/chromeos/login/users/user.h" | |
| 11 #include "chrome/browser/signin/screenlock_bridge.h" | 10 #include "chrome/browser/signin/screenlock_bridge.h" |
| 12 #include "chrome/test/base/testing_browser_process.h" | 11 #include "chrome/test/base/testing_browser_process.h" |
| 13 #include "chrome/test/base/testing_profile_manager.h" | 12 #include "chrome/test/base/testing_profile_manager.h" |
| 13 #include "components/user_manager/user.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 const size_t kMaxUsers = 18; // same as in user_selection_screen.cc | 18 const size_t kMaxUsers = 18; // same as in user_selection_screen.cc |
| 19 const char* kOwner = "owner@gmail.com"; | 19 const char* kOwner = "owner@gmail.com"; |
| 20 const char* kUsersPublic[] = {"public0@gmail.com", "public1@gmail.com"}; | 20 const char* kUsersPublic[] = {"public0@gmail.com", "public1@gmail.com"}; |
| 21 const char* kUsers[] = { | 21 const char* kUsers[] = { |
| 22 "a0@gmail.com", "a1@gmail.com", "a2@gmail.com", "a3@gmail.com", | 22 "a0@gmail.com", "a1@gmail.com", "a2@gmail.com", "a3@gmail.com", |
| 23 "a4@gmail.com", "a5@gmail.com", "a6@gmail.com", "a7@gmail.com", | 23 "a4@gmail.com", "a5@gmail.com", "a6@gmail.com", "a7@gmail.com", |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 scoped_ptr<TestingProfileManager> profile_manager_; | 72 scoped_ptr<TestingProfileManager> profile_manager_; |
| 73 std::map<std::string, | 73 std::map<std::string, |
| 74 ScreenlockBridge::LockHandler::AuthType> user_auth_type_map; | 74 ScreenlockBridge::LockHandler::AuthType> user_auth_type_map; |
| 75 scoped_ptr<MultiProfileUserController> controller_; | 75 scoped_ptr<MultiProfileUserController> controller_; |
| 76 | 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(SigninPrepareUserListTest); | 77 DISALLOW_COPY_AND_ASSIGN(SigninPrepareUserListTest); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 TEST_F(SigninPrepareUserListTest, AlwaysKeepOwnerInList) { | 80 TEST_F(SigninPrepareUserListTest, AlwaysKeepOwnerInList) { |
| 81 EXPECT_LT(kMaxUsers, fake_user_manager_->GetUsers().size()); | 81 EXPECT_LT(kMaxUsers, fake_user_manager_->GetUsers().size()); |
| 82 UserList users_to_send = UserSelectionScreen::PrepareUserListForSending( | 82 user_manager::UserList users_to_send = |
| 83 fake_user_manager_->GetUsers(), | 83 UserSelectionScreen::PrepareUserListForSending( |
| 84 kOwner, | 84 fake_user_manager_->GetUsers(), kOwner, true /* is signin to add */); |
| 85 true /* is signin to add */); | |
| 86 | 85 |
| 87 EXPECT_EQ(kMaxUsers, users_to_send.size()); | 86 EXPECT_EQ(kMaxUsers, users_to_send.size()); |
| 88 EXPECT_EQ(kOwner, users_to_send.back()->email()); | 87 EXPECT_EQ(kOwner, users_to_send.back()->email()); |
| 89 | 88 |
| 90 fake_user_manager_->RemoveUserFromList("a16@gmail.com"); | 89 fake_user_manager_->RemoveUserFromList("a16@gmail.com"); |
| 91 fake_user_manager_->RemoveUserFromList("a17@gmail.com"); | 90 fake_user_manager_->RemoveUserFromList("a17@gmail.com"); |
| 92 users_to_send = UserSelectionScreen::PrepareUserListForSending( | 91 users_to_send = UserSelectionScreen::PrepareUserListForSending( |
| 93 fake_user_manager_->GetUsers(), | 92 fake_user_manager_->GetUsers(), |
| 94 kOwner, | 93 kOwner, |
| 95 true /* is signin to add */); | 94 true /* is signin to add */); |
| 96 | 95 |
| 97 EXPECT_EQ(kMaxUsers, users_to_send.size()); | 96 EXPECT_EQ(kMaxUsers, users_to_send.size()); |
| 98 EXPECT_EQ("a18@gmail.com", users_to_send.back()->email()); | 97 EXPECT_EQ("a18@gmail.com", users_to_send.back()->email()); |
| 99 EXPECT_EQ(kOwner, users_to_send[kMaxUsers-2]->email()); | 98 EXPECT_EQ(kOwner, users_to_send[kMaxUsers-2]->email()); |
| 100 } | 99 } |
| 101 | 100 |
| 102 TEST_F(SigninPrepareUserListTest, PublicAccounts) { | 101 TEST_F(SigninPrepareUserListTest, PublicAccounts) { |
| 103 UserList users_to_send = UserSelectionScreen::PrepareUserListForSending( | 102 user_manager::UserList users_to_send = |
| 104 fake_user_manager_->GetUsers(), | 103 UserSelectionScreen::PrepareUserListForSending( |
| 105 kOwner, | 104 fake_user_manager_->GetUsers(), kOwner, true /* is signin to add */); |
| 106 true /* is signin to add */); | |
| 107 | 105 |
| 108 EXPECT_EQ(kMaxUsers, users_to_send.size()); | 106 EXPECT_EQ(kMaxUsers, users_to_send.size()); |
| 109 EXPECT_EQ("a0@gmail.com", users_to_send.front()->email()); | 107 EXPECT_EQ("a0@gmail.com", users_to_send.front()->email()); |
| 110 | 108 |
| 111 users_to_send = UserSelectionScreen::PrepareUserListForSending( | 109 users_to_send = UserSelectionScreen::PrepareUserListForSending( |
| 112 fake_user_manager_->GetUsers(), | 110 fake_user_manager_->GetUsers(), |
| 113 kOwner, | 111 kOwner, |
| 114 false /* is signin to add */); | 112 false /* is signin to add */); |
| 115 | 113 |
| 116 EXPECT_EQ(kMaxUsers, users_to_send.size()); | 114 EXPECT_EQ(kMaxUsers, users_to_send.size()); |
| 117 EXPECT_EQ("public0@gmail.com", users_to_send.front()->email()); | 115 EXPECT_EQ("public0@gmail.com", users_to_send.front()->email()); |
| 118 } | 116 } |
| 119 | 117 |
| 120 } // namespace chromeos | 118 } // namespace chromeos |
| OLD | NEW |