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

Side by Side Diff: components/cronet/ios/test/cronet_http_test.mm

Issue 2512263002: Pass raw response with Context-Encoding sdch if support is not configured. (Closed)
Patch Set: Fix net unittests. Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <Cronet/Cronet.h> 5 #import <Cronet/Cronet.h>
6 #import <Foundation/Foundation.h> 6 #import <Foundation/Foundation.h>
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 TEST_F(HttpTest, SdchDisabledByDefault) { 190 TEST_F(HttpTest, SdchDisabledByDefault) {
191 NSURL* url = 191 NSURL* url =
192 net::NSURLWithGURL(GURL(TestServer::GetEchoHeaderURL("Accept-Encoding"))); 192 net::NSURLWithGURL(GURL(TestServer::GetEchoHeaderURL("Accept-Encoding")));
193 NSURLSessionDataTask* task = [session_ dataTaskWithURL:url]; 193 NSURLSessionDataTask* task = [session_ dataTaskWithURL:url];
194 StartDataTaskAndWaitForCompletion(task); 194 StartDataTaskAndWaitForCompletion(task);
195 EXPECT_EQ(nil, [delegate_ error]); 195 EXPECT_EQ(nil, [delegate_ error]);
196 EXPECT_FALSE([[delegate_ responseBody] containsString:@"sdch"]); 196 EXPECT_FALSE([[delegate_ responseBody] containsString:@"sdch"]);
197 } 197 }
198 198
199 TEST_F(HttpTest, AcceptEncodingSdch) {
xunjieli 2016/11/29 23:30:42 I think this deserves a comment and maybe also men
mef 2016/11/30 15:51:06 Done.
200 NSURL* url =
201 net::NSURLWithGURL(GURL(TestServer::GetEchoHeaderURL("Accept-Encoding")));
202 NSMutableURLRequest* mutableRequest =
203 [[NSURLRequest requestWithURL:url] mutableCopy];
204 [mutableRequest addValue:@"gzip,sdch" forHTTPHeaderField:@"Accept-Encoding"];
205 NSURLSessionDataTask* task = [session_ dataTaskWithRequest:mutableRequest];
206 StartDataTaskAndWaitForCompletion(task);
207 EXPECT_EQ(nil, [delegate_ error]);
208 EXPECT_TRUE([[delegate_ responseBody] containsString:@"gzip,sdch"]);
209 }
210
211 TEST_F(HttpTest, AcceptEncodingFooBar) {
212 NSURL* url =
213 net::NSURLWithGURL(GURL(TestServer::GetEchoHeaderURL("Accept-Encoding")));
214 NSMutableURLRequest* mutableRequest =
215 [[NSURLRequest requestWithURL:url] mutableCopy];
216 [mutableRequest addValue:@"foo,bar" forHTTPHeaderField:@"Accept-Encoding"];
217 NSURLSessionDataTask* task = [session_ dataTaskWithRequest:mutableRequest];
218 StartDataTaskAndWaitForCompletion(task);
219 EXPECT_EQ(nil, [delegate_ error]);
220 EXPECT_TRUE([[delegate_ responseBody] containsString:@"foo,bar"]);
221 }
222
199 TEST_F(HttpTest, NSURLSessionAcceptLanguage) { 223 TEST_F(HttpTest, NSURLSessionAcceptLanguage) {
200 NSURL* url = 224 NSURL* url =
201 net::NSURLWithGURL(GURL(TestServer::GetEchoHeaderURL("Accept-Language"))); 225 net::NSURLWithGURL(GURL(TestServer::GetEchoHeaderURL("Accept-Language")));
202 NSURLSessionDataTask* task = [session_ dataTaskWithURL:url]; 226 NSURLSessionDataTask* task = [session_ dataTaskWithURL:url];
203 StartDataTaskAndWaitForCompletion(task); 227 StartDataTaskAndWaitForCompletion(task);
204 EXPECT_EQ(nil, [delegate_ error]); 228 EXPECT_EQ(nil, [delegate_ error]);
205 ASSERT_STREQ("en-US,en", [[delegate_ responseBody] UTF8String]); 229 ASSERT_STREQ("en-US,en", [[delegate_ responseBody] UTF8String]);
206 } 230 }
207 231
208 TEST_F(HttpTest, SetUserAgentIsExact) { 232 TEST_F(HttpTest, SetUserAgentIsExact) {
(...skipping 18 matching lines...) Expand all
227 }]; 251 }];
228 StartDataTaskAndWaitForCompletion(task); 252 StartDataTaskAndWaitForCompletion(task);
229 EXPECT_TRUE(block_used); 253 EXPECT_TRUE(block_used);
230 EXPECT_EQ(nil, [delegate_ error]); 254 EXPECT_EQ(nil, [delegate_ error]);
231 EXPECT_FALSE([[delegate_ responseBody] 255 EXPECT_FALSE([[delegate_ responseBody]
232 containsString:base::SysUTF8ToNSString(kUserAgent)]); 256 containsString:base::SysUTF8ToNSString(kUserAgent)]);
233 EXPECT_TRUE([[delegate_ responseBody] containsString:@"CFNetwork"]); 257 EXPECT_TRUE([[delegate_ responseBody] containsString:@"CFNetwork"]);
234 } 258 }
235 259
236 } // namespace cronet 260 } // namespace cronet
OLDNEW
« no previous file with comments | « no previous file | net/url_request/url_request_http_job.cc » ('j') | net/url_request/url_request_http_job_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698