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

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

Issue 474973004: Remove implicit conversions from scoped_refptr to T* in net/websockets/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
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
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 } 632 }
633 633
634 // If there was a frame read at the same time as the response headers (and the 634 // If there was a frame read at the same time as the response headers (and the
635 // handshake succeeded), then we should parse it. 635 // handshake succeeded), then we should parse it.
636 TEST_F(WebSocketBasicStreamSocketTest, HttpReadBufferIsUsed) { 636 TEST_F(WebSocketBasicStreamSocketTest, HttpReadBufferIsUsed) {
637 SetHttpReadBuffer(kSampleFrame, kSampleFrameSize); 637 SetHttpReadBuffer(kSampleFrame, kSampleFrameSize);
638 CreateNullStream(); 638 CreateNullStream();
639 639
640 EXPECT_EQ(OK, stream_->ReadFrames(&frames_, cb_.callback())); 640 EXPECT_EQ(OK, stream_->ReadFrames(&frames_, cb_.callback()));
641 ASSERT_EQ(1U, frames_.size()); 641 ASSERT_EQ(1U, frames_.size());
642 ASSERT_TRUE(frames_[0]->data); 642 ASSERT_TRUE(frames_[0]->data.get());
643 EXPECT_EQ(GG_UINT64_C(6), frames_[0]->header.payload_length); 643 EXPECT_EQ(GG_UINT64_C(6), frames_[0]->header.payload_length);
644 } 644 }
645 645
646 // Check that a frame whose header partially arrived at the end of the response 646 // Check that a frame whose header partially arrived at the end of the response
647 // headers works correctly. 647 // headers works correctly.
648 TEST_F(WebSocketBasicStreamSocketSingleReadTest, 648 TEST_F(WebSocketBasicStreamSocketSingleReadTest,
649 PartialFrameHeaderInHttpResponse) { 649 PartialFrameHeaderInHttpResponse) {
650 SetHttpReadBuffer(kSampleFrame, 1); 650 SetHttpReadBuffer(kSampleFrame, 1);
651 CreateRead(MockRead(ASYNC, kSampleFrame + 1, kSampleFrameSize - 1)); 651 CreateRead(MockRead(ASYNC, kSampleFrame + 1, kSampleFrameSize - 1));
652 652
653 ASSERT_EQ(ERR_IO_PENDING, stream_->ReadFrames(&frames_, cb_.callback())); 653 ASSERT_EQ(ERR_IO_PENDING, stream_->ReadFrames(&frames_, cb_.callback()));
654 EXPECT_EQ(OK, cb_.WaitForResult()); 654 EXPECT_EQ(OK, cb_.WaitForResult());
655 ASSERT_EQ(1U, frames_.size()); 655 ASSERT_EQ(1U, frames_.size());
656 ASSERT_TRUE(frames_[0]->data); 656 ASSERT_TRUE(frames_[0]->data.get());
657 EXPECT_EQ(GG_UINT64_C(6), frames_[0]->header.payload_length); 657 EXPECT_EQ(GG_UINT64_C(6), frames_[0]->header.payload_length);
658 EXPECT_EQ(WebSocketFrameHeader::kOpCodeText, frames_[0]->header.opcode); 658 EXPECT_EQ(WebSocketFrameHeader::kOpCodeText, frames_[0]->header.opcode);
659 } 659 }
660 660
661 // Check that a control frame which partially arrives at the end of the response 661 // Check that a control frame which partially arrives at the end of the response
662 // headers works correctly. 662 // headers works correctly.
663 TEST_F(WebSocketBasicStreamSocketSingleReadTest, 663 TEST_F(WebSocketBasicStreamSocketSingleReadTest,
664 PartialControlFrameInHttpResponse) { 664 PartialControlFrameInHttpResponse) {
665 const size_t kPartialFrameBytes = 3; 665 const size_t kPartialFrameBytes = 3;
666 SetHttpReadBuffer(kCloseFrame, kPartialFrameBytes); 666 SetHttpReadBuffer(kCloseFrame, kPartialFrameBytes);
(...skipping 269 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

Powered by Google App Engine
This is Rietveld 408576698