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

Unified Diff: components/cronet/ios/test/cronet_http_test.mm

Issue 2513023002: [Cronet] Add CookieStoreIOS. (Closed)
Patch Set: . Created 4 years, 1 month 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
« no previous file with comments | « components/cronet/ios/cronet_environment.mm ('k') | components/cronet/ios/test/test_server.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cronet/ios/test/cronet_http_test.mm
diff --git a/components/cronet/ios/test/cronet_http_test.mm b/components/cronet/ios/test/cronet_http_test.mm
index 36923e623a6d47a1e42db8a116aa53b87190d019..abf15c4b1d66d9a458ebb90e9387ba0cee94fade 100644
--- a/components/cronet/ios/test/cronet_http_test.mm
+++ b/components/cronet/ios/test/cronet_http_test.mm
@@ -57,6 +57,11 @@
[super dealloc];
}
+- (void)reset {
+ _responseBody = nil;
+ _error = nil;
+}
+
- (void)URLSession:(NSURLSession*)session
didBecomeInvalidWithError:(NSError*)error {
}
@@ -147,6 +152,7 @@ class HttpTest : public ::testing::Test {
// Launches the supplied |task| and blocks until it completes, with a timeout
// of 1 second.
void StartDataTaskAndWaitForCompletion(NSURLSessionDataTask* task) {
+ [delegate_ reset];
[task resume];
int64_t deadline_ns = 1 * ns_in_second;
dispatch_semaphore_wait([delegate_ semaphore],
@@ -215,6 +221,28 @@ TEST_F(HttpTest, SetUserAgentIsExact) {
EXPECT_STREQ(kUserAgent, [[delegate_ responseBody] UTF8String]);
}
+TEST_F(HttpTest, SetCookie) {
+ const char kCookieHeader[] = "Cookie";
+ const char kCookieLine[] = "aaaa=bbb";
+ NSURL* echoCookieUrl =
+ net::NSURLWithGURL(GURL(TestServer::GetEchoHeaderURL(kCookieHeader)));
+ StartDataTaskAndWaitForCompletion([session_ dataTaskWithURL:echoCookieUrl]);
+ EXPECT_EQ(nil, [delegate_ error]);
+ EXPECT_EQ(nil, [delegate_ responseBody]);
+
+ NSURL* setCookieUrl =
+ net::NSURLWithGURL(GURL(TestServer::GetSetCookieURL(kCookieLine)));
+ StartDataTaskAndWaitForCompletion([session_ dataTaskWithURL:setCookieUrl]);
+ EXPECT_EQ(nil, [delegate_ error]);
+ EXPECT_TRUE([[delegate_ responseBody]
+ containsString:base::SysUTF8ToNSString(kCookieLine)]);
+
+ StartDataTaskAndWaitForCompletion([session_ dataTaskWithURL:echoCookieUrl]);
+ EXPECT_EQ(nil, [delegate_ error]);
+ EXPECT_TRUE([[delegate_ responseBody]
+ containsString:base::SysUTF8ToNSString(kCookieLine)]);
+}
+
TEST_F(HttpTest, FilterOutRequest) {
NSURL* url =
net::NSURLWithGURL(GURL(TestServer::GetEchoHeaderURL("User-Agent")));
« no previous file with comments | « components/cronet/ios/cronet_environment.mm ('k') | components/cronet/ios/test/test_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698