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

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

Issue 19079002: Enable pnacl by default (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: IOS flag name Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/nacl/nacl_browsertest_util.h ('k') | chrome/test/ppapi/ppapi_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/environment.h" 9 #include "base/environment.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 static void AddPnaclParm(const base::FilePath::StringType& url, 181 static void AddPnaclParm(const base::FilePath::StringType& url,
182 base::FilePath::StringType* url_with_parm) { 182 base::FilePath::StringType* url_with_parm) {
183 if (url.find(FILE_PATH_LITERAL("?")) == base::FilePath::StringType::npos) { 183 if (url.find(FILE_PATH_LITERAL("?")) == base::FilePath::StringType::npos) {
184 *url_with_parm = url + FILE_PATH_LITERAL("?pnacl=1"); 184 *url_with_parm = url + FILE_PATH_LITERAL("?pnacl=1");
185 } else { 185 } else {
186 *url_with_parm = url + FILE_PATH_LITERAL("&pnacl=1"); 186 *url_with_parm = url + FILE_PATH_LITERAL("&pnacl=1");
187 } 187 }
188 } 188 }
189 189
190 static void AddPnaclDisabledParm(const base::FilePath::StringType& url,
191 base::FilePath::StringType* url_with_parm) {
192 if (url.find(FILE_PATH_LITERAL("?")) == base::FilePath::StringType::npos) {
193 *url_with_parm = url + FILE_PATH_LITERAL("?pnacl_disabled=1");
194 } else {
195 *url_with_parm = url + FILE_PATH_LITERAL("&pnacl_disabled=1");
196 }
197 }
198
190 NaClBrowserTestBase::NaClBrowserTestBase() { 199 NaClBrowserTestBase::NaClBrowserTestBase() {
191 } 200 }
192 201
193 NaClBrowserTestBase::~NaClBrowserTestBase() { 202 NaClBrowserTestBase::~NaClBrowserTestBase() {
194 } 203 }
195 204
196 void NaClBrowserTestBase::SetUpCommandLine(CommandLine* command_line) { 205 void NaClBrowserTestBase::SetUpCommandLine(CommandLine* command_line) {
197 command_line->AppendSwitch(switches::kNoFirstRun); 206 command_line->AppendSwitch(switches::kNoFirstRun);
198 command_line->AppendSwitch(switches::kEnableNaCl); 207 command_line->AppendSwitch(switches::kEnableNaCl);
199 } 208 }
200 209
201 void NaClBrowserTestBase::SetUpInProcessBrowserTestFixture() { 210 void NaClBrowserTestBase::SetUpInProcessBrowserTestFixture() {
202 // Sanity check. 211 // Sanity check.
203 base::FilePath plugin_lib; 212 base::FilePath plugin_lib;
204 ASSERT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib)); 213 ASSERT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib));
205 ASSERT_TRUE(base::PathExists(plugin_lib)) << plugin_lib.value(); 214 ASSERT_TRUE(base::PathExists(plugin_lib)) << plugin_lib.value();
206 215
207 ASSERT_TRUE(StartTestServer()) << "Cannot start test server."; 216 ASSERT_TRUE(StartTestServer()) << "Cannot start test server.";
208 } 217 }
209 218
210 bool NaClBrowserTestBase::GetDocumentRoot(base::FilePath* document_root) { 219 bool NaClBrowserTestBase::GetDocumentRoot(base::FilePath* document_root) {
211 return GetNaClVariantRoot(Variant(), document_root); 220 return GetNaClVariantRoot(Variant(), document_root);
212 } 221 }
213 222
214 bool NaClBrowserTestBase::IsPnacl() { 223 bool NaClBrowserTestBase::IsAPnaclTest() {
215 return false; 224 return false;
216 } 225 }
217 226
227 bool NaClBrowserTestBase::IsPnaclDisabled() {
228 return false;
229 }
230
218 GURL NaClBrowserTestBase::TestURL( 231 GURL NaClBrowserTestBase::TestURL(
219 const base::FilePath::StringType& url_fragment) { 232 const base::FilePath::StringType& url_fragment) {
220 base::FilePath expanded_url = base::FilePath(FILE_PATH_LITERAL("files")); 233 base::FilePath expanded_url = base::FilePath(FILE_PATH_LITERAL("files"));
221 expanded_url = expanded_url.Append(url_fragment); 234 expanded_url = expanded_url.Append(url_fragment);
222 return test_server_->GetURL(expanded_url.MaybeAsASCII()); 235 return test_server_->GetURL(expanded_url.MaybeAsASCII());
223 } 236 }
224 237
225 bool NaClBrowserTestBase::RunJavascriptTest(const GURL& url, 238 bool NaClBrowserTestBase::RunJavascriptTest(const GURL& url,
226 TestMessageHandler* handler) { 239 TestMessageHandler* handler) {
227 JavascriptTestObserver observer( 240 JavascriptTestObserver observer(
228 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(), 241 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(),
229 handler); 242 handler);
230 ui_test_utils::NavigateToURL(browser(), url); 243 ui_test_utils::NavigateToURL(browser(), url);
231 return observer.Run(); 244 return observer.Run();
232 } 245 }
233 246
234 void NaClBrowserTestBase::RunLoadTest( 247 void NaClBrowserTestBase::RunLoadTest(
235 const base::FilePath::StringType& test_file) { 248 const base::FilePath::StringType& test_file) {
236 LoadTestMessageHandler handler; 249 LoadTestMessageHandler handler;
237 base::FilePath::StringType test_file_with_parm = test_file; 250 base::FilePath::StringType test_file_with_pnacl = test_file;
238 if (IsPnacl()) { 251 if (IsAPnaclTest()) {
239 AddPnaclParm(test_file, &test_file_with_parm); 252 AddPnaclParm(test_file, &test_file_with_pnacl);
240 } 253 }
241 bool ok = RunJavascriptTest(TestURL(test_file_with_parm), &handler); 254 base::FilePath::StringType test_file_with_both = test_file_with_pnacl;
255 if (IsPnaclDisabled()) {
256 AddPnaclDisabledParm(test_file_with_pnacl, &test_file_with_both);
257 }
258 bool ok = RunJavascriptTest(TestURL(test_file_with_both), &handler);
242 ASSERT_TRUE(ok) << handler.error_message(); 259 ASSERT_TRUE(ok) << handler.error_message();
243 ASSERT_TRUE(handler.test_passed()) << "Test failed."; 260 ASSERT_TRUE(handler.test_passed()) << "Test failed.";
244 } 261 }
245 262
246 void NaClBrowserTestBase::RunNaClIntegrationTest( 263 void NaClBrowserTestBase::RunNaClIntegrationTest(
247 const base::FilePath::StringType& url_fragment) { 264 const base::FilePath::StringType& url_fragment) {
248 NaClIntegrationMessageHandler handler; 265 NaClIntegrationMessageHandler handler;
249 base::FilePath::StringType url_fragment_with_parm = url_fragment; 266 base::FilePath::StringType url_fragment_with_pnacl = url_fragment;
250 if (IsPnacl()) { 267 if (IsAPnaclTest()) {
251 AddPnaclParm(url_fragment, &url_fragment_with_parm); 268 AddPnaclParm(url_fragment, &url_fragment_with_pnacl);
252 } 269 }
253 bool ok = RunJavascriptTest(TestURL(url_fragment_with_parm), &handler); 270 base::FilePath::StringType url_fragment_with_both = url_fragment_with_pnacl;
271 if (IsPnaclDisabled()) {
272 AddPnaclDisabledParm(url_fragment_with_pnacl, &url_fragment_with_both);
273 }
274 bool ok = RunJavascriptTest(TestURL(url_fragment_with_both), &handler);
254 ASSERT_TRUE(ok) << handler.error_message(); 275 ASSERT_TRUE(ok) << handler.error_message();
255 ASSERT_TRUE(handler.test_passed()) << "Test failed."; 276 ASSERT_TRUE(handler.test_passed()) << "Test failed.";
256 } 277 }
257 278
258 bool NaClBrowserTestBase::StartTestServer() { 279 bool NaClBrowserTestBase::StartTestServer() {
259 // Launch the web server. 280 // Launch the web server.
260 base::FilePath document_root; 281 base::FilePath document_root;
261 if (!GetDocumentRoot(&document_root)) 282 if (!GetDocumentRoot(&document_root))
262 return false; 283 return false;
263 test_server_.reset(new net::SpawnedTestServer( 284 test_server_.reset(new net::SpawnedTestServer(
264 net::SpawnedTestServer::TYPE_HTTP, 285 net::SpawnedTestServer::TYPE_HTTP,
265 net::SpawnedTestServer::kLocalhost, 286 net::SpawnedTestServer::kLocalhost,
266 document_root)); 287 document_root));
267 return test_server_->Start(); 288 return test_server_->Start();
268 } 289 }
269 290
270 base::FilePath::StringType NaClBrowserTestNewlib::Variant() { 291 base::FilePath::StringType NaClBrowserTestNewlib::Variant() {
271 return FILE_PATH_LITERAL("newlib"); 292 return FILE_PATH_LITERAL("newlib");
272 } 293 }
273 294
274 base::FilePath::StringType NaClBrowserTestGLibc::Variant() { 295 base::FilePath::StringType NaClBrowserTestGLibc::Variant() {
275 return FILE_PATH_LITERAL("glibc"); 296 return FILE_PATH_LITERAL("glibc");
276 } 297 }
277 298
278 base::FilePath::StringType NaClBrowserTestPnacl::Variant() { 299 base::FilePath::StringType NaClBrowserTestPnacl::Variant() {
279 return FILE_PATH_LITERAL("pnacl"); 300 return FILE_PATH_LITERAL("pnacl");
280 } 301 }
281 302
282 bool NaClBrowserTestPnacl::IsPnacl() { 303 bool NaClBrowserTestPnacl::IsAPnaclTest() {
283 return true; 304 return true;
284 } 305 }
285 306
286 void NaClBrowserTestPnacl::SetUpCommandLine(CommandLine* command_line) { 307 base::FilePath::StringType NaClBrowserTestPnaclDisabled::Variant() {
308 return FILE_PATH_LITERAL("pnacl");
309 }
310
311 bool NaClBrowserTestPnaclDisabled::IsAPnaclTest() {
312 return true;
313 }
314
315 bool NaClBrowserTestPnaclDisabled::IsPnaclDisabled() {
316 return true;
317 }
318
319 void NaClBrowserTestPnaclDisabled::SetUpCommandLine(CommandLine* command_line) {
287 NaClBrowserTestBase::SetUpCommandLine(command_line); 320 NaClBrowserTestBase::SetUpCommandLine(command_line);
288 command_line->AppendSwitch(switches::kEnablePnacl); 321 command_line->AppendSwitch(switches::kDisablePnacl);
289 } 322 }
290 323
291 NaClBrowserTestPnaclWithNewCache::NaClBrowserTestPnaclWithNewCache() { 324 NaClBrowserTestPnaclWithNewCache::NaClBrowserTestPnaclWithNewCache() {
292 scoped_ptr<base::Environment> env(base::Environment::Create()); 325 scoped_ptr<base::Environment> env(base::Environment::Create());
293 env->SetVar("PNACL_USE_NEW_CACHE", "true"); 326 env->SetVar("PNACL_USE_NEW_CACHE", "true");
294 } 327 }
295 328
296 base::FilePath::StringType NaClBrowserTestStatic::Variant() { 329 base::FilePath::StringType NaClBrowserTestStatic::Variant() {
297 return FILE_PATH_LITERAL("static"); 330 return FILE_PATH_LITERAL("static");
298 } 331 }
299 332
300 bool NaClBrowserTestStatic::GetDocumentRoot(base::FilePath* document_root) { 333 bool NaClBrowserTestStatic::GetDocumentRoot(base::FilePath* document_root) {
301 *document_root = base::FilePath(FILE_PATH_LITERAL("chrome/test/data/nacl")); 334 *document_root = base::FilePath(FILE_PATH_LITERAL("chrome/test/data/nacl"));
302 return true; 335 return true;
303 } 336 }
OLDNEW
« no previous file with comments | « chrome/test/nacl/nacl_browsertest_util.h ('k') | chrome/test/ppapi/ppapi_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698