OLD | NEW |
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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/prefs/scoped_user_pref_update.h" | 8 #include "base/prefs/scoped_user_pref_update.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 it != logged_users.end(); | 99 it != logged_users.end(); |
100 ++it) { | 100 ++it) { |
101 if ((*it)->email() == user_context.GetUserID()) | 101 if ((*it)->email() == user_context.GetUserID()) |
102 return true; | 102 return true; |
103 } | 103 } |
104 return false; | 104 return false; |
105 } | 105 } |
106 | 106 |
107 void LoginManagerTest::LoginUser(const std::string& user_id) { | 107 void LoginManagerTest::LoginUser(const std::string& user_id) { |
108 UserContext user_context(user_id); | 108 UserContext user_context(user_id); |
| 109 user_context.SetGaiaID(GetGaiaIDForUserID(user_id)); |
109 user_context.SetKey(Key("password")); | 110 user_context.SetKey(Key("password")); |
110 SetExpectedCredentials(user_context); | 111 SetExpectedCredentials(user_context); |
111 EXPECT_TRUE(TryToLogin(user_context)); | 112 EXPECT_TRUE(TryToLogin(user_context)); |
112 } | 113 } |
113 | 114 |
114 void LoginManagerTest::AddUser(const std::string& user_id) { | 115 void LoginManagerTest::AddUser(const std::string& user_id) { |
115 UserContext user_context(user_id); | 116 UserContext user_context(user_id); |
| 117 user_context.SetGaiaID(GetGaiaIDForUserID(user_id)); |
116 user_context.SetKey(Key("password")); | 118 user_context.SetKey(Key("password")); |
117 SetExpectedCredentials(user_context); | 119 SetExpectedCredentials(user_context); |
118 EXPECT_TRUE(AddUserToSession(user_context)); | 120 EXPECT_TRUE(AddUserToSession(user_context)); |
119 } | 121 } |
120 | 122 |
| 123 // static |
| 124 std::string LoginManagerTest::GetGaiaIDForUserID(const std::string& user_id) { |
| 125 return "gaia-id-" + user_id; |
| 126 } |
| 127 |
121 void LoginManagerTest::JSExpect(const std::string& expression) { | 128 void LoginManagerTest::JSExpect(const std::string& expression) { |
122 js_checker_.ExpectTrue(expression); | 129 js_checker_.ExpectTrue(expression); |
123 } | 130 } |
124 | 131 |
125 void LoginManagerTest::InitializeWebContents() { | 132 void LoginManagerTest::InitializeWebContents() { |
126 LoginDisplayHost* host = LoginDisplayHostImpl::default_host(); | 133 LoginDisplayHost* host = LoginDisplayHostImpl::default_host(); |
127 EXPECT_TRUE(host != NULL); | 134 EXPECT_TRUE(host != NULL); |
128 | 135 |
129 content::WebContents* web_contents = | 136 content::WebContents* web_contents = |
130 host->GetWebUILoginView()->GetWebContents(); | 137 host->GetWebUILoginView()->GetWebContents(); |
131 EXPECT_TRUE(web_contents != NULL); | 138 EXPECT_TRUE(web_contents != NULL); |
132 set_web_contents(web_contents); | 139 set_web_contents(web_contents); |
133 js_checker_.set_web_contents(web_contents); | 140 js_checker_.set_web_contents(web_contents); |
134 } | 141 } |
135 | 142 |
136 } // namespace chromeos | 143 } // namespace chromeos |
OLD | NEW |