Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <Foundation/Foundation.h> | 5 #import <Foundation/Foundation.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 #include <list> | 7 #include <list> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 ASSERT_EQ(std::string(kHelloHeaderValue), | 319 ASSERT_EQ(std::string(kHelloHeaderValue), |
| 320 test.response_headers[kHelloHeaderName]); | 320 test.response_headers[kHelloHeaderName]); |
| 321 ASSERT_EQ(TestBidirectionalStreamCallback::ON_SUCCEEDED, test.response_step); | 321 ASSERT_EQ(TestBidirectionalStreamCallback::ON_SUCCEEDED, test.response_step); |
| 322 ASSERT_EQ(std::string(kHelloBodyValue, 2), test.read_data.front()); | 322 ASSERT_EQ(std::string(kHelloBodyValue, 2), test.read_data.front()); |
| 323 ASSERT_EQ(std::string(kHelloBodyValue), base::JoinString(test.read_data, "")); | 323 ASSERT_EQ(std::string(kHelloBodyValue), base::JoinString(test.read_data, "")); |
| 324 ASSERT_EQ(std::string(kHelloTrailerValue), | 324 ASSERT_EQ(std::string(kHelloTrailerValue), |
| 325 test.response_trailers[kHelloTrailerName]); | 325 test.response_trailers[kHelloTrailerName]); |
| 326 cronet_bidirectional_stream_destroy(test.stream); | 326 cronet_bidirectional_stream_destroy(test.stream); |
| 327 } | 327 } |
| 328 | 328 |
| 329 TEST_P(CronetBidirectionalStreamTest, SimplePutWithEmptyWriteDataAtTheEnd) { | |
| 330 TestBidirectionalStreamCallback test; | |
| 331 test.AddWriteData("Hello, "); | |
| 332 test.AddWriteData("world!"); | |
| 333 test.AddWriteData(""); | |
| 334 test.read_buffer_size = 2; | |
|
xunjieli
2016/07/25 18:36:43
Could you add a comment on why we are using a read
mef
2016/07/26 19:26:24
Done. I've added comment to StartExampleBidiStream
| |
| 335 test.stream = | |
| 336 cronet_bidirectional_stream_create(engine(), &test, test.callback()); | |
| 337 DCHECK(test.stream); | |
| 338 cronet_bidirectional_stream_delay_request_headers_until_flush(test.stream, | |
| 339 GetParam()); | |
| 340 cronet_bidirectional_stream_start(test.stream, kTestServerUrl, 0, "PUT", | |
| 341 &kTestHeadersArray, false); | |
| 342 test.BlockForDone(); | |
| 343 ASSERT_EQ(std::string(kHelloStatus), test.response_headers[kStatusHeader]); | |
| 344 ASSERT_EQ(std::string(kHelloHeaderValue), | |
| 345 test.response_headers[kHelloHeaderName]); | |
| 346 ASSERT_EQ(TestBidirectionalStreamCallback::ON_SUCCEEDED, test.response_step); | |
| 347 ASSERT_EQ(std::string(kHelloBodyValue, 2), test.read_data.front()); | |
| 348 ASSERT_EQ(std::string(kHelloBodyValue), base::JoinString(test.read_data, "")); | |
|
xunjieli
2016/07/25 18:36:43
Why do we need a concatenation of test.read_data w
mef
2016/07/26 19:26:24
The empty string is a separator between elements b
| |
| 349 ASSERT_EQ(std::string(kHelloTrailerValue), | |
| 350 test.response_trailers[kHelloTrailerName]); | |
| 351 cronet_bidirectional_stream_destroy(test.stream); | |
| 352 } | |
| 353 | |
| 329 TEST_P(CronetBidirectionalStreamTest, SimpleGetWithFlush) { | 354 TEST_P(CronetBidirectionalStreamTest, SimpleGetWithFlush) { |
| 330 TestBidirectionalStreamCallback test; | 355 TestBidirectionalStreamCallback test; |
| 331 test.stream = | 356 test.stream = |
| 332 cronet_bidirectional_stream_create(engine(), &test, test.callback()); | 357 cronet_bidirectional_stream_create(engine(), &test, test.callback()); |
| 333 DCHECK(test.stream); | 358 DCHECK(test.stream); |
| 334 cronet_bidirectional_stream_disable_auto_flush(test.stream, true); | 359 cronet_bidirectional_stream_disable_auto_flush(test.stream, true); |
| 335 cronet_bidirectional_stream_delay_request_headers_until_flush(test.stream, | 360 cronet_bidirectional_stream_delay_request_headers_until_flush(test.stream, |
| 336 GetParam()); | 361 GetParam()); |
| 337 // Flush before start is ignored. | 362 // Flush before start is ignored. |
| 338 cronet_bidirectional_stream_flush(test.stream); | 363 cronet_bidirectional_stream_flush(test.stream); |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 650 ASSERT_EQ(TestBidirectionalStreamCallback::ON_FAILED, test.response_step); | 675 ASSERT_EQ(TestBidirectionalStreamCallback::ON_FAILED, test.response_step); |
| 651 ASSERT_EQ(net::ERR_NAME_NOT_RESOLVED, test.net_error); | 676 ASSERT_EQ(net::ERR_NAME_NOT_RESOLVED, test.net_error); |
| 652 cronet_bidirectional_stream_destroy(test.stream); | 677 cronet_bidirectional_stream_destroy(test.stream); |
| 653 } | 678 } |
| 654 | 679 |
| 655 INSTANTIATE_TEST_CASE_P(CronetBidirectionalStreamDelayRequestHeadersUntilFlush, | 680 INSTANTIATE_TEST_CASE_P(CronetBidirectionalStreamDelayRequestHeadersUntilFlush, |
| 656 CronetBidirectionalStreamTest, | 681 CronetBidirectionalStreamTest, |
| 657 ::testing::Values(true, false)); | 682 ::testing::Values(true, false)); |
| 658 | 683 |
| 659 } // namespace cronet | 684 } // namespace cronet |
| OLD | NEW |