diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 23:47:58 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 23:47:58 +0000 |
commit | 1cf1f99e52b39e01115eeef712c139dfa63df00e (patch) | |
tree | a66199aae6d00f1174e088eeaac1701d4cd50fe0 /chrome/browser/sync | |
parent | a16cea5c0b48672e3823f6f79e9908b83dc0354c (diff) | |
download | chromium_src-1cf1f99e52b39e01115eeef712c139dfa63df00e.zip chromium_src-1cf1f99e52b39e01115eeef712c139dfa63df00e.tar.gz chromium_src-1cf1f99e52b39e01115eeef712c139dfa63df00e.tar.bz2 |
Fix two URLRequestContext leaks in HttpBridgeTest and reenable the test. It was previously failing the purify step.
BUG=19002
TEST=HttpBridgeTest
Review URL: http://codereview.chromium.org/165363
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23254 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync')
-rw-r--r-- | chrome/browser/sync/glue/http_bridge_unittest.cc | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/chrome/browser/sync/glue/http_bridge_unittest.cc b/chrome/browser/sync/glue/http_bridge_unittest.cc index ab85184..63da13a 100644 --- a/chrome/browser/sync/glue/http_bridge_unittest.cc +++ b/chrome/browser/sync/glue/http_bridge_unittest.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// TODO(timsteele): Re-enable ASAP. http://crbug.com/19002 -#if 0 #ifdef CHROME_PERSONALIZATION #include "base/thread.h" @@ -20,7 +18,8 @@ const char16 kDocRoot[] = L"chrome/test/data"; class HttpBridgeTest : public testing::Test { public: - HttpBridgeTest() : io_thread_("HttpBridgeTest IO thread") { + HttpBridgeTest() : io_thread_("HttpBridgeTest IO thread"), + fake_default_request_context_(NULL) { } virtual void SetUp() { @@ -30,24 +29,30 @@ class HttpBridgeTest : public testing::Test { } virtual void TearDown() { + io_thread_loop()->ReleaseSoon(FROM_HERE, fake_default_request_context_); io_thread_.Stop(); + fake_default_request_context_ = NULL; } HttpBridge* BuildBridge() { - if (!request_context_) { - request_context_ = new HttpBridge::RequestContext( - new TestURLRequestContext()); + if (!fake_default_request_context_) { + fake_default_request_context_ = new TestURLRequestContext(); + fake_default_request_context_->AddRef(); } - HttpBridge* bridge = new HttpBridge(request_context_, - io_thread_.message_loop()); + HttpBridge* bridge = new HttpBridge( + new HttpBridge::RequestContext(fake_default_request_context_), + io_thread_.message_loop()); bridge->use_io_loop_for_testing_ = true; return bridge; } MessageLoop* io_thread_loop() { return io_thread_.message_loop(); } private: + // A make-believe "default" request context, as would be returned by + // Profile::GetDefaultRequestContext(). Created lazily by BuildBridge. + TestURLRequestContext* fake_default_request_context_; + // Separate thread for IO used by the HttpBridge. - scoped_refptr<HttpBridge::RequestContext> request_context_; base::Thread io_thread_; }; @@ -82,8 +87,9 @@ class ShuntedHttpBridge : public HttpBridge { // Test the HttpBridge without actually making any network requests. TEST_F(HttpBridgeTest, TestMakeSynchronousPostShunted) { + scoped_refptr<TestURLRequestContext> ctx(new TestURLRequestContext()); scoped_refptr<HttpBridge> http_bridge(new ShuntedHttpBridge( - new TestURLRequestContext(), io_thread_loop(), this)); + ctx, io_thread_loop(), this)); http_bridge->SetUserAgent("bob"); http_bridge->SetURL("http://www.google.com", 9999); http_bridge->SetPostPayload("text/plain", 2, " "); @@ -168,4 +174,3 @@ TEST_F(HttpBridgeTest, TestMakeSynchronousPostLiveComprehensive) { } #endif // CHROME_PERSONALIZATION -#endif |