OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "chrome/browser/chrome_browser_main.h" | 7 #include "chrome/browser/chrome_browser_main.h" |
8 #include "chrome/browser/chrome_browser_main_extra_parts.h" | 8 #include "chrome/browser/chrome_browser_main_extra_parts.h" |
9 #include "chrome/browser/chrome_content_browser_client.h" | 9 #include "chrome/browser/chrome_content_browser_client.h" |
10 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" | 10 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 virtual void CleanUpOnMainThread() OVERRIDE { | 168 virtual void CleanUpOnMainThread() OVERRIDE { |
169 LOG(INFO) << "Stopping the http server."; | 169 LOG(INFO) << "Stopping the http server."; |
170 EXPECT_TRUE(test_server_->ShutdownAndWaitUntilComplete()); | 170 EXPECT_TRUE(test_server_->ShutdownAndWaitUntilComplete()); |
171 delete test_server_; // Destructor wants UI thread. | 171 delete test_server_; // Destructor wants UI thread. |
172 } | 172 } |
173 | 173 |
174 scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { | 174 scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { |
175 GURL url = test_server_->GetURL(request.relative_url); | 175 GURL url = test_server_->GetURL(request.relative_url); |
176 LOG(INFO) << "Http request: " << url.spec(); | 176 LOG(INFO) << "Http request: " << url.spec(); |
177 | 177 |
178 scoped_ptr<HttpResponse> http_response(new HttpResponse()); | 178 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); |
179 if (url.path() == "/ServiceLogin") { | 179 if (url.path() == "/ServiceLogin") { |
180 http_response->set_code(net::test_server::SUCCESS); | 180 http_response->set_code(net::test_server::SUCCESS); |
181 http_response->set_content(service_login_response_); | 181 http_response->set_content(service_login_response_); |
182 http_response->set_content_type("text/html"); | 182 http_response->set_content_type("text/html"); |
183 } else if (url.path() == "/ServiceLoginAuth") { | 183 } else if (url.path() == "/ServiceLoginAuth") { |
184 LOG(INFO) << "Params: " << request.content; | 184 LOG(INFO) << "Params: " << request.content; |
185 static const char kContinueParam[] = "continue="; | 185 static const char kContinueParam[] = "continue="; |
186 int continue_arg_begin = request.content.find(kContinueParam) + | 186 int continue_arg_begin = request.content.find(kContinueParam) + |
187 arraysize(kContinueParam) - 1; | 187 arraysize(kContinueParam) - 1; |
188 int continue_arg_end = request.content.find("&", continue_arg_begin); | 188 int continue_arg_end = request.content.find("&", continue_arg_begin); |
189 const std::string continue_url = request.content.substr( | 189 const std::string continue_url = request.content.substr( |
190 continue_arg_begin, continue_arg_end - continue_arg_begin); | 190 continue_arg_begin, continue_arg_end - continue_arg_begin); |
191 http_response->set_code(net::test_server::SUCCESS); | 191 http_response->set_code(net::test_server::SUCCESS); |
192 const std::string redirect_js = | 192 const std::string redirect_js = |
193 "document.location.href = unescape('" + continue_url + "');"; | 193 "document.location.href = unescape('" + continue_url + "');"; |
194 http_response->set_content( | 194 http_response->set_content( |
195 "<HTML><HEAD><SCRIPT>\n" + redirect_js + "\n</SCRIPT></HEAD></HTML>"); | 195 "<HTML><HEAD><SCRIPT>\n" + redirect_js + "\n</SCRIPT></HEAD></HTML>"); |
196 http_response->set_content_type("text/html"); | 196 http_response->set_content_type("text/html"); |
197 } else { | 197 } else { |
198 NOTREACHED() << url.path(); | 198 NOTREACHED() << url.path(); |
199 } | 199 } |
200 return http_response.Pass(); | 200 return http_response.PassAs<HttpResponse>(); |
201 } | 201 } |
202 | 202 |
203 scoped_ptr<TestContentBrowserClient> content_browser_client_; | 203 scoped_ptr<TestContentBrowserClient> content_browser_client_; |
204 content::ContentBrowserClient* original_content_browser_client_; | 204 content::ContentBrowserClient* original_content_browser_client_; |
205 std::string service_login_response_; | 205 std::string service_login_response_; |
206 EmbeddedTestServer* test_server_; // cant use scoped_ptr because destructor | 206 EmbeddedTestServer* test_server_; // cant use scoped_ptr because destructor |
207 // needs UI thread. | 207 // needs UI thread. |
208 }; | 208 }; |
209 | 209 |
210 // Test is flaky - http://crbug.com/242587 | 210 // Test is flaky - http://crbug.com/242587 |
211 IN_PROC_BROWSER_TEST_F(OobeTest, DISABLED_NewUser) { | 211 IN_PROC_BROWSER_TEST_F(OobeTest, DISABLED_NewUser) { |
212 chromeos::WizardController::SkipPostLoginScreensForTesting(); | 212 chromeos::WizardController::SkipPostLoginScreensForTesting(); |
213 chromeos::WizardController* wizard_controller = | 213 chromeos::WizardController* wizard_controller = |
214 chromeos::WizardController::default_controller(); | 214 chromeos::WizardController::default_controller(); |
215 CHECK(wizard_controller); | 215 CHECK(wizard_controller); |
216 wizard_controller->SkipToLoginForTesting(); | 216 wizard_controller->SkipToLoginForTesting(); |
217 | 217 |
218 scoped_refptr<content::MessageLoopRunner> runner = | 218 scoped_refptr<content::MessageLoopRunner> runner = |
219 new content::MessageLoopRunner; | 219 new content::MessageLoopRunner; |
220 content_browser_client_->browser_main_extra_parts_->set_quit_task( | 220 content_browser_client_->browser_main_extra_parts_->set_quit_task( |
221 runner->QuitClosure()); | 221 runner->QuitClosure()); |
222 runner->Run(); | 222 runner->Run(); |
223 } | 223 } |
224 | 224 |
225 } | 225 } |
OLD | NEW |