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

Side by Side Diff: chrome/browser/ui/webui/signin/login_ui_test_utils.cc

Issue 1536553002: Remove InlineLoginHandlerChromeOS and exclude InlineLoginUI from CrOS build. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge conflicts resolved. 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 "chrome/browser/signin/signin_promo.h" 5 #include "chrome/browser/signin/signin_promo.h"
6 #include "chrome/browser/signin/signin_tracker_factory.h" 6 #include "chrome/browser/signin/signin_tracker_factory.h"
7 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/tabs/tab_strip_model.h" 8 #include "chrome/browser/ui/tabs/tab_strip_model.h"
9 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" 9 #include "chrome/browser/ui/webui/signin/get_auth_frame.h"
10 #include "chrome/test/base/ui_test_utils.h" 10 #include "chrome/test/base/ui_test_utils.h"
11 #include "content/public/browser/notification_service.h" 11 #include "content/public/browser/notification_service.h"
12 #include "content/public/browser/notification_types.h" 12 #include "content/public/browser/notification_types.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "content/public/test/browser_test_utils.h" 14 #include "content/public/test/browser_test_utils.h"
15 15
16 using content::MessageLoopRunner; 16 using content::MessageLoopRunner;
17 17
18 // anonymous namespace for signin with UI helper functions. 18 // anonymous namespace for signin with UI helper functions.
19 namespace { 19 namespace {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 " } else {" 132 " } else {"
133 " window.domAutomationController.send('failed');" 133 " window.domAutomationController.send('failed');"
134 " }" 134 " }"
135 " }" 135 " }"
136 " CheckelementExists();" 136 " CheckelementExists();"
137 "}" 137 "}"
138 "WaitForElementById('" + element_id + "');"; 138 "WaitForElementById('" + element_id + "');";
139 content::WebContents* web_contents = 139 content::WebContents* web_contents =
140 browser->tab_strip_model()->GetActiveWebContents(); 140 browser->tab_strip_model()->GetActiveWebContents();
141 ASSERT_TRUE(content::ExecuteScriptAndExtractString( 141 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
142 InlineLoginUI::GetAuthFrame(web_contents, GURL(), "signin-frame"), 142 signin::GetAuthFrame(web_contents, "signin-frame"), js, &message));
143 js, &message));
144 143
145 ASSERT_EQ("found", message) << 144 ASSERT_EQ("found", message) <<
146 "Failed to find element with id " << element_id; 145 "Failed to find element with id " << element_id;
147 } 146 }
148 147
149 bool ElementExistsInSigninFrame(Browser* browser, 148 bool ElementExistsInSigninFrame(Browser* browser,
150 const std::string& element_id) { 149 const std::string& element_id) {
151 content::WebContents* web_contents = 150 content::WebContents* web_contents =
152 browser->tab_strip_model()->GetActiveWebContents(); 151 browser->tab_strip_model()->GetActiveWebContents();
153 bool result = false; 152 bool result = false;
154 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 153 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
155 InlineLoginUI::GetAuthFrame(web_contents, GURL(), "signin-frame"), 154 signin::GetAuthFrame(web_contents, "signin-frame"),
156 "window.domAutomationController.send(" 155 "window.domAutomationController.send("
157 " document.getElementById('" + element_id + "') != null);", 156 " document.getElementById('" +
157 element_id + "') != null);",
158 &result)); 158 &result));
159 return result; 159 return result;
160 } 160 }
161 161
162 void SigninInNewGaiaFlow(Browser* browser, 162 void SigninInNewGaiaFlow(Browser* browser,
163 const std::string& email, 163 const std::string& email,
164 const std::string& password) { 164 const std::string& password) {
165 std::string js = "document.getElementById('Email').value = '" + email + "';" 165 std::string js = "document.getElementById('Email').value = '" + email + "';"
166 "document.getElementById('next').click();"; 166 "document.getElementById('next').click();";
167 167
168 content::WebContents* web_contents = 168 content::WebContents* web_contents =
169 browser->tab_strip_model()->GetActiveWebContents(); 169 browser->tab_strip_model()->GetActiveWebContents();
170 ASSERT_TRUE(content::ExecuteScript(InlineLoginUI::GetAuthFrame( 170 ASSERT_TRUE(content::ExecuteScript(
171 web_contents, GURL(), "signin-frame"), js)); 171 signin::GetAuthFrame(web_contents, "signin-frame"), js));
172 172
173 WaitUntilElementExistsInSigninFrame(browser, "Passwd"); 173 WaitUntilElementExistsInSigninFrame(browser, "Passwd");
174 js = "document.getElementById('Passwd').value = '" + password + "';" 174 js = "document.getElementById('Passwd').value = '" + password + "';"
175 "document.getElementById('signIn').click();"; 175 "document.getElementById('signIn').click();";
176 176
177 ASSERT_TRUE(content::ExecuteScript(InlineLoginUI::GetAuthFrame( 177 ASSERT_TRUE(content::ExecuteScript(
178 web_contents, GURL(), "signin-frame"), js)); 178 signin::GetAuthFrame(web_contents, "signin-frame"), js));
179 } 179 }
180 180
181 void SigninInOldGaiaFlow(Browser* browser, 181 void SigninInOldGaiaFlow(Browser* browser,
182 const std::string& email, 182 const std::string& email,
183 const std::string& password) { 183 const std::string& password) {
184 std::string js = 184 std::string js =
185 "document.getElementById('Email').value = '" + email + "';" 185 "document.getElementById('Email').value = '" + email + "';"
186 "document.getElementById('Passwd').value = '" + password + "';" 186 "document.getElementById('Passwd').value = '" + password + "';"
187 "document.getElementById('signIn').click();"; 187 "document.getElementById('signIn').click();";
188 188
189 content::WebContents* web_contents = 189 content::WebContents* web_contents =
190 browser->tab_strip_model()->GetActiveWebContents(); 190 browser->tab_strip_model()->GetActiveWebContents();
191 ASSERT_TRUE(content::ExecuteScript(InlineLoginUI::GetAuthFrame( 191 ASSERT_TRUE(content::ExecuteScript(
192 web_contents, GURL(), "signin-frame"), js)); 192 signin::GetAuthFrame(web_contents, "signin-frame"), js));
193 } 193 }
194 194
195 void ExecuteJsToSigninInSigninFrame(Browser* browser, 195 void ExecuteJsToSigninInSigninFrame(Browser* browser,
196 const std::string& email, 196 const std::string& email,
197 const std::string& password) { 197 const std::string& password) {
198 WaitUntilElementExistsInSigninFrame(browser, "Email"); 198 WaitUntilElementExistsInSigninFrame(browser, "Email");
199 if (ElementExistsInSigninFrame(browser, "next")) 199 if (ElementExistsInSigninFrame(browser, "next"))
200 SigninInNewGaiaFlow(browser, email, password); 200 SigninInNewGaiaFlow(browser, email, password);
201 else 201 else
202 SigninInOldGaiaFlow(browser, email, password); 202 SigninInOldGaiaFlow(browser, email, password);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 bool SignInWithUI(Browser* browser, 236 bool SignInWithUI(Browser* browser,
237 const std::string& username, 237 const std::string& username,
238 const std::string& password) { 238 const std::string& password) {
239 return SignInWithUI(browser, username, password, 239 return SignInWithUI(browser, username, password,
240 false /* wait_for_account_cookies */, 240 false /* wait_for_account_cookies */,
241 signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE, 241 signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE,
242 signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT); 242 signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT);
243 } 243 }
244 244
245 } // namespace login_ui_test_utils 245 } // namespace login_ui_test_utils
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc ('k') | chrome/browser/ui/webui/test_files_request_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698