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 #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 Loading... |
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 |
OLD | NEW |