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

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

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « net/websockets/websocket_end_to_end_test.cc ('k') | sandbox/linux/BUILD.gn » ('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 #include "net/websockets/websocket_stream.h" 5 #include "net/websockets/websocket_stream.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 scoped_ptr<base::HistogramSamples> samples(GetSamples(name)); 1381 scoped_ptr<base::HistogramSamples> samples(GetSamples(name));
1382 ASSERT_TRUE(samples); 1382 ASSERT_TRUE(samples);
1383 if (original) { 1383 if (original) {
1384 samples->Subtract(*original); // Cancel the original values. 1384 samples->Subtract(*original); // Cancel the original values.
1385 } 1385 }
1386 EXPECT_EQ(1, samples->GetCount(INCOMPLETE)); 1386 EXPECT_EQ(1, samples->GetCount(INCOMPLETE));
1387 EXPECT_EQ(0, samples->GetCount(CONNECTED)); 1387 EXPECT_EQ(0, samples->GetCount(CONNECTED));
1388 EXPECT_EQ(0, samples->GetCount(FAILED)); 1388 EXPECT_EQ(0, samples->GetCount(FAILED));
1389 } 1389 }
1390 1390
1391 TEST_F(WebSocketStreamCreateTest, HandleErrConnectionClosed) {
1392 static const char kTruncatedResponse[] =
1393 "HTTP/1.1 101 Switching Protocols\r\n"
1394 "Upgrade: websocket\r\n"
1395 "Connection: Upgrade\r\n"
1396 "Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n"
1397 "Cache-Control: no-sto";
1398
1399 std::string request =
1400 WebSocketStandardRequest("/", "localhost", "http://localhost", "");
1401 MockRead reads[] = {
1402 MockRead(SYNCHRONOUS, 1, kTruncatedResponse),
1403 MockRead(SYNCHRONOUS, ERR_CONNECTION_CLOSED, 2),
1404 };
1405 MockWrite writes[] = {MockWrite(SYNCHRONOUS, 0, request.c_str())};
1406 scoped_ptr<DeterministicSocketData> socket_data(
1407 BuildSocketData(reads, writes));
1408 socket_data->set_connect_data(MockConnect(SYNCHRONOUS, OK));
1409 CreateAndConnectRawExpectations("ws://localhost/", NoSubProtocols(),
1410 "http://localhost", socket_data.Pass());
1411 RunUntilIdle();
1412 EXPECT_TRUE(has_failed());
1413 }
1414
1391 } // namespace 1415 } // namespace
1392 } // namespace net 1416 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_end_to_end_test.cc ('k') | sandbox/linux/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698