Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: net/websockets/websocket_basic_stream_test.cc

Issue 145873006: ui/base/resource: Roll our own version of ReadBigEndian() function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/net.gyp ('k') | net/websockets/websocket_channel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include <string.h> // for memcpy() and memset(). 11 #include <string.h> // for memcpy() and memset().
12 12
13 #include <string> 13 #include <string>
14 14
15 #include "base/basictypes.h" 15 #include "base/basictypes.h"
16 #include "base/big_endian.h"
16 #include "base/port.h" 17 #include "base/port.h"
17 #include "net/base/big_endian.h"
18 #include "net/base/capturing_net_log.h" 18 #include "net/base/capturing_net_log.h"
19 #include "net/base/test_completion_callback.h" 19 #include "net/base/test_completion_callback.h"
20 #include "net/socket/socket_test_util.h" 20 #include "net/socket/socket_test_util.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 namespace net { 23 namespace net {
24 namespace { 24 namespace {
25 25
26 #define WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(name, value) \ 26 #define WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(name, value) \
27 const char k##name[] = value; \ 27 const char k##name[] = value; \
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 TEST_F(WebSocketBasicStreamSocketChunkedReadTest, OneMegFrame) { 796 TEST_F(WebSocketBasicStreamSocketChunkedReadTest, OneMegFrame) {
797 // This should be equal to the definition of kReadBufferSize in 797 // This should be equal to the definition of kReadBufferSize in
798 // websocket_basic_stream.cc. 798 // websocket_basic_stream.cc.
799 const int kReadBufferSize = 32 * 1024; 799 const int kReadBufferSize = 32 * 1024;
800 const uint64 kPayloadSize = 1 << 20; 800 const uint64 kPayloadSize = 1 << 20;
801 const size_t kWireSize = kPayloadSize + kLargeFrameHeaderSize; 801 const size_t kWireSize = kPayloadSize + kLargeFrameHeaderSize;
802 const size_t kExpectedFrameCount = 802 const size_t kExpectedFrameCount =
803 (kWireSize + kReadBufferSize - 1) / kReadBufferSize; 803 (kWireSize + kReadBufferSize - 1) / kReadBufferSize;
804 scoped_ptr<char[]> big_frame(new char[kWireSize]); 804 scoped_ptr<char[]> big_frame(new char[kWireSize]);
805 memcpy(big_frame.get(), "\x81\x7F", 2); 805 memcpy(big_frame.get(), "\x81\x7F", 2);
806 WriteBigEndian(big_frame.get() + 2, kPayloadSize); 806 base::WriteBigEndian(big_frame.get() + 2, kPayloadSize);
807 memset(big_frame.get() + kLargeFrameHeaderSize, 'A', kPayloadSize); 807 memset(big_frame.get() + kLargeFrameHeaderSize, 'A', kPayloadSize);
808 808
809 CreateChunkedRead(ASYNC, 809 CreateChunkedRead(ASYNC,
810 big_frame.get(), 810 big_frame.get(),
811 kWireSize, 811 kWireSize,
812 kReadBufferSize, 812 kReadBufferSize,
813 kExpectedFrameCount, 813 kExpectedFrameCount,
814 LAST_FRAME_BIG); 814 LAST_FRAME_BIG);
815 815
816 for (size_t frame = 0; frame < kExpectedFrameCount; ++frame) { 816 for (size_t frame = 0; frame < kExpectedFrameCount; ++frame) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 936
937 TEST_F(WebSocketBasicStreamSocketTest, GetSubProtocolWorks) { 937 TEST_F(WebSocketBasicStreamSocketTest, GetSubProtocolWorks) {
938 sub_protocol_ = "cyberchat"; 938 sub_protocol_ = "cyberchat";
939 CreateNullStream(); 939 CreateNullStream();
940 940
941 EXPECT_EQ("cyberchat", stream_->GetSubProtocol()); 941 EXPECT_EQ("cyberchat", stream_->GetSubProtocol());
942 } 942 }
943 943
944 } // namespace 944 } // namespace
945 } // namespace net 945 } // namespace net
OLDNEW
« no previous file with comments | « net/net.gyp ('k') | net/websockets/websocket_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698