OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // Tests for WebSocketBasicStream. Note that we do not attempt to verify that | 5 // Tests for WebSocketBasicStream. Note that we do not attempt to verify that |
6 // frame parsing itself functions correctly, as that is covered by the | 6 // frame parsing itself functions correctly, as that is covered by the |
7 // WebSocketFrameParser tests. | 7 // WebSocketFrameParser tests. |
8 | 8 |
9 #include "net/websockets/websocket_basic_stream.h" | 9 #include "net/websockets/websocket_basic_stream.h" |
10 | 10 |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 EXPECT_EQ(OK, cb_.WaitForResult()); | 788 EXPECT_EQ(OK, cb_.WaitForResult()); |
789 ASSERT_EQ(1U, frames_.size()); | 789 ASSERT_EQ(1U, frames_.size()); |
790 EXPECT_EQ(WebSocketFrameHeader::kOpCodeClose, frames_[0]->header.opcode); | 790 EXPECT_EQ(WebSocketFrameHeader::kOpCodeClose, frames_[0]->header.opcode); |
791 } | 791 } |
792 | 792 |
793 // A frame with a 1MB payload that has to be read in chunks. | 793 // A frame with a 1MB payload that has to be read in chunks. |
794 TEST_F(WebSocketBasicStreamSocketChunkedReadTest, OneMegFrame) { | 794 TEST_F(WebSocketBasicStreamSocketChunkedReadTest, OneMegFrame) { |
795 // This should be equal to the definition of kReadBufferSize in | 795 // This should be equal to the definition of kReadBufferSize in |
796 // websocket_basic_stream.cc. | 796 // websocket_basic_stream.cc. |
797 const int kReadBufferSize = 32 * 1024; | 797 const int kReadBufferSize = 32 * 1024; |
798 const uint64 kPayloadSize = 1 << 20; | 798 const uint64_t kPayloadSize = 1 << 20; |
799 const size_t kWireSize = kPayloadSize + kLargeFrameHeaderSize; | 799 const size_t kWireSize = kPayloadSize + kLargeFrameHeaderSize; |
800 const size_t kExpectedFrameCount = | 800 const size_t kExpectedFrameCount = |
801 (kWireSize + kReadBufferSize - 1) / kReadBufferSize; | 801 (kWireSize + kReadBufferSize - 1) / kReadBufferSize; |
802 scoped_ptr<char[]> big_frame(new char[kWireSize]); | 802 scoped_ptr<char[]> big_frame(new char[kWireSize]); |
803 memcpy(big_frame.get(), "\x81\x7F", 2); | 803 memcpy(big_frame.get(), "\x81\x7F", 2); |
804 base::WriteBigEndian(big_frame.get() + 2, kPayloadSize); | 804 base::WriteBigEndian(big_frame.get() + 2, kPayloadSize); |
805 memset(big_frame.get() + kLargeFrameHeaderSize, 'A', kPayloadSize); | 805 memset(big_frame.get() + kLargeFrameHeaderSize, 'A', kPayloadSize); |
806 | 806 |
807 CreateChunkedRead(ASYNC, | 807 CreateChunkedRead(ASYNC, |
808 big_frame.get(), | 808 big_frame.get(), |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 | 934 |
935 TEST_F(WebSocketBasicStreamSocketTest, GetSubProtocolWorks) { | 935 TEST_F(WebSocketBasicStreamSocketTest, GetSubProtocolWorks) { |
936 sub_protocol_ = "cyberchat"; | 936 sub_protocol_ = "cyberchat"; |
937 CreateNullStream(); | 937 CreateNullStream(); |
938 | 938 |
939 EXPECT_EQ("cyberchat", stream_->GetSubProtocol()); | 939 EXPECT_EQ("cyberchat", stream_->GetSubProtocol()); |
940 } | 940 } |
941 | 941 |
942 } // namespace | 942 } // namespace |
943 } // namespace net | 943 } // namespace net |
OLD | NEW |