Chromium Code Reviews| 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/test/test_timeouts.h" | 7 #include "base/test/test_timeouts.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "content/public/common/content_switches.h" | 9 #include "content/public/common/content_switches.h" |
| 10 #include "content/common/pepper_plugin_registry.h" | 10 #include "content/common/pepper_plugin_registry.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 GURL test_url = net::FilePathToFileURL(test_path); | 63 GURL test_url = net::FilePathToFileURL(test_path); |
| 64 | 64 |
| 65 GURL::Replacements replacements; | 65 GURL::Replacements replacements; |
| 66 std::string query = BuildQuery("", test_case); | 66 std::string query = BuildQuery("", test_case); |
| 67 replacements.SetQuery(query.c_str(), url_parse::Component(0, query.size())); | 67 replacements.SetQuery(query.c_str(), url_parse::Component(0, query.size())); |
| 68 return test_url.ReplaceComponents(replacements); | 68 return test_url.ReplaceComponents(replacements); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void RunTest(const std::string& test_case) { | 71 void RunTest(const std::string& test_case) { |
| 72 scoped_refptr<TabProxy> tab = GetActiveTab(); | 72 scoped_refptr<TabProxy> tab = GetActiveTab(); |
| 73 EXPECT_TRUE(tab.get()); | 73 ASSERT_TRUE(tab.get()); |
| 74 if (!tab.get()) | |
| 75 return; | |
| 76 GURL url = GetTestFileUrl(test_case); | 74 GURL url = GetTestFileUrl(test_case); |
| 77 EXPECT_TRUE(tab->NavigateToURLBlockUntilNavigationsComplete(url, 1)); | 75 EXPECT_TRUE(tab->NavigateToURLBlockUntilNavigationsComplete(url, 1)); |
| 78 RunTestURL(tab, url); | 76 RunTestURL(tab, url); |
| 79 } | 77 } |
| 80 | 78 |
| 79 void RunTestAndReload(const std::string& test_case) { | |
| 80 scoped_refptr<TabProxy> tab = GetActiveTab(); | |
| 81 ASSERT_TRUE(tab.get()); | |
| 82 GURL url = GetTestFileUrl(test_case); | |
| 83 // Run the test the first time. | |
| 84 EXPECT_TRUE(tab->NavigateToURLBlockUntilNavigationsComplete(url, 1)); | |
| 85 RunTestURL(tab, url); | |
| 86 // Now we'll clean up the cookies to prepare for reloading and running the | |
| 87 // test again. Look for the first cookie that isn't equal to "...". It | |
| 88 // will either be "PASS" or errors from the test. | |
| 89 int progress_number = 0; | |
| 90 std::string cookie_name, progress("..."); | |
| 91 while (progress == "...") { | |
| 92 cookie_name = StringPrintf("PPAPI_PROGRESS_%d", progress_number); | |
| 93 progress = WaitUntilCookieNonEmpty(tab.get(), url, cookie_name.c_str(), | |
| 94 TestTimeouts::action_timeout_ms()); | |
| 95 ++progress_number; | |
| 96 } | |
| 97 // If the first run passed, then delete the "PASS" cookie and reload. If we | |
| 98 // left the "PASS" cookie alone, RunTestURL would find it and assume we | |
| 99 // passed the test on the reload regardless of the actual result. If the | |
| 100 // first run failed, we let those errors take precedent and don't bother | |
| 101 // reloading and running the test again. | |
| 102 if (progress == "PASS") { | |
| 103 EXPECT_TRUE(tab->DeleteCookie(url, cookie_name)); | |
| 104 EXPECT_TRUE(tab->Reload()); | |
| 105 RunTestURL(tab, url); | |
| 106 } | |
| 107 } | |
| 108 | |
| 81 void RunTestViaHTTP(const std::string& test_case) { | 109 void RunTestViaHTTP(const std::string& test_case) { |
| 82 // For HTTP tests, we use the output DIR to grab the generated files such | 110 // For HTTP tests, we use the output DIR to grab the generated files such |
| 83 // as the NEXEs. | 111 // as the NEXEs. |
| 84 FilePath exe_dir = CommandLine::ForCurrentProcess()->GetProgram().DirName(); | 112 FilePath exe_dir = CommandLine::ForCurrentProcess()->GetProgram().DirName(); |
| 85 FilePath src_dir; | 113 FilePath src_dir; |
| 86 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)); | 114 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)); |
| 87 | 115 |
| 88 // TestServer expects a path relative to source. So we must first | 116 // TestServer expects a path relative to source. So we must first |
| 89 // generate absolute paths to SRC and EXE and from there generate | 117 // generate absolute paths to SRC and EXE and from there generate |
| 90 // a relative path. | 118 // a relative path. |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 // Use these macros to run the tests for a specific interface. | 296 // Use these macros to run the tests for a specific interface. |
| 269 // Most interfaces should be tested with both macros. | 297 // Most interfaces should be tested with both macros. |
| 270 #define TEST_PPAPI_IN_PROCESS(test_name) \ | 298 #define TEST_PPAPI_IN_PROCESS(test_name) \ |
| 271 TEST_F(PPAPITest, test_name) { \ | 299 TEST_F(PPAPITest, test_name) { \ |
| 272 RunTest(STRIP_PREFIXES(test_name)); \ | 300 RunTest(STRIP_PREFIXES(test_name)); \ |
| 273 } | 301 } |
| 274 #define TEST_PPAPI_OUT_OF_PROCESS(test_name) \ | 302 #define TEST_PPAPI_OUT_OF_PROCESS(test_name) \ |
| 275 TEST_F(OutOfProcessPPAPITest, test_name) { \ | 303 TEST_F(OutOfProcessPPAPITest, test_name) { \ |
| 276 RunTest(STRIP_PREFIXES(test_name)); \ | 304 RunTest(STRIP_PREFIXES(test_name)); \ |
| 277 } | 305 } |
| 306 // Run the test and reload. This can test for clean shutdown, including leaked | |
| 307 // vars. | |
| 308 #define TEST_PPAPI_IN_PROCESS_AND_RELOAD(test_name) \ | |
| 309 TEST_F(PPAPITest, test_name) { \ | |
| 310 RunTestAndReload(STRIP_PREFIXES(test_name)); \ | |
| 311 } | |
| 312 #define TEST_PPAPI_OUT_OF_PROCESS_AND_RELOAD(test_name) \ | |
| 313 TEST_F(OutOfProcessPPAPITest, test_name) { \ | |
| 314 RunTestAndReload(STRIP_PREFIXES(test_name)); \ | |
| 315 } | |
| 316 | |
| 278 | 317 |
| 279 // Similar macros that test over HTTP. | 318 // Similar macros that test over HTTP. |
| 280 #define TEST_PPAPI_IN_PROCESS_VIA_HTTP(test_name) \ | 319 #define TEST_PPAPI_IN_PROCESS_VIA_HTTP(test_name) \ |
| 281 TEST_F(PPAPITest, test_name) { \ | 320 TEST_F(PPAPITest, test_name) { \ |
| 282 RunTestViaHTTP(STRIP_PREFIXES(test_name)); \ | 321 RunTestViaHTTP(STRIP_PREFIXES(test_name)); \ |
| 283 } | 322 } |
| 284 #define TEST_PPAPI_OUT_OF_PROCESS_VIA_HTTP(test_name) \ | 323 #define TEST_PPAPI_OUT_OF_PROCESS_VIA_HTTP(test_name) \ |
| 285 TEST_F(OutOfProcessPPAPITest, test_name) { \ | 324 TEST_F(OutOfProcessPPAPITest, test_name) { \ |
| 286 RunTestViaHTTP(STRIP_PREFIXES(test_name)); \ | 325 RunTestViaHTTP(STRIP_PREFIXES(test_name)); \ |
| 287 } | 326 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 #define MAYBE_InputEvent DISABLED_InputEvent | 397 #define MAYBE_InputEvent DISABLED_InputEvent |
| 359 #else | 398 #else |
| 360 #define MAYBE_InputEvent InputEvent | 399 #define MAYBE_InputEvent InputEvent |
| 361 #endif | 400 #endif |
| 362 | 401 |
| 363 TEST_PPAPI_IN_PROCESS(MAYBE_InputEvent) | 402 TEST_PPAPI_IN_PROCESS(MAYBE_InputEvent) |
| 364 TEST_PPAPI_OUT_OF_PROCESS(MAYBE_InputEvent) | 403 TEST_PPAPI_OUT_OF_PROCESS(MAYBE_InputEvent) |
| 365 // TODO(bbudge) Enable when input events are proxied correctly for NaCl. | 404 // TODO(bbudge) Enable when input events are proxied correctly for NaCl. |
| 366 TEST_PPAPI_NACL_VIA_HTTP(DISABLED_InputEvent) | 405 TEST_PPAPI_NACL_VIA_HTTP(DISABLED_InputEvent) |
| 367 | 406 |
| 368 TEST_PPAPI_IN_PROCESS(Instance) | 407 // We run and reload the InstanceDeprecated test to ensure that the |
| 408 // InstanceObject is properly cleaned up after the first run. | |
| 409 TEST_PPAPI_IN_PROCESS_AND_RELOAD(Instance) | |
|
brettw
2012/02/16 23:40:45
I think the macros are getting out of control. Do
| |
| 410 // TODO(dmichael): Fix the similar leak for o-o-p and use the RELOAD test. | |
| 369 TEST_PPAPI_OUT_OF_PROCESS(Instance) | 411 TEST_PPAPI_OUT_OF_PROCESS(Instance) |
| 370 // The Instance test is actually InstanceDeprecated which isn't supported | 412 // The Instance test is actually InstanceDeprecated which isn't supported |
| 371 // by NaCl. | 413 // by NaCl. |
| 372 | 414 |
| 373 TEST_PPAPI_IN_PROCESS(Graphics2D) | 415 TEST_PPAPI_IN_PROCESS(Graphics2D) |
| 374 TEST_PPAPI_OUT_OF_PROCESS(Graphics2D) | 416 TEST_PPAPI_OUT_OF_PROCESS(Graphics2D) |
| 375 TEST_PPAPI_NACL_VIA_HTTP(Graphics2D) | 417 TEST_PPAPI_NACL_VIA_HTTP(Graphics2D) |
| 376 | 418 |
| 377 TEST_PPAPI_IN_PROCESS(ImageData) | 419 TEST_PPAPI_IN_PROCESS(ImageData) |
| 378 TEST_PPAPI_OUT_OF_PROCESS(ImageData) | 420 TEST_PPAPI_OUT_OF_PROCESS(ImageData) |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 826 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_OutOfRangeAccess) | 868 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_OutOfRangeAccess) |
| 827 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_EmptyArray) | 869 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_EmptyArray) |
| 828 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_InvalidElement) | 870 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_InvalidElement) |
| 829 | 871 |
| 830 TEST_PPAPI_IN_PROCESS(FlashMessageLoop_Basics) | 872 TEST_PPAPI_IN_PROCESS(FlashMessageLoop_Basics) |
| 831 TEST_PPAPI_IN_PROCESS(FlashMessageLoop_RunWithoutQuit) | 873 TEST_PPAPI_IN_PROCESS(FlashMessageLoop_RunWithoutQuit) |
| 832 TEST_PPAPI_OUT_OF_PROCESS(FlashMessageLoop_Basics) | 874 TEST_PPAPI_OUT_OF_PROCESS(FlashMessageLoop_Basics) |
| 833 TEST_PPAPI_OUT_OF_PROCESS(FlashMessageLoop_RunWithoutQuit) | 875 TEST_PPAPI_OUT_OF_PROCESS(FlashMessageLoop_RunWithoutQuit) |
| 834 | 876 |
| 835 #endif // ADDRESS_SANITIZER | 877 #endif // ADDRESS_SANITIZER |
| OLD | NEW |