| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/test/nacl/nacl_browsertest_util.h" | 5 #include "chrome/test/nacl/nacl_browsertest_util.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 bool NaClBrowserTestBase::GetDocumentRoot(base::FilePath* document_root) { | 203 bool NaClBrowserTestBase::GetDocumentRoot(base::FilePath* document_root) { |
| 204 return GetNaClVariantRoot(Variant(), document_root); | 204 return GetNaClVariantRoot(Variant(), document_root); |
| 205 } | 205 } |
| 206 | 206 |
| 207 bool NaClBrowserTestBase::IsAPnaclTest() { | 207 bool NaClBrowserTestBase::IsAPnaclTest() { |
| 208 return false; | 208 return false; |
| 209 } | 209 } |
| 210 | 210 |
| 211 GURL NaClBrowserTestBase::TestURL( | 211 GURL NaClBrowserTestBase::TestURL( |
| 212 const base::FilePath::StringType& url_fragment) { | 212 const base::FilePath::StringType& url_fragment) { |
| 213 base::FilePath expanded_url = base::FilePath(FILE_PATH_LITERAL("files")); | 213 base::FilePath expanded_url = base::FilePath(FILE_PATH_LITERAL("/")); |
| 214 expanded_url = expanded_url.Append(url_fragment); | 214 expanded_url = expanded_url.Append(url_fragment); |
| 215 return test_server_->GetURL(expanded_url.MaybeAsASCII()); | 215 return test_server_->GetURL(expanded_url.MaybeAsASCII()); |
| 216 } | 216 } |
| 217 | 217 |
| 218 bool NaClBrowserTestBase::RunJavascriptTest( | 218 bool NaClBrowserTestBase::RunJavascriptTest( |
| 219 const GURL& url, | 219 const GURL& url, |
| 220 content::TestMessageHandler* handler) { | 220 content::TestMessageHandler* handler) { |
| 221 content::JavascriptTestObserver observer( | 221 content::JavascriptTestObserver observer( |
| 222 browser()->tab_strip_model()->GetActiveWebContents(), | 222 browser()->tab_strip_model()->GetActiveWebContents(), |
| 223 handler); | 223 handler); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 252 &handler); | 252 &handler); |
| 253 ASSERT_TRUE(ok) << handler.error_message(); | 253 ASSERT_TRUE(ok) << handler.error_message(); |
| 254 ASSERT_TRUE(handler.test_passed()) << "Test failed."; | 254 ASSERT_TRUE(handler.test_passed()) << "Test failed."; |
| 255 } | 255 } |
| 256 | 256 |
| 257 bool NaClBrowserTestBase::StartTestServer() { | 257 bool NaClBrowserTestBase::StartTestServer() { |
| 258 // Launch the web server. | 258 // Launch the web server. |
| 259 base::FilePath document_root; | 259 base::FilePath document_root; |
| 260 if (!GetDocumentRoot(&document_root)) | 260 if (!GetDocumentRoot(&document_root)) |
| 261 return false; | 261 return false; |
| 262 test_server_.reset(new net::SpawnedTestServer( | 262 test_server_.reset(new net::EmbeddedTestServer); |
| 263 net::SpawnedTestServer::TYPE_HTTP, | 263 test_server_->ServeFilesFromSourceDirectory(document_root); |
| 264 net::SpawnedTestServer::kLocalhost, | |
| 265 document_root)); | |
| 266 return test_server_->Start(); | 264 return test_server_->Start(); |
| 267 } | 265 } |
| 268 | 266 |
| 269 base::FilePath::StringType NaClBrowserTestNewlib::Variant() { | 267 base::FilePath::StringType NaClBrowserTestNewlib::Variant() { |
| 270 return FILE_PATH_LITERAL("newlib"); | 268 return FILE_PATH_LITERAL("newlib"); |
| 271 } | 269 } |
| 272 | 270 |
| 273 base::FilePath::StringType NaClBrowserTestGLibc::Variant() { | 271 base::FilePath::StringType NaClBrowserTestGLibc::Variant() { |
| 274 return FILE_PATH_LITERAL("glibc"); | 272 return FILE_PATH_LITERAL("glibc"); |
| 275 } | 273 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 // to point at the isolated the test extension directory. | 343 // to point at the isolated the test extension directory. |
| 346 // Otherwise, multiple NaCl extensions tests will end up sharing the | 344 // Otherwise, multiple NaCl extensions tests will end up sharing the |
| 347 // same directory when loading the extension files. | 345 // same directory when loading the extension files. |
| 348 base::FilePath document_root; | 346 base::FilePath document_root; |
| 349 ASSERT_TRUE(GetDocumentRoot(&document_root)); | 347 ASSERT_TRUE(GetDocumentRoot(&document_root)); |
| 350 | 348 |
| 351 // Document root is relative to source root, and source root may not be CWD. | 349 // Document root is relative to source root, and source root may not be CWD. |
| 352 command_line->AppendSwitchPath(switches::kLoadExtension, | 350 command_line->AppendSwitchPath(switches::kLoadExtension, |
| 353 src_root.Append(document_root)); | 351 src_root.Append(document_root)); |
| 354 } | 352 } |
| OLD | NEW |