| OLD | NEW |
| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 [task resume]; | 156 [task resume]; |
| 157 int64_t deadline_ns = 1 * ns_in_second; | 157 int64_t deadline_ns = 1 * ns_in_second; |
| 158 dispatch_semaphore_wait([delegate_ semaphore], | 158 dispatch_semaphore_wait([delegate_ semaphore], |
| 159 dispatch_time(DISPATCH_TIME_NOW, deadline_ns)); | 159 dispatch_time(DISPATCH_TIME_NOW, deadline_ns)); |
| 160 } | 160 } |
| 161 | 161 |
| 162 base::scoped_nsobject<NSURLSession> session_; | 162 base::scoped_nsobject<NSURLSession> session_; |
| 163 base::scoped_nsobject<TestDelegate> delegate_; | 163 base::scoped_nsobject<TestDelegate> delegate_; |
| 164 }; | 164 }; |
| 165 | 165 |
| 166 TEST_F(HttpTest, CreateFile) { |
| 167 bool ssl_file_created = [[NSFileManager defaultManager] |
| 168 fileExistsAtPath:[Cronet getNetLogPathForFile:@"SSLKEYLOGFILE"]]; |
| 169 |
| 170 [[NSFileManager defaultManager] |
| 171 removeItemAtPath:[Cronet getNetLogPathForFile:@"SSLKEYLOGFILE"] |
| 172 error:nil]; |
| 173 |
| 174 EXPECT_TRUE(ssl_file_created); |
| 175 } |
| 176 |
| 166 TEST_F(HttpTest, NSURLSessionReceivesData) { | 177 TEST_F(HttpTest, NSURLSessionReceivesData) { |
| 167 NSURL* url = net::NSURLWithGURL(GURL(grpc_support::kTestServerUrl)); | 178 NSURL* url = net::NSURLWithGURL(GURL(grpc_support::kTestServerUrl)); |
| 168 __block BOOL block_used = NO; | 179 __block BOOL block_used = NO; |
| 169 NSURLSessionDataTask* task = [session_ dataTaskWithURL:url]; | 180 NSURLSessionDataTask* task = [session_ dataTaskWithURL:url]; |
| 170 [Cronet setRequestFilterBlock:^(NSURLRequest* request) { | 181 [Cronet setRequestFilterBlock:^(NSURLRequest* request) { |
| 171 block_used = YES; | 182 block_used = YES; |
| 172 EXPECT_EQ([request URL], url); | 183 EXPECT_EQ([request URL], url); |
| 173 return YES; | 184 return YES; |
| 174 }]; | 185 }]; |
| 175 StartDataTaskAndWaitForCompletion(task); | 186 StartDataTaskAndWaitForCompletion(task); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 [Cronet setRequestFilterBlock:^(NSURLRequest* request) { | 420 [Cronet setRequestFilterBlock:^(NSURLRequest* request) { |
| 410 EXPECT_TRUE(false) << "Block should not be called for unsupported requests"; | 421 EXPECT_TRUE(false) << "Block should not be called for unsupported requests"; |
| 411 return YES; | 422 return YES; |
| 412 }]; | 423 }]; |
| 413 StartDataTaskAndWaitForCompletion(task); | 424 StartDataTaskAndWaitForCompletion(task); |
| 414 EXPECT_EQ(nil, [delegate_ error]); | 425 EXPECT_EQ(nil, [delegate_ error]); |
| 415 EXPECT_TRUE([[delegate_ responseBody] containsString:testString]); | 426 EXPECT_TRUE([[delegate_ responseBody] containsString:testString]); |
| 416 } | 427 } |
| 417 | 428 |
| 418 } // namespace cronet | 429 } // namespace cronet |
| OLD | NEW |