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

Side by Side Diff: net/server/web_socket_encoder_unittest.cc

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years 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/server/web_socket_encoder.cc ('k') | net/socket/client_socket_factory.h » ('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 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
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
OLDNEW
« no previous file with comments | « net/server/web_socket_encoder.cc ('k') | net/socket/client_socket_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698