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

Unified Diff: net/url_request/url_request_unittest.cc

Issue 7598001: Remove the old synchronous CookieMonster API. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« net/base/cookie_store.h ('K') | « net/base/cookie_store.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« net/base/cookie_store.h ('K') | « net/base/cookie_store.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698