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

Side by Side Diff: chrome/test/nacl/nacl_browsertest_util.cc

Issue 263683002: Set file tokens for NaCl main nexe if available to enable validation caching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clear tokens too Created 6 years, 7 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 (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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // pexes are artifacts of the build. To keep things tidy, all test data is kept 162 // pexes are artifacts of the build. To keep things tidy, all test data is kept
163 // in a subdirectory. Several variants of a test may be run, for example when 163 // in a subdirectory. Several variants of a test may be run, for example when
164 // linked against newlib and when linked against glibc. These variants are kept 164 // linked against newlib and when linked against glibc. These variants are kept
165 // in different subdirectories. For example, the build directory will look 165 // in different subdirectories. For example, the build directory will look
166 // something like this on Linux: 166 // something like this on Linux:
167 // out/ 167 // out/
168 // Release/ 168 // Release/
169 // nacl_test_data/ 169 // nacl_test_data/
170 // newlib/ 170 // newlib/
171 // glibc/ 171 // glibc/
172 // pnacl/
172 static bool GetNaClVariantRoot(const base::FilePath::StringType& variant, 173 static bool GetNaClVariantRoot(const base::FilePath::StringType& variant,
173 base::FilePath* document_root) { 174 base::FilePath* document_root) {
174 if (!ui_test_utils::GetRelativeBuildDirectory(document_root)) 175 if (!ui_test_utils::GetRelativeBuildDirectory(document_root))
175 return false; 176 return false;
176 *document_root = document_root->Append(FILE_PATH_LITERAL("nacl_test_data")); 177 *document_root = document_root->Append(FILE_PATH_LITERAL("nacl_test_data"));
177 *document_root = document_root->Append(variant); 178 *document_root = document_root->Append(variant);
178 return true; 179 return true;
179 } 180 }
180 181
181 static void AddPnaclParm(const base::FilePath::StringType& url, 182 static void AddPnaclParm(const base::FilePath::StringType& url,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 base::FilePath::StringType test_file_with_both = test_file_with_pnacl; 255 base::FilePath::StringType test_file_with_both = test_file_with_pnacl;
255 if (IsPnaclDisabled()) { 256 if (IsPnaclDisabled()) {
256 AddPnaclDisabledParm(test_file_with_pnacl, &test_file_with_both); 257 AddPnaclDisabledParm(test_file_with_pnacl, &test_file_with_both);
257 } 258 }
258 bool ok = RunJavascriptTest(TestURL(test_file_with_both), &handler); 259 bool ok = RunJavascriptTest(TestURL(test_file_with_both), &handler);
259 ASSERT_TRUE(ok) << handler.error_message(); 260 ASSERT_TRUE(ok) << handler.error_message();
260 ASSERT_TRUE(handler.test_passed()) << "Test failed."; 261 ASSERT_TRUE(handler.test_passed()) << "Test failed.";
261 } 262 }
262 263
263 void NaClBrowserTestBase::RunNaClIntegrationTest( 264 void NaClBrowserTestBase::RunNaClIntegrationTest(
264 const base::FilePath::StringType& url_fragment) { 265 const base::FilePath::StringType& url_fragment, bool full_url) {
265 NaClIntegrationMessageHandler handler; 266 NaClIntegrationMessageHandler handler;
266 base::FilePath::StringType url_fragment_with_pnacl = url_fragment; 267 base::FilePath::StringType url_fragment_with_pnacl = url_fragment;
267 if (IsAPnaclTest()) { 268 if (IsAPnaclTest()) {
268 AddPnaclParm(url_fragment, &url_fragment_with_pnacl); 269 AddPnaclParm(url_fragment, &url_fragment_with_pnacl);
269 } 270 }
270 base::FilePath::StringType url_fragment_with_both = url_fragment_with_pnacl; 271 base::FilePath::StringType url_fragment_with_both = url_fragment_with_pnacl;
271 if (IsPnaclDisabled()) { 272 if (IsPnaclDisabled()) {
272 AddPnaclDisabledParm(url_fragment_with_pnacl, &url_fragment_with_both); 273 AddPnaclDisabledParm(url_fragment_with_pnacl, &url_fragment_with_both);
273 } 274 }
274 bool ok = RunJavascriptTest(TestURL(url_fragment_with_both), &handler); 275 bool ok = RunJavascriptTest(full_url
276 ? GURL(url_fragment_with_both)
277 : TestURL(url_fragment_with_both),
278 &handler);
275 ASSERT_TRUE(ok) << handler.error_message(); 279 ASSERT_TRUE(ok) << handler.error_message();
276 ASSERT_TRUE(handler.test_passed()) << "Test failed."; 280 ASSERT_TRUE(handler.test_passed()) << "Test failed.";
277 } 281 }
278 282
279 bool NaClBrowserTestBase::StartTestServer() { 283 bool NaClBrowserTestBase::StartTestServer() {
280 // Launch the web server. 284 // Launch the web server.
281 base::FilePath document_root; 285 base::FilePath document_root;
282 if (!GetDocumentRoot(&document_root)) 286 if (!GetDocumentRoot(&document_root))
283 return false; 287 return false;
284 test_server_.reset(new net::SpawnedTestServer( 288 test_server_.reset(new net::SpawnedTestServer(
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 346
343 base::FilePath::StringType NaClBrowserTestPnaclNonSfi::Variant() { 347 base::FilePath::StringType NaClBrowserTestPnaclNonSfi::Variant() {
344 return FILE_PATH_LITERAL("nonsfi"); 348 return FILE_PATH_LITERAL("nonsfi");
345 } 349 }
346 350
347 void NaClBrowserTestPnaclNonSfi::SetUpCommandLine( 351 void NaClBrowserTestPnaclNonSfi::SetUpCommandLine(
348 base::CommandLine* command_line) { 352 base::CommandLine* command_line) {
349 NaClBrowserTestBase::SetUpCommandLine(command_line); 353 NaClBrowserTestBase::SetUpCommandLine(command_line);
350 command_line->AppendSwitch(switches::kEnableNaClNonSfiMode); 354 command_line->AppendSwitch(switches::kEnableNaClNonSfiMode);
351 } 355 }
356
357 void NaClBrowserTestNewlibExtension::SetUpCommandLine(
358 CommandLine* command_line) {
359 NaClBrowserTestBase::SetUpCommandLine(command_line);
360 base::FilePath src_root;
361 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &src_root));
362
363 // Extension-based tests should specialize the GetDocumentRoot() / Variant()
364 // to point at the isolated the test extension directory.
365 // Otherwise, multiple NaCl extensions tests will end up sharing the
366 // same directory when loading the extension files.
367 base::FilePath document_root;
368 ASSERT_TRUE(GetDocumentRoot(&document_root));
369
370 // Document root is relative to source root, and source root may not be CWD.
371 command_line->AppendSwitchPath(switches::kLoadExtension,
372 src_root.Append(document_root));
373 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698