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

Side by Side Diff: chrome/browser/chromeos/login/ui/user_adding_screen_browsertest.cc

Issue 1610823003: Migrate call sites LoginDisplayHostImpl::default_host to LoginDisplayHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix-add-supervised-user
Patch Set: Created 4 years, 11 months 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 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/session/session_state_delegate.h" 5 #include "ash/session/session_state_delegate.h"
6 #include "ash/shell.h" 6 #include "ash/shell.h"
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/chromeos/login/lock/screen_locker.h" 10 #include "chrome/browser/chromeos/login/lock/screen_locker.h"
11 #include "chrome/browser/chromeos/login/lock/screen_locker_tester.h" 11 #include "chrome/browser/chromeos/login/lock/screen_locker_tester.h"
12 #include "chrome/browser/chromeos/login/login_manager_test.h" 12 #include "chrome/browser/chromeos/login/login_manager_test.h"
13 #include "chrome/browser/chromeos/login/startup_utils.h" 13 #include "chrome/browser/chromeos/login/startup_utils.h"
14 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 14 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
15 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" 15 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
16 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" 16 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
17 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" 17 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
18 #include "chrome/browser/chromeos/profiles/profile_helper.h" 18 #include "chrome/browser/chromeos/profiles/profile_helper.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "chrome/test/base/in_process_browser_test.h" 20 #include "chrome/test/base/in_process_browser_test.h"
21 #include "components/user_manager/user_manager.h" 21 #include "components/user_manager/user_manager.h"
22 #include "content/public/browser/notification_service.h"
22 #include "content/public/test/test_utils.h" 23 #include "content/public/test/test_utils.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 25
25 using namespace testing; 26 using namespace testing;
26 27
27 namespace { 28 namespace {
28 29
29 const char* const kTestUsers[] = {"test-user1@gmail.com", 30 const char* const kTestUsers[] = {"test-user1@gmail.com",
30 "test-user2@gmail.com", 31 "test-user2@gmail.com",
31 "test-user3@gmail.com"}; 32 "test-user3@gmail.com"};
(...skipping 18 matching lines...) Expand all
50 void OnUserAddingFinished() override { ++user_adding_finished_; } 51 void OnUserAddingFinished() override { ++user_adding_finished_; }
51 52
52 void OnUserAddingStarted() override { ++user_adding_started_; } 53 void OnUserAddingStarted() override { ++user_adding_started_; }
53 54
54 void SetUserCanLock(user_manager::User* user, bool can_lock) { 55 void SetUserCanLock(user_manager::User* user, bool can_lock) {
55 user->set_can_lock(can_lock); 56 user->set_can_lock(can_lock);
56 } 57 }
57 58
58 void CheckScreenIsVisible() { 59 void CheckScreenIsVisible() {
59 views::View* web_view = 60 views::View* web_view =
60 LoginDisplayHostImpl::default_host()->GetWebUILoginView()->child_at(0); 61 LoginDisplayHost::default_host()->GetWebUILoginView()->child_at(0);
61 for (views::View* current_view = web_view; 62 for (views::View* current_view = web_view;
62 current_view; 63 current_view;
63 current_view = current_view->parent()) { 64 current_view = current_view->parent()) {
64 EXPECT_TRUE(current_view->visible()); 65 EXPECT_TRUE(current_view->visible());
65 if (current_view->layer()) 66 if (current_view->layer())
66 EXPECT_EQ(current_view->layer()->GetCombinedOpacity(), 1.f); 67 EXPECT_EQ(current_view->layer()->GetCombinedOpacity(), 1.f);
67 } 68 }
68 for (aura::Window* window = web_view->GetWidget()->GetNativeWindow(); 69 for (aura::Window* window = web_view->GetWidget()->GetNativeWindow();
69 window; 70 window;
70 window = window->parent()) { 71 window = window->parent()) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 ash::Shell::GetInstance()->session_state_delegate()-> 113 ash::Shell::GetInstance()->session_state_delegate()->
113 GetSessionState()); 114 GetSessionState());
114 115
115 UserAddingScreen::Get()->Cancel(); 116 UserAddingScreen::Get()->Cancel();
116 content::RunAllPendingInMessageLoop(); 117 content::RunAllPendingInMessageLoop();
117 EXPECT_EQ(1, user_adding_finished()); 118 EXPECT_EQ(1, user_adding_finished());
118 EXPECT_EQ(ash::SessionStateDelegate::SESSION_STATE_ACTIVE, 119 EXPECT_EQ(ash::SessionStateDelegate::SESSION_STATE_ACTIVE,
119 ash::Shell::GetInstance()->session_state_delegate()-> 120 ash::Shell::GetInstance()->session_state_delegate()->
120 GetSessionState()); 121 GetSessionState());
121 122
122 EXPECT_TRUE(LoginDisplayHostImpl::default_host() == NULL); 123 EXPECT_TRUE(LoginDisplayHost::default_host() == NULL);
achuithb 2016/01/21 23:14:31 nullptr since you're here
jdufault 2016/01/22 21:14:11 Done.
123 EXPECT_EQ(1u, user_manager::UserManager::Get()->GetLoggedInUsers().size()); 124 EXPECT_EQ(1u, user_manager::UserManager::Get()->GetLoggedInUsers().size());
124 EXPECT_EQ(kTestUsers[0], 125 EXPECT_EQ(kTestUsers[0],
125 user_manager::UserManager::Get()->GetActiveUser()->email()); 126 user_manager::UserManager::Get()->GetActiveUser()->email());
126 } 127 }
127 128
128 IN_PROC_BROWSER_TEST_F(UserAddingScreenTest, PRE_AddingSeveralUsers) { 129 IN_PROC_BROWSER_TEST_F(UserAddingScreenTest, PRE_AddingSeveralUsers) {
129 RegisterUser(kTestUsers[0]); 130 RegisterUser(kTestUsers[0]);
130 RegisterUser(kTestUsers[1]); 131 RegisterUser(kTestUsers[1]);
131 RegisterUser(kTestUsers[2]); 132 RegisterUser(kTestUsers[2]);
132 StartupUtils::MarkOobeCompleted(); 133 StartupUtils::MarkOobeCompleted();
(...skipping 15 matching lines...) Expand all
148 content::RunAllPendingInMessageLoop(); 149 content::RunAllPendingInMessageLoop();
149 EXPECT_EQ(i, user_adding_started()); 150 EXPECT_EQ(i, user_adding_started());
150 EXPECT_EQ(ash::SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY, 151 EXPECT_EQ(ash::SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY,
151 ash::Shell::GetInstance()->session_state_delegate()-> 152 ash::Shell::GetInstance()->session_state_delegate()->
152 GetSessionState()); 153 GetSessionState());
153 AddUser(kTestUsers[i]); 154 AddUser(kTestUsers[i]);
154 EXPECT_EQ(i, user_adding_finished()); 155 EXPECT_EQ(i, user_adding_finished());
155 EXPECT_EQ(ash::SessionStateDelegate::SESSION_STATE_ACTIVE, 156 EXPECT_EQ(ash::SessionStateDelegate::SESSION_STATE_ACTIVE,
156 ash::Shell::GetInstance()->session_state_delegate()-> 157 ash::Shell::GetInstance()->session_state_delegate()->
157 GetSessionState()); 158 GetSessionState());
158 EXPECT_TRUE(LoginDisplayHostImpl::default_host() == NULL); 159 EXPECT_TRUE(LoginDisplayHost::default_host() == NULL);
achuithb 2016/01/21 23:14:31 nullptr
jdufault 2016/01/22 21:14:11 Done.
159 ASSERT_EQ(unsigned(i + 1), user_manager->GetLoggedInUsers().size()); 160 ASSERT_EQ(unsigned(i + 1), user_manager->GetLoggedInUsers().size());
160 } 161 }
161 162
162 EXPECT_EQ(ash::SessionStateDelegate::SESSION_STATE_ACTIVE, 163 EXPECT_EQ(ash::SessionStateDelegate::SESSION_STATE_ACTIVE,
163 ash::Shell::GetInstance()->session_state_delegate()-> 164 ash::Shell::GetInstance()->session_state_delegate()->
164 GetSessionState()); 165 GetSessionState());
165 166
166 // Now check how unlock policy works for these users. 167 // Now check how unlock policy works for these users.
167 PrefService* prefs1 = 168 PrefService* prefs1 =
168 ProfileHelper::Get() 169 ProfileHelper::Get()
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 content::NotificationService::AllSources()).Wait(); 264 content::NotificationService::AllSources()).Wait();
264 265
265 UserAddingScreen::Get()->Start(); 266 UserAddingScreen::Get()->Start();
266 content::RunAllPendingInMessageLoop(); 267 content::RunAllPendingInMessageLoop();
267 CheckScreenIsVisible(); 268 CheckScreenIsVisible();
268 UserAddingScreen::Get()->Cancel(); 269 UserAddingScreen::Get()->Cancel();
269 content::RunAllPendingInMessageLoop(); 270 content::RunAllPendingInMessageLoop();
270 } 271 }
271 272
272 } // namespace chromeos 273 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698