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

Side by Side Diff: third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannelTest.cpp

Issue 2003253002: [Devtools] Allow User-Agent header override for Websockets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "modules/websockets/WebSocketChannel.h" 5 #include "modules/websockets/WebSocketChannel.h"
6 6
7 #include "core/dom/DOMArrayBuffer.h" 7 #include "core/dom/DOMArrayBuffer.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/fileapi/Blob.h" 9 #include "core/fileapi/Blob.h"
10 #include "core/testing/DummyPageHolder.h" 10 #include "core/testing/DummyPageHolder.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 public: 73 public:
74 static MockWebSocketHandle* create() 74 static MockWebSocketHandle* create()
75 { 75 {
76 return new testing::StrictMock<MockWebSocketHandle>(); 76 return new testing::StrictMock<MockWebSocketHandle>();
77 } 77 }
78 78
79 MockWebSocketHandle() { } 79 MockWebSocketHandle() { }
80 80
81 ~MockWebSocketHandle() override { } 81 ~MockWebSocketHandle() override { }
82 82
83 MOCK_METHOD4(connect, void(const WebURL&, const WebVector<WebString>&, const WebSecurityOrigin&, WebSocketHandleClient*)); 83 MOCK_METHOD5(connect, void(const WebURL&, const WebVector<WebString>&, const WebSecurityOrigin&, const WebString&, WebSocketHandleClient*));
84 MOCK_METHOD4(send, void(bool, WebSocketHandle::MessageType, const char*, siz e_t)); 84 MOCK_METHOD4(send, void(bool, WebSocketHandle::MessageType, const char*, siz e_t));
85 MOCK_METHOD1(flowControl, void(int64_t)); 85 MOCK_METHOD1(flowControl, void(int64_t));
86 MOCK_METHOD2(close, void(unsigned short, const WebString&)); 86 MOCK_METHOD2(close, void(unsigned short, const WebString&));
87 }; 87 };
88 88
89 class DocumentWebSocketChannelTest : public ::testing::Test { 89 class DocumentWebSocketChannelTest : public ::testing::Test {
90 public: 90 public:
91 DocumentWebSocketChannelTest() 91 DocumentWebSocketChannelTest()
92 : m_pageHolder(DummyPageHolder::create()) 92 : m_pageHolder(DummyPageHolder::create())
93 , m_channelClient(MockWebSocketChannelClient::create()) 93 , m_channelClient(MockWebSocketChannelClient::create())
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 void didConsumeBufferedAmount(unsigned long a) 126 void didConsumeBufferedAmount(unsigned long a)
127 { 127 {
128 m_sumOfConsumedBufferedAmount += a; 128 m_sumOfConsumedBufferedAmount += a;
129 } 129 }
130 130
131 void connect() 131 void connect()
132 { 132 {
133 { 133 {
134 InSequence s; 134 InSequence s;
135 EXPECT_CALL(*handle(), connect(WebURL(KURL(KURL(), "ws://localhost/" )), _, _, handleClient())); 135 EXPECT_CALL(*handle(), connect(WebURL(KURL(KURL(), "ws://localhost/" )), _, _, _, handleClient()));
136 EXPECT_CALL(*handle(), flowControl(65536)); 136 EXPECT_CALL(*handle(), flowControl(65536));
137 EXPECT_CALL(*channelClient(), didConnect(String("a"), String("b"))); 137 EXPECT_CALL(*channelClient(), didConnect(String("a"), String("b")));
138 } 138 }
139 EXPECT_TRUE(channel()->connect(KURL(KURL(), "ws://localhost/"), "x")); 139 EXPECT_TRUE(channel()->connect(KURL(KURL(), "ws://localhost/"), "x"));
140 handleClient()->didConnect(handle(), WebString("a"), WebString("b")); 140 handleClient()->didConnect(handle(), WebString("a"), WebString("b"));
141 ::testing::Mock::VerifyAndClearExpectations(this); 141 ::testing::Mock::VerifyAndClearExpectations(this);
142 } 142 }
143 143
144 OwnPtr<DummyPageHolder> m_pageHolder; 144 OwnPtr<DummyPageHolder> m_pageHolder;
145 Persistent<MockWebSocketChannelClient> m_channelClient; 145 Persistent<MockWebSocketChannelClient> m_channelClient;
(...skipping 10 matching lines...) Expand all
156 ) 156 )
157 { 157 {
158 return memcmp(arg, p, len) == 0; 158 return memcmp(arg, p, len) == 0;
159 } 159 }
160 160
161 TEST_F(DocumentWebSocketChannelTest, connectSuccess) 161 TEST_F(DocumentWebSocketChannelTest, connectSuccess)
162 { 162 {
163 Checkpoint checkpoint; 163 Checkpoint checkpoint;
164 { 164 {
165 InSequence s; 165 InSequence s;
166 EXPECT_CALL(*handle(), connect(WebURL(KURL(KURL(), "ws://localhost/")), _, _, handleClient())); 166 EXPECT_CALL(*handle(), connect(WebURL(KURL(KURL(), "ws://localhost/")), _, _, _, handleClient()));
167 EXPECT_CALL(*handle(), flowControl(65536)); 167 EXPECT_CALL(*handle(), flowControl(65536));
168 EXPECT_CALL(checkpoint, Call(1)); 168 EXPECT_CALL(checkpoint, Call(1));
169 EXPECT_CALL(*channelClient(), didConnect(String("a"), String("b"))); 169 EXPECT_CALL(*channelClient(), didConnect(String("a"), String("b")));
170 } 170 }
171 171
172 EXPECT_TRUE(channel()->connect(KURL(KURL(), "ws://localhost/"), "x")); 172 EXPECT_TRUE(channel()->connect(KURL(KURL(), "ws://localhost/"), "x"));
173 checkpoint.Call(1); 173 checkpoint.Call(1);
174 handleClient()->didConnect(handle(), WebString("a"), WebString("b")); 174 handleClient()->didConnect(handle(), WebString("a"), WebString("b"));
175 } 175 }
176 176
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 EXPECT_CALL(*channelClient(), didError()); 679 EXPECT_CALL(*channelClient(), didError());
680 EXPECT_CALL(*channelClient(), didClose(WebSocketChannelClient::ClosingHa ndshakeIncomplete, WebSocketChannel::CloseEventCodeAbnormalClosure, String())); 680 EXPECT_CALL(*channelClient(), didClose(WebSocketChannelClient::ClosingHa ndshakeIncomplete, WebSocketChannel::CloseEventCodeAbnormalClosure, String()));
681 } 681 }
682 682
683 channel()->fail("fail message from WebSocket", ErrorMessageLevel, nullptr); 683 channel()->fail("fail message from WebSocket", ErrorMessageLevel, nullptr);
684 } 684 }
685 685
686 } // namespace 686 } // namespace
687 687
688 } // namespace blink 688 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698