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

Side by Side Diff: chrome/browser/chromeos/login/login_manager_test.cc

Issue 745613002: [cros] Cleanup: remove LoginUtils (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get rid of FakeChromeUserManager usage in ExistingUserController* tests Created 5 years, 10 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 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 "chrome/browser/chromeos/login/login_manager_test.h" 5 #include "chrome/browser/chromeos/login/login_manager_test.h"
6 6
7 #include "base/prefs/scoped_user_pref_update.h" 7 #include "base/prefs/scoped_user_pref_update.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/chromeos/login/existing_user_controller.h" 10 #include "chrome/browser/chromeos/login/existing_user_controller.h"
11 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
12 #include "chrome/browser/chromeos/login/session/user_session_manager_test_api.h"
11 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 13 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
12 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" 14 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
13 #include "chromeos/chromeos_switches.h" 15 #include "chromeos/chromeos_switches.h"
14 #include "chromeos/login/auth/key.h" 16 #include "chromeos/login/auth/key.h"
15 #include "chromeos/login/auth/user_context.h" 17 #include "chromeos/login/auth/user_context.h"
16 #include "components/user_manager/user.h" 18 #include "components/user_manager/user.h"
17 #include "components/user_manager/user_manager.h" 19 #include "components/user_manager/user_manager.h"
18 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
19 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
20 #include "content/public/test/browser_test_utils.h" 22 #include "content/public/test/browser_test_utils.h"
(...skipping 16 matching lines...) Expand all
37 } 39 }
38 40
39 void LoginManagerTest::SetUpCommandLine(base::CommandLine* command_line) { 41 void LoginManagerTest::SetUpCommandLine(base::CommandLine* command_line) {
40 command_line->AppendSwitch(chromeos::switches::kLoginManager); 42 command_line->AppendSwitch(chromeos::switches::kLoginManager);
41 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); 43 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests);
42 MixinBasedBrowserTest::SetUpCommandLine(command_line); 44 MixinBasedBrowserTest::SetUpCommandLine(command_line);
43 } 45 }
44 46
45 void LoginManagerTest::SetUpInProcessBrowserTestFixture() { 47 void LoginManagerTest::SetUpInProcessBrowserTestFixture() {
46 MixinBasedBrowserTest::SetUpInProcessBrowserTestFixture(); 48 MixinBasedBrowserTest::SetUpInProcessBrowserTestFixture();
47 mock_login_utils_ = new testing::NiceMock<MockLoginUtils>();
48 mock_login_utils_->DelegateToFake();
49 mock_login_utils_->GetFakeLoginUtils()->set_should_launch_browser(
50 should_launch_browser_);
51 LoginUtils::Set(mock_login_utils_);
52 } 49 }
53 50
54 void LoginManagerTest::SetUpOnMainThread() { 51 void LoginManagerTest::SetUpOnMainThread() {
55 MixinBasedBrowserTest::SetUpOnMainThread(); 52 MixinBasedBrowserTest::SetUpOnMainThread();
56 content::WindowedNotificationObserver( 53 content::WindowedNotificationObserver(
57 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, 54 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
58 content::NotificationService::AllSources()).Wait(); 55 content::NotificationService::AllSources()).Wait();
59 InitializeWebContents(); 56 InitializeWebContents();
57 test::UserSessionManagerTestApi session_manager_test_api(
58 UserSessionManager::GetInstance());
59 session_manager_test_api.SetShouldLaunchBrowserInTests(
60 should_launch_browser_);
60 } 61 }
61 62
62 void LoginManagerTest::RegisterUser(const std::string& user_id) { 63 void LoginManagerTest::RegisterUser(const std::string& user_id) {
63 ListPrefUpdate users_pref(g_browser_process->local_state(), "LoggedInUsers"); 64 ListPrefUpdate users_pref(g_browser_process->local_state(), "LoggedInUsers");
64 users_pref->AppendIfNotPresent(new base::StringValue(user_id)); 65 users_pref->AppendIfNotPresent(new base::StringValue(user_id));
65 } 66 }
66 67
67 void LoginManagerTest::SetExpectedCredentials(const UserContext& user_context) { 68 void LoginManagerTest::SetExpectedCredentials(const UserContext& user_context) {
68 login_utils().GetFakeLoginUtils()->SetExpectedCredentials(user_context); 69 test::UserSessionManagerTestApi session_manager_test_api(
70 UserSessionManager::GetInstance());
71 session_manager_test_api.InjectStubUserContext(user_context);
69 } 72 }
70 73
71 bool LoginManagerTest::TryToLogin(const UserContext& user_context) { 74 bool LoginManagerTest::TryToLogin(const UserContext& user_context) {
72 if (!AddUserToSession(user_context)) 75 if (!AddUserToSession(user_context))
73 return false; 76 return false;
74 if (const user_manager::User* active_user = 77 if (const user_manager::User* active_user =
75 user_manager::UserManager::Get()->GetActiveUser()) 78 user_manager::UserManager::Get()->GetActiveUser())
76 return active_user->email() == user_context.GetUserID(); 79 return active_user->email() == user_context.GetUserID();
77 return false; 80 return false;
78 } 81 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 EXPECT_TRUE(host != NULL); 126 EXPECT_TRUE(host != NULL);
124 127
125 content::WebContents* web_contents = 128 content::WebContents* web_contents =
126 host->GetWebUILoginView()->GetWebContents(); 129 host->GetWebUILoginView()->GetWebContents();
127 EXPECT_TRUE(web_contents != NULL); 130 EXPECT_TRUE(web_contents != NULL);
128 set_web_contents(web_contents); 131 set_web_contents(web_contents);
129 js_checker_.set_web_contents(web_contents); 132 js_checker_.set_web_contents(web_contents);
130 } 133 }
131 134
132 } // namespace chromeos 135 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/login_manager_test.h ('k') | chrome/browser/chromeos/login/login_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698