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

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: Fix instance object reference leak, add testing. Created 8 years, 10 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') | webkit/plugins/ppapi/ppapi_webplugin_impl.cc » ('J')
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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 #define MAYBE_InputEvent DISABLED_InputEvent 388 #define MAYBE_InputEvent DISABLED_InputEvent
359 #else 389 #else
360 #define MAYBE_InputEvent InputEvent 390 #define MAYBE_InputEvent InputEvent
361 #endif 391 #endif
362 392
363 TEST_PPAPI_IN_PROCESS(MAYBE_InputEvent) 393 TEST_PPAPI_IN_PROCESS(MAYBE_InputEvent)
364 TEST_PPAPI_OUT_OF_PROCESS(MAYBE_InputEvent) 394 TEST_PPAPI_OUT_OF_PROCESS(MAYBE_InputEvent)
365 // TODO(bbudge) Enable when input events are proxied correctly for NaCl. 395 // TODO(bbudge) Enable when input events are proxied correctly for NaCl.
366 TEST_PPAPI_NACL_VIA_HTTP(DISABLED_InputEvent) 396 TEST_PPAPI_NACL_VIA_HTTP(DISABLED_InputEvent)
367 397
368 TEST_PPAPI_IN_PROCESS(Instance) 398 TEST_PPAPI_IN_PROCESS(Instance_ExecuteScript);
369 TEST_PPAPI_OUT_OF_PROCESS(Instance) 399 TEST_PPAPI_OUT_OF_PROCESS(Instance_ExecuteScript)
370 // The Instance test is actually InstanceDeprecated which isn't supported 400 // ExecuteScript isn't supported by NaCl.
371 // by NaCl. 401
402 // We run and reload the RecursiveObjects test to ensure that the InstanceObject
403 // (and others) are properly cleaned up after the first run.
404 TEST_F(PPAPITest, Instance_RecursiveObjects) {
405 RunTestAndReload("Instance_RecursiveObjects");
406 }
407 // TODO(dmichael): Make it work out-process (or at least see whether we care).
408 TEST_F(OutOfProcessPPAPITest, DISABLED_Instance_RecursiveObjects) {
409 RunTestAndReload("Instance_RecursiveObjects");
410 }
411 TEST_PPAPI_IN_PROCESS(Instance_TestLeakedObjectDestructors);
412 TEST_PPAPI_OUT_OF_PROCESS(Instance_TestLeakedObjectDestructors);
413 // ScriptableObjects aren't supported in NaCl, so Instance_RecursiveObjects and
414 // Instance_TestLeakedObjectDestructors don't make sense for NaCl.
372 415
373 TEST_PPAPI_IN_PROCESS(Graphics2D) 416 TEST_PPAPI_IN_PROCESS(Graphics2D)
374 TEST_PPAPI_OUT_OF_PROCESS(Graphics2D) 417 TEST_PPAPI_OUT_OF_PROCESS(Graphics2D)
375 TEST_PPAPI_NACL_VIA_HTTP(Graphics2D) 418 TEST_PPAPI_NACL_VIA_HTTP(Graphics2D)
376 419
377 TEST_PPAPI_IN_PROCESS(ImageData) 420 TEST_PPAPI_IN_PROCESS(ImageData)
378 TEST_PPAPI_OUT_OF_PROCESS(ImageData) 421 TEST_PPAPI_OUT_OF_PROCESS(ImageData)
379 TEST_PPAPI_NACL_VIA_HTTP(ImageData) 422 TEST_PPAPI_NACL_VIA_HTTP(ImageData)
380 423
381 TEST_PPAPI_IN_PROCESS(BrowserFont) 424 TEST_PPAPI_IN_PROCESS(BrowserFont)
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_OutOfRangeAccess) 901 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_OutOfRangeAccess)
859 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_EmptyArray) 902 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_EmptyArray)
860 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_InvalidElement) 903 TEST_PPAPI_OUT_OF_PROCESS(ResourceArray_InvalidElement)
861 904
862 TEST_PPAPI_IN_PROCESS(FlashMessageLoop_Basics) 905 TEST_PPAPI_IN_PROCESS(FlashMessageLoop_Basics)
863 TEST_PPAPI_IN_PROCESS(FlashMessageLoop_RunWithoutQuit) 906 TEST_PPAPI_IN_PROCESS(FlashMessageLoop_RunWithoutQuit)
864 TEST_PPAPI_OUT_OF_PROCESS(FlashMessageLoop_Basics) 907 TEST_PPAPI_OUT_OF_PROCESS(FlashMessageLoop_Basics)
865 TEST_PPAPI_OUT_OF_PROCESS(FlashMessageLoop_RunWithoutQuit) 908 TEST_PPAPI_OUT_OF_PROCESS(FlashMessageLoop_RunWithoutQuit)
866 909
867 #endif // ADDRESS_SANITIZER 910 #endif // ADDRESS_SANITIZER
OLDNEW
« no previous file with comments | « no previous file | ppapi/tests/test_case.h » ('j') | webkit/plugins/ppapi/ppapi_webplugin_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698