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 12 matching lines...) Expand all Loading... |
23 // - Non-NULL masking key | 23 // - Non-NULL masking key |
24 // - A frame larger than kReadBufferSize; | 24 // - A frame larger than kReadBufferSize; |
25 | 25 |
26 const char kSampleFrame[] = "\x81\x06Sample"; | 26 const char kSampleFrame[] = "\x81\x06Sample"; |
27 const size_t kSampleFrameSize = arraysize(kSampleFrame) - 1; | 27 const size_t kSampleFrameSize = arraysize(kSampleFrame) - 1; |
28 const char kPartialLargeFrame[] = | 28 const char kPartialLargeFrame[] = |
29 "\x81\x7F\x00\x00\x00\x00\x7F\xFF\xFF\xFF" | 29 "\x81\x7F\x00\x00\x00\x00\x7F\xFF\xFF\xFF" |
30 "chromiunum ad pasco per loca insanis pullum manducat frumenti"; | 30 "chromiunum ad pasco per loca insanis pullum manducat frumenti"; |
31 const size_t kPartialLargeFrameSize = arraysize(kPartialLargeFrame) - 1; | 31 const size_t kPartialLargeFrameSize = arraysize(kPartialLargeFrame) - 1; |
32 const size_t kLargeFrameHeaderSize = 10; | 32 const size_t kLargeFrameHeaderSize = 10; |
33 const size_t kLargeFrameDeclaredPayloadSize = 0x7FFFFFFF; | |
34 const char kMultipleFrames[] = "\x81\x01X\x81\x01Y\x81\x01Z"; | 33 const char kMultipleFrames[] = "\x81\x01X\x81\x01Y\x81\x01Z"; |
35 const size_t kMultipleFramesSize = arraysize(kMultipleFrames) - 1; | 34 const size_t kMultipleFramesSize = arraysize(kMultipleFrames) - 1; |
36 // This frame encodes a payload length of 7 in two bytes, which is always | 35 // This frame encodes a payload length of 7 in two bytes, which is always |
37 // invalid. | 36 // invalid. |
38 const char kInvalidFrame[] = "\x81\x7E\x00\x07Invalid"; | 37 const char kInvalidFrame[] = "\x81\x7E\x00\x07Invalid"; |
39 const size_t kInvalidFrameSize = arraysize(kInvalidFrame) - 1; | 38 const size_t kInvalidFrameSize = arraysize(kInvalidFrame) - 1; |
40 // Control frames must have the FIN bit set. This one does not. | 39 // Control frames must have the FIN bit set. This one does not. |
41 const char kPingFrameWithoutFin[] = "\x09\x00"; | 40 const char kPingFrameWithoutFin[] = "\x09\x00"; |
42 const size_t kPingFrameWithoutFinSize = arraysize(kPingFrameWithoutFin) - 1; | 41 const size_t kPingFrameWithoutFinSize = arraysize(kPingFrameWithoutFin) - 1; |
43 // Control frames must have a payload of 125 bytes or less. This one has | 42 // Control frames must have a payload of 125 bytes or less. This one has |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 | 719 |
721 TEST_F(WebSocketBasicStreamSocketTest, GetSubProtocolWorks) { | 720 TEST_F(WebSocketBasicStreamSocketTest, GetSubProtocolWorks) { |
722 sub_protocol_ = "cyberchat"; | 721 sub_protocol_ = "cyberchat"; |
723 CreateNullStream(); | 722 CreateNullStream(); |
724 | 723 |
725 EXPECT_EQ("cyberchat", stream_->GetSubProtocol()); | 724 EXPECT_EQ("cyberchat", stream_->GetSubProtocol()); |
726 } | 725 } |
727 | 726 |
728 } // namespace | 727 } // namespace |
729 } // namespace net | 728 } // namespace net |
OLD | NEW |