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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } | 217 } |
218 | 218 |
219 bool NaClBrowserTestBase::GetDocumentRoot(base::FilePath* document_root) { | 219 bool NaClBrowserTestBase::GetDocumentRoot(base::FilePath* document_root) { |
220 return GetNaClVariantRoot(Variant(), document_root); | 220 return GetNaClVariantRoot(Variant(), document_root); |
221 } | 221 } |
222 | 222 |
223 bool NaClBrowserTestBase::IsAPnaclTest() { | 223 bool NaClBrowserTestBase::IsAPnaclTest() { |
224 return false; | 224 return false; |
225 } | 225 } |
226 | 226 |
227 bool NaClBrowserTestBase::IsPnaclDisabled() { | |
228 return false; | |
229 } | |
230 | |
231 GURL NaClBrowserTestBase::TestURL( | 227 GURL NaClBrowserTestBase::TestURL( |
232 const base::FilePath::StringType& url_fragment) { | 228 const base::FilePath::StringType& url_fragment) { |
233 base::FilePath expanded_url = base::FilePath(FILE_PATH_LITERAL("files")); | 229 base::FilePath expanded_url = base::FilePath(FILE_PATH_LITERAL("files")); |
234 expanded_url = expanded_url.Append(url_fragment); | 230 expanded_url = expanded_url.Append(url_fragment); |
235 return test_server_->GetURL(expanded_url.MaybeAsASCII()); | 231 return test_server_->GetURL(expanded_url.MaybeAsASCII()); |
236 } | 232 } |
237 | 233 |
238 bool NaClBrowserTestBase::RunJavascriptTest( | 234 bool NaClBrowserTestBase::RunJavascriptTest( |
239 const GURL& url, | 235 const GURL& url, |
240 content::TestMessageHandler* handler) { | 236 content::TestMessageHandler* handler) { |
241 content::JavascriptTestObserver observer( | 237 content::JavascriptTestObserver observer( |
242 browser()->tab_strip_model()->GetActiveWebContents(), | 238 browser()->tab_strip_model()->GetActiveWebContents(), |
243 handler); | 239 handler); |
244 ui_test_utils::NavigateToURL(browser(), url); | 240 ui_test_utils::NavigateToURL(browser(), url); |
245 return observer.Run(); | 241 return observer.Run(); |
246 } | 242 } |
247 | 243 |
248 void NaClBrowserTestBase::RunLoadTest( | 244 void NaClBrowserTestBase::RunLoadTest( |
249 const base::FilePath::StringType& test_file) { | 245 const base::FilePath::StringType& test_file) { |
250 LoadTestMessageHandler handler; | 246 LoadTestMessageHandler handler; |
251 base::FilePath::StringType test_file_with_pnacl = test_file; | 247 base::FilePath::StringType test_file_with_pnacl = test_file; |
252 if (IsAPnaclTest()) { | 248 if (IsAPnaclTest()) { |
253 AddPnaclParm(test_file, &test_file_with_pnacl); | 249 AddPnaclParm(test_file, &test_file_with_pnacl); |
254 } | 250 } |
255 base::FilePath::StringType test_file_with_both = test_file_with_pnacl; | 251 base::FilePath::StringType test_file_with_both = test_file_with_pnacl; |
256 if (IsPnaclDisabled()) { | |
257 AddPnaclDisabledParm(test_file_with_pnacl, &test_file_with_both); | |
258 } | |
259 bool ok = RunJavascriptTest(TestURL(test_file_with_both), &handler); | 252 bool ok = RunJavascriptTest(TestURL(test_file_with_both), &handler); |
260 ASSERT_TRUE(ok) << handler.error_message(); | 253 ASSERT_TRUE(ok) << handler.error_message(); |
261 ASSERT_TRUE(handler.test_passed()) << "Test failed."; | 254 ASSERT_TRUE(handler.test_passed()) << "Test failed."; |
262 } | 255 } |
263 | 256 |
264 void NaClBrowserTestBase::RunNaClIntegrationTest( | 257 void NaClBrowserTestBase::RunNaClIntegrationTest( |
265 const base::FilePath::StringType& url_fragment, bool full_url) { | 258 const base::FilePath::StringType& url_fragment, bool full_url) { |
266 NaClIntegrationMessageHandler handler; | 259 NaClIntegrationMessageHandler handler; |
267 base::FilePath::StringType url_fragment_with_pnacl = url_fragment; | 260 base::FilePath::StringType url_fragment_with_pnacl = url_fragment; |
268 if (IsAPnaclTest()) { | 261 if (IsAPnaclTest()) { |
269 AddPnaclParm(url_fragment, &url_fragment_with_pnacl); | 262 AddPnaclParm(url_fragment, &url_fragment_with_pnacl); |
270 } | 263 } |
271 base::FilePath::StringType url_fragment_with_both = url_fragment_with_pnacl; | 264 base::FilePath::StringType url_fragment_with_both = url_fragment_with_pnacl; |
272 if (IsPnaclDisabled()) { | |
273 AddPnaclDisabledParm(url_fragment_with_pnacl, &url_fragment_with_both); | |
274 } | |
275 bool ok = RunJavascriptTest(full_url | 265 bool ok = RunJavascriptTest(full_url |
276 ? GURL(url_fragment_with_both) | 266 ? GURL(url_fragment_with_both) |
277 : TestURL(url_fragment_with_both), | 267 : TestURL(url_fragment_with_both), |
278 &handler); | 268 &handler); |
279 ASSERT_TRUE(ok) << handler.error_message(); | 269 ASSERT_TRUE(ok) << handler.error_message(); |
280 ASSERT_TRUE(handler.test_passed()) << "Test failed."; | 270 ASSERT_TRUE(handler.test_passed()) << "Test failed."; |
281 } | 271 } |
282 | 272 |
283 bool NaClBrowserTestBase::StartTestServer() { | 273 bool NaClBrowserTestBase::StartTestServer() { |
284 // Launch the web server. | 274 // Launch the web server. |
(...skipping 20 matching lines...) Expand all Loading... |
305 } | 295 } |
306 | 296 |
307 bool NaClBrowserTestPnacl::IsAPnaclTest() { | 297 bool NaClBrowserTestPnacl::IsAPnaclTest() { |
308 return true; | 298 return true; |
309 } | 299 } |
310 | 300 |
311 base::FilePath::StringType NaClBrowserTestPnaclDisabled::Variant() { | 301 base::FilePath::StringType NaClBrowserTestPnaclDisabled::Variant() { |
312 return FILE_PATH_LITERAL("pnacl"); | 302 return FILE_PATH_LITERAL("pnacl"); |
313 } | 303 } |
314 | 304 |
315 bool NaClBrowserTestPnaclDisabled::IsAPnaclTest() { | |
316 return true; | |
317 } | |
318 | |
319 bool NaClBrowserTestPnaclDisabled::IsPnaclDisabled() { | |
320 return true; | |
321 } | |
322 void NaClBrowserTestPnaclDisabled::SetUpCommandLine( | |
323 base::CommandLine* command_line) { | |
324 NaClBrowserTestBase::SetUpCommandLine(command_line); | |
325 command_line->AppendSwitch(switches::kDisablePnacl); | |
326 } | |
327 | |
328 base::FilePath::StringType NaClBrowserTestNonSfiMode::Variant() { | 305 base::FilePath::StringType NaClBrowserTestNonSfiMode::Variant() { |
329 return FILE_PATH_LITERAL("libc-free"); | 306 return FILE_PATH_LITERAL("libc-free"); |
330 } | 307 } |
331 | 308 |
332 void NaClBrowserTestNonSfiMode::SetUpCommandLine( | 309 void NaClBrowserTestNonSfiMode::SetUpCommandLine( |
333 base::CommandLine* command_line) { | 310 base::CommandLine* command_line) { |
334 NaClBrowserTestBase::SetUpCommandLine(command_line); | 311 NaClBrowserTestBase::SetUpCommandLine(command_line); |
335 command_line->AppendSwitch(switches::kEnableNaClNonSfiMode); | 312 command_line->AppendSwitch(switches::kEnableNaClNonSfiMode); |
336 } | 313 } |
337 | 314 |
(...skipping 26 matching lines...) Expand all Loading... |
364 // to point at the isolated the test extension directory. | 341 // to point at the isolated the test extension directory. |
365 // Otherwise, multiple NaCl extensions tests will end up sharing the | 342 // Otherwise, multiple NaCl extensions tests will end up sharing the |
366 // same directory when loading the extension files. | 343 // same directory when loading the extension files. |
367 base::FilePath document_root; | 344 base::FilePath document_root; |
368 ASSERT_TRUE(GetDocumentRoot(&document_root)); | 345 ASSERT_TRUE(GetDocumentRoot(&document_root)); |
369 | 346 |
370 // Document root is relative to source root, and source root may not be CWD. | 347 // Document root is relative to source root, and source root may not be CWD. |
371 command_line->AppendSwitchPath(switches::kLoadExtension, | 348 command_line->AppendSwitchPath(switches::kLoadExtension, |
372 src_root.Append(document_root)); | 349 src_root.Append(document_root)); |
373 } | 350 } |
OLD | NEW |