| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 content_browser_client_.reset(new TestContentBrowserClient()); | 145 content_browser_client_.reset(new TestContentBrowserClient()); |
| 146 original_content_browser_client_ = content::SetBrowserClientForTesting( | 146 original_content_browser_client_ = content::SetBrowserClientForTesting( |
| 147 content_browser_client_.get()); | 147 content_browser_client_.get()); |
| 148 base::FilePath test_data_dir; | 148 base::FilePath test_data_dir; |
| 149 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); | 149 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); |
| 150 CHECK(file_util::ReadFileToString(test_data_dir.Append(kServiceLogin), | 150 CHECK(file_util::ReadFileToString(test_data_dir.Append(kServiceLogin), |
| 151 &service_login_response_)); | 151 &service_login_response_)); |
| 152 } | 152 } |
| 153 | 153 |
| 154 virtual void SetUpOnMainThread() OVERRIDE { | 154 virtual void SetUpOnMainThread() OVERRIDE { |
| 155 test_server_ = new HttpServer(); // Constructor wants UI thread. | 155 test_server_ = new HttpServer( |
| 156 content::BrowserThread::GetMessageLoopProxyForThread( |
| 157 content::BrowserThread::IO)); |
| 156 CHECK(test_server_->InitializeAndWaitUntilReady()); | 158 CHECK(test_server_->InitializeAndWaitUntilReady()); |
| 157 test_server_->RegisterRequestHandler( | 159 test_server_->RegisterRequestHandler( |
| 158 base::Bind(&OobeTest::HandleRequest, base::Unretained(this))); | 160 base::Bind(&OobeTest::HandleRequest, base::Unretained(this))); |
| 159 LOG(INFO) << "Set up http server at " << test_server_->base_url(); | 161 LOG(INFO) << "Set up http server at " << test_server_->base_url(); |
| 160 CHECK(test_server_->port() >= 8040 && test_server_->port() < 8045) | 162 CHECK(test_server_->port() >= 8040 && test_server_->port() < 8045) |
| 161 << "Current manifest_test.json for gaia_login restrictions " | 163 << "Current manifest_test.json for gaia_login restrictions " |
| 162 << "does not allow this port"; | 164 << "does not allow this port"; |
| 163 | 165 |
| 164 const std::string gaia_url = | 166 const std::string gaia_url = |
| 165 "http://localhost:" + test_server_->base_url().port(); | 167 "http://localhost:" + test_server_->base_url().port(); |
| 166 content_browser_client_->browser_main_extra_parts_->set_gaia_url(gaia_url); | 168 content_browser_client_->browser_main_extra_parts_->set_gaia_url(gaia_url); |
| 167 } | 169 } |
| 168 | 170 |
| 169 virtual void CleanUpOnMainThread() OVERRIDE { | 171 virtual void CleanUpOnMainThread() OVERRIDE { |
| 170 LOG(INFO) << "Stopping the http server."; | 172 LOG(INFO) << "Stopping the http server."; |
| 171 test_server_->ShutdownAndWaitUntilComplete(); | 173 EXPECT_TRUE(test_server_->ShutdownAndWaitUntilComplete()); |
| 172 delete test_server_; // Destructor wants UI thread. | 174 delete test_server_; // Destructor wants UI thread. |
| 173 } | 175 } |
| 174 | 176 |
| 175 scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { | 177 scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { |
| 176 GURL url = test_server_->GetURL(request.relative_url); | 178 GURL url = test_server_->GetURL(request.relative_url); |
| 177 LOG(INFO) << "Http request: " << url.spec(); | 179 LOG(INFO) << "Http request: " << url.spec(); |
| 178 | 180 |
| 179 scoped_ptr<HttpResponse> http_response(new HttpResponse()); | 181 scoped_ptr<HttpResponse> http_response(new HttpResponse()); |
| 180 if (url.path() == "/ServiceLogin") { | 182 if (url.path() == "/ServiceLogin") { |
| 181 http_response->set_code(test_server::SUCCESS); | 183 http_response->set_code(test_server::SUCCESS); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 wizard_controller->SkipToLoginForTesting(); | 218 wizard_controller->SkipToLoginForTesting(); |
| 217 | 219 |
| 218 scoped_refptr<content::MessageLoopRunner> runner = | 220 scoped_refptr<content::MessageLoopRunner> runner = |
| 219 new content::MessageLoopRunner; | 221 new content::MessageLoopRunner; |
| 220 content_browser_client_->browser_main_extra_parts_->set_quit_task( | 222 content_browser_client_->browser_main_extra_parts_->set_quit_task( |
| 221 runner->QuitClosure()); | 223 runner->QuitClosure()); |
| 222 runner->Run(); | 224 runner->Run(); |
| 223 } | 225 } |
| 224 | 226 |
| 225 } | 227 } |
| OLD | NEW |