| OLD | NEW |
| 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 "net/server/web_socket_encoder.h" | 5 #include "net/server/web_socket_encoder.h" |
| 6 | 6 |
| 7 #include "net/websockets/websocket_deflate_parameters.h" | 7 #include "net/websockets/websocket_deflate_parameters.h" |
| 8 #include "net/websockets/websocket_extension.h" | 8 #include "net/websockets/websocket_extension.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 TEST_F(WebSocketEncoderCompressionTest, LongFrame) { | 207 TEST_F(WebSocketEncoderCompressionTest, LongFrame) { |
| 208 int length = 1000000; | 208 int length = 1000000; |
| 209 std::string temp; | 209 std::string temp; |
| 210 temp.reserve(length); | 210 temp.reserve(length); |
| 211 for (int i = 0; i < length; ++i) | 211 for (int i = 0; i < length; ++i) |
| 212 temp += (char)('a' + (i % 26)); | 212 temp += (char)('a' + (i % 26)); |
| 213 | 213 |
| 214 std::string frame; | 214 std::string frame; |
| 215 frame.reserve(length); | 215 frame.reserve(length); |
| 216 for (int i = 0; i < length; ++i) { | 216 for (int i = 0; i < length; ++i) { |
| 217 int64 j = i; | 217 int64_t j = i; |
| 218 frame += temp.data()[(j * j) % length]; | 218 frame += temp.data()[(j * j) % length]; |
| 219 } | 219 } |
| 220 | 220 |
| 221 int mask = 0; | 221 int mask = 0; |
| 222 std::string encoded; | 222 std::string encoded; |
| 223 int bytes_consumed; | 223 int bytes_consumed; |
| 224 std::string decoded; | 224 std::string decoded; |
| 225 | 225 |
| 226 server_->EncodeFrame(frame, mask, &encoded); | 226 server_->EncodeFrame(frame, mask, &encoded); |
| 227 EXPECT_LT(encoded.length(), frame.length()); | 227 EXPECT_LT(encoded.length(), frame.length()); |
| 228 EXPECT_EQ(WebSocket::FRAME_OK, | 228 EXPECT_EQ(WebSocket::FRAME_OK, |
| 229 client_->DecodeFrame(encoded, &bytes_consumed, &decoded)); | 229 client_->DecodeFrame(encoded, &bytes_consumed, &decoded)); |
| 230 EXPECT_EQ(frame, decoded); | 230 EXPECT_EQ(frame, decoded); |
| 231 EXPECT_EQ((int)encoded.length(), bytes_consumed); | 231 EXPECT_EQ((int)encoded.length(), bytes_consumed); |
| 232 } | 232 } |
| 233 | 233 |
| 234 } // namespace net | 234 } // namespace net |
| OLD | NEW |