Chromium Code Reviews| Index: net/url_request/url_request_unittest.cc |
| =================================================================== |
| --- net/url_request/url_request_unittest.cc (revision 95998) |
| +++ net/url_request/url_request_unittest.cc (working copy) |
| @@ -13,6 +13,7 @@ |
| #include <string> |
| #include "base/basictypes.h" |
| +#include "base/bind.h" |
| #include "base/compiler_specific.h" |
| #include "base/file_util.h" |
| #include "base/format_macros.h" |
| @@ -1632,42 +1633,42 @@ |
| } |
| } |
| -TEST_F(URLRequestTest, DelayedCookieCallback) { |
| - TestServer test_server(TestServer::TYPE_HTTP, FilePath()); |
| - ASSERT_TRUE(test_server.Start()); |
| +// TEST_F(URLRequestTest, DelayedCookieCallback) { |
| +// TestServer test_server(TestServer::TYPE_HTTP, FilePath()); |
| +// ASSERT_TRUE(test_server.Start()); |
| - scoped_refptr<URLRequestContext> context(new TestURLRequestContext()); |
| - scoped_refptr<DelayedCookieMonster> delayed_cm = |
| - new DelayedCookieMonster(); |
| - scoped_refptr<CookieStore> cookie_store = delayed_cm; |
| - context->set_cookie_store(delayed_cm); |
| +// scoped_refptr<URLRequestContext> context(new TestURLRequestContext()); |
| +// scoped_refptr<DelayedCookieMonster> delayed_cm = |
| +// new DelayedCookieMonster(); |
| +// scoped_refptr<CookieStore> cookie_store = delayed_cm; |
| +// context->set_cookie_store(delayed_cm); |
| - // Set up a cookie. |
| - { |
| - TestDelegate d; |
| - URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); |
| - req.set_context(context); |
| - req.Start(); |
| - MessageLoop::current()->Run(); |
| - EXPECT_EQ(0, d.blocked_get_cookies_count()); |
| - EXPECT_EQ(0, d.blocked_set_cookie_count()); |
| - EXPECT_EQ(1, d.set_cookie_count()); |
| - } |
| +// // Set up a cookie. |
| +// { |
| +// TestDelegate d; |
| +// URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); |
| +// req.set_context(context); |
| +// req.Start(); |
| +// MessageLoop::current()->Run(); |
| +// EXPECT_EQ(0, d.blocked_get_cookies_count()); |
| +// EXPECT_EQ(0, d.blocked_set_cookie_count()); |
| +// EXPECT_EQ(1, d.set_cookie_count()); |
| +// } |
| - // Verify that the cookie is set. |
| - { |
| - TestDelegate d; |
| - TestURLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
| - req.set_context(context); |
| - req.Start(); |
| - MessageLoop::current()->Run(); |
| +// // Verify that the cookie is set. |
| +// { |
| +// TestDelegate d; |
| +// TestURLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
| +// req.set_context(context); |
| +// req.Start(); |
| +// MessageLoop::current()->Run(); |
| - EXPECT_TRUE(d.data_received().find("CookieToNotSend=1") |
| - != std::string::npos); |
| - EXPECT_EQ(0, d.blocked_get_cookies_count()); |
| - EXPECT_EQ(0, d.blocked_set_cookie_count()); |
| - } |
| -} |
| +// EXPECT_TRUE(d.data_received().find("CookieToNotSend=1") |
| +// != std::string::npos); |
| +// EXPECT_EQ(0, d.blocked_get_cookies_count()); |
| +// EXPECT_EQ(0, d.blocked_set_cookie_count()); |
| +// } |
| +// } |
| TEST_F(URLRequestTest, DoNotSendCookies) { |
| TestServer test_server(TestServer::TYPE_HTTP, FilePath()); |
| @@ -1982,6 +1983,12 @@ |
| } |
| } |
| +void CheckCookiePolicyCallback(const CookieList& cookies) { |
| + EXPECT_EQ(1U, cookies.size()); |
| + EXPECT_FALSE(cookies[0].IsPersistent()); |
| + MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
| +} |
| + |
| TEST_F(URLRequestTest, CookiePolicy_ForceSession) { |
| TestServer test_server(TestServer::TYPE_HTTP, FilePath()); |
| ASSERT_TRUE(test_server.Start()); |
| @@ -2002,10 +2009,9 @@ |
| } |
| // Now, check the cookie store. |
| - CookieList cookies = |
| - default_context_->cookie_store()->GetCookieMonster()->GetAllCookies(); |
| - EXPECT_EQ(1U, cookies.size()); |
| - EXPECT_FALSE(cookies[0].IsPersistent()); |
| + default_context_->cookie_store()->GetCookieMonster()->GetAllCookiesAsync( |
| + base::Bind(&CheckCookiePolicyCallback)); |
| + MessageLoop::current()->RunAllPending(); |
|
erikwright (departed)
2011/08/11 15:13:52
Use a 'was_run' boolean to verify that the callbac
ycxiao
2011/08/12 02:35:24
Done.
|
| } |
| // In this test, we do a POST which the server will 302 redirect. |