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

Side by Side Diff: Source/modules/websockets/WebSocketPerMessageDeflateTest.cpp

Issue 314043002: [WebSocket] Add tests for permessage deflate split frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 EXPECT_TRUE(f2.final); 285 EXPECT_TRUE(f2.final);
286 286
287 c.resetInflateBuffer(); 287 c.resetInflateBuffer();
288 ASSERT_TRUE(c.inflate(f3)); 288 ASSERT_TRUE(c.inflate(f3));
289 EXPECT_EQ(5u, f3.payloadLength); 289 EXPECT_EQ(5u, f3.payloadLength);
290 EXPECT_EQ(std::string("Hello"), std::string(f3.payload, f3.payloadLength)); 290 EXPECT_EQ(std::string("Hello"), std::string(f3.payload, f3.payloadLength));
291 EXPECT_FALSE(f3.compress); 291 EXPECT_FALSE(f3.compress);
292 EXPECT_TRUE(f3.final); 292 EXPECT_TRUE(f3.final);
293 } 293 }
294 294
295 TEST(WebSocketPerMessageDeflateTest, TestInflateMultipleBlocksOverMultipleFrames )
296 {
297 WebSocketPerMessageDeflate c;
298 c.enable(8, WebSocketDeflater::TakeOverContext);
299 WebSocketFrame::OpCode opcode = WebSocketFrame::OpCodeText;
300 WebSocketFrame::OpCode continuation = WebSocketFrame::OpCodeContinuation;
301 std::string expected = "HelloHello";
302 std::string actual;
303 WebSocketFrame f1(opcode, "\xf2\x48\xcd\xc9\xc9\x07\x00\x00\x00\xff\xff", 11 , WebSocketFrame::Compress);
304 WebSocketFrame f2(continuation, "\xf2\x00\x11\x00\x00", 5, WebSocketFrame::F inal);
305
306 ASSERT_TRUE(c.inflate(f1));
307 EXPECT_FALSE(f1.compress);
308 EXPECT_FALSE(f1.final);
309 actual += std::string(f1.payload, f1.payloadLength);
310
311 c.resetInflateBuffer();
312 ASSERT_TRUE(c.inflate(f2));
313 EXPECT_FALSE(f2.compress);
314 EXPECT_TRUE(f2.final);
315 actual += std::string(f2.payload, f2.payloadLength);
316
317 EXPECT_EQ(expected, actual);
318 }
319
295 TEST(WebSocketPerMessageDeflateTest, TestInflateEmptyFrame) 320 TEST(WebSocketPerMessageDeflateTest, TestInflateEmptyFrame)
296 { 321 {
297 WebSocketPerMessageDeflate c; 322 WebSocketPerMessageDeflate c;
298 c.enable(8, WebSocketDeflater::TakeOverContext); 323 c.enable(8, WebSocketDeflater::TakeOverContext);
299 WebSocketFrame::OpCode opcode = WebSocketFrame::OpCodeText; 324 WebSocketFrame::OpCode opcode = WebSocketFrame::OpCodeText;
300 WebSocketFrame::OpCode continuation = WebSocketFrame::OpCodeContinuation; 325 WebSocketFrame::OpCode continuation = WebSocketFrame::OpCodeContinuation;
301 WebSocketFrame f1(opcode, "", 0, WebSocketFrame::Compress); 326 WebSocketFrame f1(opcode, "", 0, WebSocketFrame::Compress);
302 WebSocketFrame f2(continuation, "\xf2\x48\xcd\xc9\xc9\x07\x00", 7, WebSocket Frame::Final); 327 WebSocketFrame f2(continuation, "\xf2\x48\xcd\xc9\xc9\x07\x00", 7, WebSocket Frame::Final);
303 328
304 ASSERT_TRUE(c.inflate(f1)); 329 ASSERT_TRUE(c.inflate(f1));
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 EXPECT_FALSE(processResponse(params)); 503 EXPECT_FALSE(processResponse(params));
479 } 504 }
480 } 505 }
481 506
482 TEST(WebSocketPerMessageDeflateTest, TestNegotiationRequest) 507 TEST(WebSocketPerMessageDeflateTest, TestNegotiationRequest)
483 { 508 {
484 String actual = WebSocketPerMessageDeflate().createExtensionProcessor()->han dshakeString(); 509 String actual = WebSocketPerMessageDeflate().createExtensionProcessor()->han dshakeString();
485 EXPECT_EQ(String("permessage-deflate; client_max_window_bits"), actual); 510 EXPECT_EQ(String("permessage-deflate; client_max_window_bits"), actual);
486 } 511 }
487 } // namespace 512 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698