| 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")));
|
|
|