| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 void VerifySourceContents(const char* expected_data, | 99 void VerifySourceContents(const char* expected_data, |
| 100 size_t expected_length = SIZE_UNKNOWN); | 100 size_t expected_length = SIZE_UNKNOWN); |
| 101 | 101 |
| 102 void VerifyTransferComplete(HttpMode mode, HttpError error); | 102 void VerifyTransferComplete(HttpMode mode, HttpError error); |
| 103 | 103 |
| 104 HttpBase base; | 104 HttpBase base; |
| 105 MemoryStream* mem; | 105 MemoryStream* mem; |
| 106 HttpResponseData data; | 106 HttpResponseData data; |
| 107 | 107 |
| 108 // The source of http data, and source events | 108 // The source of http data, and source events |
| 109 testing::StreamSource src; | 109 webrtc::testing::StreamSource src; |
| 110 std::vector<Event> events; | 110 std::vector<Event> events; |
| 111 | 111 |
| 112 // Document stream, and stream events | 112 // Document stream, and stream events |
| 113 bool obtain_stream; | 113 bool obtain_stream; |
| 114 StreamInterface* http_stream; | 114 StreamInterface* http_stream; |
| 115 testing::StreamSink sink; | 115 webrtc::testing::StreamSink sink; |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 void HttpBaseTest::SetupSource(const char* http_data) { | 118 void HttpBaseTest::SetupSource(const char* http_data) { |
| 119 LOG_F(LS_VERBOSE) << "Enter"; | 119 LOG_F(LS_VERBOSE) << "Enter"; |
| 120 | 120 |
| 121 src.SetState(SS_OPENING); | 121 src.SetState(SS_OPENING); |
| 122 src.QueueString(http_data); | 122 src.QueueString(http_data); |
| 123 | 123 |
| 124 base.notify(this); | 124 base.notify(this); |
| 125 base.attach(&src); | 125 base.attach(&src); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 base.recv(&data); | 501 base.recv(&data); |
| 502 | 502 |
| 503 // Pull document data | 503 // Pull document data |
| 504 VerifyDocumentStreamOpenEvent(); | 504 VerifyDocumentStreamOpenEvent(); |
| 505 ReadDocumentStreamData("Goodbye!"); | 505 ReadDocumentStreamData("Goodbye!"); |
| 506 | 506 |
| 507 // Simulate unexpected close | 507 // Simulate unexpected close |
| 508 src.SetState(SS_CLOSED); | 508 src.SetState(SS_CLOSED); |
| 509 | 509 |
| 510 // Observe error event on document stream | 510 // Observe error event on document stream |
| 511 EXPECT_EQ(testing::SSE_ERROR, sink.Events(http_stream)); | 511 EXPECT_EQ(webrtc::testing::SSE_ERROR, sink.Events(http_stream)); |
| 512 | 512 |
| 513 // Future reads give an error | 513 // Future reads give an error |
| 514 int error = 0; | 514 int error = 0; |
| 515 char buffer[5] = { 0 }; | 515 char buffer[5] = { 0 }; |
| 516 EXPECT_EQ(SR_ERROR, | 516 EXPECT_EQ(SR_ERROR, |
| 517 http_stream->Read(buffer, sizeof(buffer), nullptr, &error)); | 517 http_stream->Read(buffer, sizeof(buffer), nullptr, &error)); |
| 518 EXPECT_EQ(HE_DISCONNECTED, error); | 518 EXPECT_EQ(HE_DISCONNECTED, error); |
| 519 | 519 |
| 520 // Document completed with error | 520 // Document completed with error |
| 521 VerifyHeaderComplete(2, false); | 521 VerifyHeaderComplete(2, false); |
| 522 VerifyTransferComplete(HM_RECV, HE_DISCONNECTED); | 522 VerifyTransferComplete(HM_RECV, HE_DISCONNECTED); |
| 523 VerifyDocumentContents(""); | 523 VerifyDocumentContents(""); |
| 524 } | 524 } |
| 525 | 525 |
| 526 } // namespace rtc | 526 } // namespace rtc |
| OLD | NEW |