diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-16 17:02:11 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-16 17:02:11 +0000 |
commit | 6756f12acade35bf30e9fea7b108260e83b51243 (patch) | |
tree | c0c0dba62da71802dd277fe3f2d14ced8af2cb36 /chrome/browser/cocoa | |
parent | 8f00b6a302b2d4ec556520b868faa20ec5f0d927 (diff) | |
download | chromium_src-6756f12acade35bf30e9fea7b108260e83b51243.zip chromium_src-6756f12acade35bf30e9fea7b108260e83b51243.tar.gz chromium_src-6756f12acade35bf30e9fea7b108260e83b51243.tar.bz2 |
[Mac] Fix a leak in CookiesWindowControllerTest by giving BrowserTestHelper a fake IO thread.
Thanks to Randy Smith for tracking this down.
BUG=31586
TEST=Valgrind Mac unit_tests stay green.
Review URL: http://codereview.chromium.org/2798001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49968 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/browser_test_helper.h | 11 | ||||
-rw-r--r-- | chrome/browser/cocoa/cookies_window_controller_unittest.mm | 4 |
2 files changed, 10 insertions, 5 deletions
diff --git a/chrome/browser/cocoa/browser_test_helper.h b/chrome/browser/cocoa/browser_test_helper.h index 77016f1..a264317 100644 --- a/chrome/browser/cocoa/browser_test_helper.h +++ b/chrome/browser/cocoa/browser_test_helper.h @@ -13,6 +13,13 @@ // Base class which contains a valid Browser*. Lots of boilerplate to // recycle between unit test classes. // +// This class creates fake UI, file, and IO threads because many objects that +// are attached to the TestingProfile (and other objects) have traits that limit +// their destruction to certain threads. For example, the URLRequestContext can +// only be deleted on the IO thread; without this fake IO thread, the object +// would never be deleted and would report as a leak under Valgrind. Note that +// these are fake threads and they all share the same MessageLoop. +// // TODO(jrg): move up a level (chrome/browser/cocoa --> // chrome/browser), and use in non-Mac unit tests such as // back_forward_menu_model_unittest.cc, @@ -21,7 +28,8 @@ class BrowserTestHelper { public: BrowserTestHelper() : ui_thread_(ChromeThread::UI, &message_loop_), - file_thread_(ChromeThread::FILE, &message_loop_) { + file_thread_(ChromeThread::FILE, &message_loop_), + io_thread_(ChromeThread::IO, &message_loop_) { profile_.reset(new TestingProfile()); profile_->CreateBookmarkModel(true); profile_->BlockUntilBookmarkModelLoaded(); @@ -72,6 +80,7 @@ class BrowserTestHelper { MessageLoopForUI message_loop_; ChromeThread ui_thread_; ChromeThread file_thread_; + ChromeThread io_thread_; }; #endif // CHROME_BROWSER_COCOA_BROWSER_TEST_HELPER_H_ diff --git a/chrome/browser/cocoa/cookies_window_controller_unittest.mm b/chrome/browser/cocoa/cookies_window_controller_unittest.mm index ea07ff1..b02031f 100644 --- a/chrome/browser/cocoa/cookies_window_controller_unittest.mm +++ b/chrome/browser/cocoa/cookies_window_controller_unittest.mm @@ -51,8 +51,6 @@ namespace { class CookiesWindowControllerTest : public CocoaTest { public: - CookiesWindowControllerTest() - : io_thread_(ChromeThread::IO, MessageLoop::current()) {} virtual void SetUp() { CocoaTest::SetUp(); @@ -84,8 +82,6 @@ class CookiesWindowControllerTest : public CocoaTest { protected: BrowserTestHelper browser_helper_; - // Need an IO thread to not leak from TestingProfile::CreateRequestContext(). - ChromeThread io_thread_; scoped_nsobject<CookiesWindowController> controller_; MockBrowsingDataDatabaseHelper* database_helper_; MockBrowsingDataLocalStorageHelper* local_storage_helper_; |