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

Side by Side Diff: chrome/test/ui/ppapi_uitest.cc

Issue 9403039: PPAPI: Really force-free NPObjects on Instance destruction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | « no previous file | ppapi/tests/test_case.h » ('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 "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
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 // Run the test and reload. This can test for clean shutdown, including leaked
80 // instance object vars.
81 void RunTestAndReload(const std::string& test_case) {
82 scoped_refptr<TabProxy> tab = GetActiveTab();
83 ASSERT_TRUE(tab.get());
84 GURL url = GetTestFileUrl(test_case);
85 // Run the test the first time.
86 EXPECT_TRUE(tab->NavigateToURLBlockUntilNavigationsComplete(url, 1));
87 RunTestURL(tab, url);
88 // Now we'll clean up the cookies to prepare for reloading and running the
89 // test again. Look for the first cookie that isn't equal to "...". It
90 // will either be "PASS" or errors from the test.
91 int progress_number = 0;
92 std::string cookie_name, progress("...");
93 while (progress == "...") {
94 cookie_name = StringPrintf("PPAPI_PROGRESS_%d", progress_number);
95 progress = WaitUntilCookieNonEmpty(tab.get(), url, cookie_name.c_str(),
96 TestTimeouts::action_timeout_ms());
97 ++progress_number;
98 }
99 // If the first run passed, then delete the "PASS" cookie and reload. If we
100 // left the "PASS" cookie alone, RunTestURL would find it and assume we
101 // passed the test on the reload regardless of the actual result. If the
102 // first run failed, we let those errors take precedent and don't bother
103 // reloading and running the test again.
104 if (progress == "PASS") {
105 EXPECT_TRUE(tab->DeleteCookie(url, cookie_name));
106 EXPECT_TRUE(tab->Reload());
107 RunTestURL(tab, url);
108 }
109 }
110
81 void RunTestViaHTTP(const std::string& test_case) { 111 void RunTestViaHTTP(const std::string& test_case) {
82 // For HTTP tests, we use the output DIR to grab the generated files such 112 // For HTTP tests, we use the output DIR to grab the generated files such
83 // as the NEXEs. 113 // as the NEXEs.
84 FilePath exe_dir = CommandLine::ForCurrentProcess()->GetProgram().DirName(); 114 FilePath exe_dir = CommandLine::ForCurrentProcess()->GetProgram().DirName();
85 FilePath src_dir; 115 FilePath src_dir;
86 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)); 116 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir));
87 117
88 // TestServer expects a path relative to source. So we must first 118 // TestServer expects a path relative to source. So we must first
89 // generate absolute paths to SRC and EXE and from there generate 119 // generate absolute paths to SRC and EXE and from there generate
90 // a relative path. 120 // a relative path.
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 #define MAYBE_InputEvent DISABLED_InputEvent 390 #define MAYBE_InputEvent DISABLED_InputEvent
361 #else 391 #else
362 #define MAYBE_InputEvent InputEvent 392 #define MAYBE_InputEvent InputEvent
363 #endif 393 #endif
364 394
365 TEST_PPAPI_IN_PROCESS(MAYBE_InputEvent) 395 TEST_PPAPI_IN_PROCESS(MAYBE_InputEvent)
366 TEST_PPAPI_OUT_OF_PROCESS(MAYBE_InputEvent) 396 TEST_PPAPI_OUT_OF_PROCESS(MAYBE_InputEvent)
367 // TODO(bbudge) Enable when input events are proxied correctly for NaCl. 397 // TODO(bbudge) Enable when input events are proxied correctly for NaCl.
368 TEST_PPAPI_NACL_VIA_HTTP(DISABLED_InputEvent) 398 TEST_PPAPI_NACL_VIA_HTTP(DISABLED_InputEvent)
369 399
370 TEST_PPAPI_IN_PROCESS(Instance) 400 TEST_PPAPI_IN_PROCESS(Instance_ExecuteScript);
371 TEST_PPAPI_OUT_OF_PROCESS(Instance) 401 TEST_PPAPI_OUT_OF_PROCESS(Instance_ExecuteScript)
372 // The Instance test is actually InstanceDeprecated which isn't supported 402 // ExecuteScript isn't supported by NaCl.
373 // by NaCl. 403
404 // We run and reload the RecursiveObjects test to ensure that the InstanceObject
405 // (and others) are properly cleaned up after the first run.
406 TEST_F(PPAPITest, Instance_RecursiveObjects) {
407 RunTestAndReload("Instance_RecursiveObjects");
408 }
409 // TODO(dmichael): Make it work out-process (or at least see whether we care).
410 TEST_F(OutOfProcessPPAPITest, DISABLED_Instance_RecursiveObjects) {
411 RunTestAndReload("Instance_RecursiveObjects");
412 }
413 TEST_PPAPI_IN_PROCESS(Instance_TestLeakedObjectDestructors);
414 TEST_PPAPI_OUT_OF_PROCESS(Instance_TestLeakedObjectDestructors);
415 // ScriptableObjects aren't supported in NaCl, so Instance_RecursiveObjects and
416 // Instance_TestLeakedObjectDestructors don't make sense for NaCl.
374 417
375 TEST_PPAPI_IN_PROCESS(Graphics2D) 418 TEST_PPAPI_IN_PROCESS(Graphics2D)
376 TEST_PPAPI_OUT_OF_PROCESS(Graphics2D) 419 TEST_PPAPI_OUT_OF_PROCESS(Graphics2D)
377 TEST_PPAPI_NACL_VIA_HTTP(Graphics2D) 420 TEST_PPAPI_NACL_VIA_HTTP(Graphics2D)
378 421
379 TEST_PPAPI_IN_PROCESS(ImageData) 422 TEST_PPAPI_IN_PROCESS(ImageData)
380 TEST_PPAPI_OUT_OF_PROCESS(ImageData) 423 TEST_PPAPI_OUT_OF_PROCESS(ImageData)
381 TEST_PPAPI_NACL_VIA_HTTP(ImageData) 424 TEST_PPAPI_NACL_VIA_HTTP(ImageData)
382 425
383 TEST_PPAPI_IN_PROCESS(BrowserFont) 426 TEST_PPAPI_IN_PROCESS(BrowserFont)
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_OutOfRangeAccess) 904 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_OutOfRangeAccess)
862 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_EmptyArray) 905 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_EmptyArray)
863 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_InvalidElement) 906 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_InvalidElement)
864 907
865 TEST_PPAPI_IN_PROCESS(FlashMessageLoop_Basics) 908 TEST_PPAPI_IN_PROCESS(FlashMessageLoop_Basics)
866 TEST_PPAPI_IN_PROCESS(FlashMessageLoop_RunWithoutQuit) 909 TEST_PPAPI_IN_PROCESS(FlashMessageLoop_RunWithoutQuit)
867 TEST_PPAPI_OUT_OF_PROCESS(FlashMessageLoop_Basics) 910 TEST_PPAPI_OUT_OF_PROCESS(FlashMessageLoop_Basics)
868 TEST_PPAPI_OUT_OF_PROCESS(FlashMessageLoop_RunWithoutQuit) 911 TEST_PPAPI_OUT_OF_PROCESS(FlashMessageLoop_RunWithoutQuit)
869 912
870 #endif // ADDRESS_SANITIZER 913 #endif // ADDRESS_SANITIZER
OLDNEW
« no previous file with comments | « no previous file | ppapi/tests/test_case.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698