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

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

Issue 271533004: Turning on MultiProfile by default for ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 users_pref->AppendIfNotPresent(new base::StringValue(username)); 59 users_pref->AppendIfNotPresent(new base::StringValue(username));
60 } 60 }
61 61
62 void LoginManagerTest::SetExpectedCredentials(const std::string& username, 62 void LoginManagerTest::SetExpectedCredentials(const std::string& username,
63 const std::string& password) { 63 const std::string& password) {
64 login_utils().GetFakeLoginUtils()->SetExpectedCredentials(username, password); 64 login_utils().GetFakeLoginUtils()->SetExpectedCredentials(username, password);
65 } 65 }
66 66
67 bool LoginManagerTest::TryToLogin(const std::string& username, 67 bool LoginManagerTest::TryToLogin(const std::string& username,
68 const std::string& password) { 68 const std::string& password) {
69 if (!AddUserTosession(username, password)) 69 if (!AddUserToSession(username, password))
70 return false; 70 return false;
71 if (const User* active_user = UserManager::Get()->GetActiveUser()) 71 if (const User* active_user = UserManager::Get()->GetActiveUser())
72 return active_user->email() == username; 72 return active_user->email() == username;
73 return false; 73 return false;
74 } 74 }
75 75
76 bool LoginManagerTest::AddUserTosession(const std::string& username, 76 bool LoginManagerTest::AddUserToSession(const std::string& username,
77 const std::string& password) { 77 const std::string& password) {
78 ExistingUserController* controller = 78 ExistingUserController* controller =
79 ExistingUserController::current_controller(); 79 ExistingUserController::current_controller();
80 if (!controller) { 80 if (!controller) {
81 ADD_FAILURE(); 81 ADD_FAILURE();
82 return false; 82 return false;
83 } 83 }
84 controller->Login(UserContext(username, password, std::string())); 84 controller->Login(UserContext(username, password, std::string()));
85 content::WindowedNotificationObserver( 85 content::WindowedNotificationObserver(
86 chrome::NOTIFICATION_SESSION_STARTED, 86 chrome::NOTIFICATION_SESSION_STARTED,
87 content::NotificationService::AllSources()).Wait(); 87 content::NotificationService::AllSources()).Wait();
88 const UserList& logged_users = UserManager::Get()->GetLoggedInUsers(); 88 const UserList& logged_users = UserManager::Get()->GetLoggedInUsers();
89 for (UserList::const_iterator it = logged_users.begin(); 89 for (UserList::const_iterator it = logged_users.begin();
90 it != logged_users.end(); ++it) { 90 it != logged_users.end(); ++it) {
91 if ((*it)->email() == username) 91 if ((*it)->email() == username)
92 return true; 92 return true;
93 } 93 }
94 return false; 94 return false;
95 } 95 }
96 96
97 void LoginManagerTest::LoginUser(const std::string& username) { 97 void LoginManagerTest::LoginUser(const std::string& username) {
98 SetExpectedCredentials(username, "password"); 98 SetExpectedCredentials(username, "password");
99 EXPECT_TRUE(TryToLogin(username, "password")); 99 EXPECT_TRUE(TryToLogin(username, "password"));
100 } 100 }
101 101
102 void LoginManagerTest::AddUser(const std::string& username) { 102 void LoginManagerTest::AddUser(const std::string& username) {
103 SetExpectedCredentials(username, "password"); 103 SetExpectedCredentials(username, "password");
104 EXPECT_TRUE(AddUserTosession(username, "password")); 104 EXPECT_TRUE(AddUserToSession(username, "password"));
105 } 105 }
106 106
107 void LoginManagerTest::JSExpect(const std::string& expression) { 107 void LoginManagerTest::JSExpect(const std::string& expression) {
108 js_checker_.ExpectTrue(expression); 108 js_checker_.ExpectTrue(expression);
109 } 109 }
110 110
111 void LoginManagerTest::InitializeWebContents() { 111 void LoginManagerTest::InitializeWebContents() {
112 LoginDisplayHost* host = LoginDisplayHostImpl::default_host(); 112 LoginDisplayHost* host = LoginDisplayHostImpl::default_host();
113 EXPECT_TRUE(host != NULL); 113 EXPECT_TRUE(host != NULL);
114 114
115 content::WebContents* web_contents = 115 content::WebContents* web_contents =
116 host->GetWebUILoginView()->GetWebContents(); 116 host->GetWebUILoginView()->GetWebContents();
117 EXPECT_TRUE(web_contents != NULL); 117 EXPECT_TRUE(web_contents != NULL);
118 set_web_contents(web_contents); 118 set_web_contents(web_contents);
119 js_checker_.set_web_contents(web_contents); 119 js_checker_.set_web_contents(web_contents);
120 } 120 }
121 121
122 } // namespace chromeos 122 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/login_manager_test.h ('k') | chrome/browser/chromeos/login/login_utils_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698