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

Side by Side Diff: net/spdy/spdy_framer_test.cc

Issue 2079313002: Revert of Update Zlib to version 1.2.8 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « AUTHORS ('k') | net/spdy/spdy_session_unittest.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/spdy/spdy_framer.h" 5 #include "net/spdy/spdy_framer.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 syn_stream.SetHeader("content-type", "text/html"); 1465 syn_stream.SetHeader("content-type", "text/html");
1466 syn_stream.SetHeader("content-length", "12"); 1466 syn_stream.SetHeader("content-length", "12");
1467 SpdySerializedFrame frame1(framer.SerializeSynStream(syn_stream)); 1467 SpdySerializedFrame frame1(framer.SerializeSynStream(syn_stream));
1468 size_t uncompressed_size1 = visitor->last_payload_len_; 1468 size_t uncompressed_size1 = visitor->last_payload_len_;
1469 size_t compressed_size1 = 1469 size_t compressed_size1 =
1470 visitor->last_frame_len_ - framer.GetSynStreamMinimumSize(); 1470 visitor->last_frame_len_ - framer.GetSynStreamMinimumSize();
1471 EXPECT_EQ(165u, uncompressed_size1); 1471 EXPECT_EQ(165u, uncompressed_size1);
1472 #if defined(USE_SYSTEM_ZLIB) 1472 #if defined(USE_SYSTEM_ZLIB)
1473 EXPECT_EQ(181u, compressed_size1); 1473 EXPECT_EQ(181u, compressed_size1);
1474 #else // !defined(USE_SYSTEM_ZLIB) 1474 #else // !defined(USE_SYSTEM_ZLIB)
1475 EXPECT_EQ(116u, compressed_size1); 1475 EXPECT_EQ(117u, compressed_size1);
1476 #endif // !defined(USE_SYSTEM_ZLIB) 1476 #endif // !defined(USE_SYSTEM_ZLIB)
1477 SpdySerializedFrame frame2(framer.SerializeSynStream(syn_stream)); 1477 SpdySerializedFrame frame2(framer.SerializeSynStream(syn_stream));
1478 size_t uncompressed_size2 = visitor->last_payload_len_; 1478 size_t uncompressed_size2 = visitor->last_payload_len_;
1479 size_t compressed_size2 = 1479 size_t compressed_size2 =
1480 visitor->last_frame_len_ - framer.GetSynStreamMinimumSize(); 1480 visitor->last_frame_len_ - framer.GetSynStreamMinimumSize();
1481 1481
1482 // Expect the second frame to be more compact than the first. 1482 // Expect the second frame to be more compact than the first.
1483 EXPECT_LE(frame2.size(), frame1.size()); 1483 EXPECT_LE(frame2.size(), frame1.size());
1484 1484
1485 // Decompress the first frame 1485 // Decompress the first frame
1486 SpdySerializedFrame frame3( 1486 SpdySerializedFrame frame3(
1487 SpdyFramerTestUtil::DecompressFrame(&framer, frame1)); 1487 SpdyFramerTestUtil::DecompressFrame(&framer, frame1));
1488 1488
1489 // Decompress the second frame 1489 // Decompress the second frame
1490 visitor.reset(new TestSpdyVisitor(spdy_version_)); 1490 visitor.reset(new TestSpdyVisitor(spdy_version_));
1491 framer.set_debug_visitor(visitor.get()); 1491 framer.set_debug_visitor(visitor.get());
1492 SpdySerializedFrame frame4( 1492 SpdySerializedFrame frame4(
1493 SpdyFramerTestUtil::DecompressFrame(&framer, frame2)); 1493 SpdyFramerTestUtil::DecompressFrame(&framer, frame2));
1494 size_t uncompressed_size4 = frame4.size() - framer.GetSynStreamMinimumSize(); 1494 size_t uncompressed_size4 = frame4.size() - framer.GetSynStreamMinimumSize();
1495 size_t compressed_size4 = 1495 size_t compressed_size4 =
1496 visitor->last_frame_len_ - framer.GetSynStreamMinimumSize(); 1496 visitor->last_frame_len_ - framer.GetSynStreamMinimumSize();
1497 EXPECT_EQ(165u, uncompressed_size4); 1497 EXPECT_EQ(165u, uncompressed_size4);
1498 #if defined(USE_SYSTEM_ZLIB) 1498 #if defined(USE_SYSTEM_ZLIB)
1499 EXPECT_EQ(175u, compressed_size4); 1499 EXPECT_EQ(175u, compressed_size4);
1500 #else // !defined(USE_SYSTEM_ZLIB) 1500 #else // !defined(USE_SYSTEM_ZLIB)
1501 EXPECT_EQ(98u, compressed_size4); 1501 EXPECT_EQ(99u, compressed_size4);
1502 #endif // !defined(USE_SYSTEM_ZLIB) 1502 #endif // !defined(USE_SYSTEM_ZLIB)
1503 1503
1504 EXPECT_EQ(uncompressed_size1, uncompressed_size2); 1504 EXPECT_EQ(uncompressed_size1, uncompressed_size2);
1505 EXPECT_EQ(uncompressed_size1, uncompressed_size4); 1505 EXPECT_EQ(uncompressed_size1, uncompressed_size4);
1506 EXPECT_EQ(compressed_size2, compressed_size4); 1506 EXPECT_EQ(compressed_size2, compressed_size4);
1507 1507
1508 // Expect frames 3 & 4 to be the same. 1508 // Expect frames 3 & 4 to be the same.
1509 CompareFrames("Uncompressed SYN_STREAM", frame3, frame4); 1509 CompareFrames("Uncompressed SYN_STREAM", frame3, frame4);
1510 1510
1511 // Expect frames 3 to be the same as a uncompressed frame created 1511 // Expect frames 3 to be the same as a uncompressed frame created
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
2423 2423
2424 SpdyFramer framer(spdy_version_); 2424 SpdyFramer framer(spdy_version_);
2425 framer.set_enable_compression(true); 2425 framer.set_enable_compression(true);
2426 2426
2427 { 2427 {
2428 const char kDescription[] = "SYN_STREAM frame, low pri, no FIN"; 2428 const char kDescription[] = "SYN_STREAM frame, low pri, no FIN";
2429 2429
2430 // clang-format off 2430 // clang-format off
2431 const unsigned char kV3FrameData[] = { 2431 const unsigned char kV3FrameData[] = {
2432 0x80, 0x03, 0x00, 0x01, 2432 0x80, 0x03, 0x00, 0x01,
2433 0x00, 0x00, 0x00, 0x36, 2433 0x00, 0x00, 0x00, 0x37,
2434 0x00, 0x00, 0x00, 0x01, 2434 0x00, 0x00, 0x00, 0x01,
2435 0x00, 0x00, 0x00, 0x00, 2435 0x00, 0x00, 0x00, 0x00,
2436 0x80, 0x00, 0x38, 0xEA, 2436 0x80, 0x00, 0x38, 0xEA,
2437 0xE3, 0xC6, 0xA7, 0xC2, 2437 0xE3, 0xC6, 0xA7, 0xC2,
2438 0x02, 0xE5, 0x0E, 0x50, 2438 0x02, 0xE5, 0x0E, 0x50,
2439 0xC2, 0x4B, 0x4A, 0x04, 2439 0xC2, 0x4B, 0x4A, 0x04,
2440 0xE5, 0x0B, 0x66, 0x80, 2440 0xE5, 0x0B, 0x66, 0x80,
2441 0x00, 0x4A, 0xCB, 0xCF, 2441 0x00, 0x4A, 0xCB, 0xCF,
2442 0x07, 0x08, 0x20, 0x10, 2442 0x07, 0x08, 0x20, 0x10,
2443 0x95, 0x96, 0x9F, 0x0F, 2443 0x95, 0x96, 0x9F, 0x0F,
2444 0xA2, 0x00, 0x02, 0x28, 2444 0xA2, 0x00, 0x02, 0x28,
2445 0x29, 0xB1, 0x08, 0x20, 2445 0x29, 0xB1, 0x08, 0x20,
2446 0x00, 0x00, 0x00, 0x00, 2446 0x80, 0x00, 0x00, 0x00,
2447 0xFF, 0xFF, 2447 0x00, 0xFF, 0xFF,
2448 }; 2448 };
2449 const unsigned char kV3SIMDFrameData[] = { 2449 const unsigned char kV3SIMDFrameData[] = {
2450 0x80, 0x03, 0x00, 0x01, 2450 0x80, 0x03, 0x00, 0x01,
2451 0x00, 0x00, 0x00, 0x31, 2451 0x00, 0x00, 0x00, 0x32,
2452 0x00, 0x00, 0x00, 0x01, 2452 0x00, 0x00, 0x00, 0x01,
2453 0x00, 0x00, 0x00, 0x00, 2453 0x00, 0x00, 0x00, 0x00,
2454 0x80, 0x00, 0x38, 0xea, 2454 0x80, 0x00, 0x38, 0xea,
2455 0xe3, 0xc6, 0xa7, 0xc2, 2455 0xe3, 0xc6, 0xa7, 0xc2,
2456 0x02, 0xe5, 0x0e, 0x50, 2456 0x02, 0xe5, 0x0e, 0x50,
2457 0xc2, 0x4b, 0x4a, 0x04, 2457 0xc2, 0x4b, 0x4a, 0x04,
2458 0xe5, 0x0b, 0x66, 0x80, 2458 0xe5, 0x0b, 0x66, 0x80,
2459 0x00, 0x4a, 0xcb, 0xcf, 2459 0x00, 0x4a, 0xcb, 0xcf,
2460 0x07, 0x08, 0x20, 0x24, 2460 0x07, 0x08, 0x20, 0x24,
2461 0x0a, 0x20, 0x80, 0x92, 2461 0x0a, 0x20, 0x80, 0x92,
2462 0x12, 0x8b, 0x00, 0x02, 2462 0x12, 0x8b, 0x00, 0x02,
2463 0x00, 0x00, 0x00, 0xff, 2463 0x08, 0x00, 0x00, 0x00,
2464 0xff, 2464 0xff, 0xff,
2465 }; 2465 };
2466 // clang-format on 2466 // clang-format on
2467 2467
2468 SpdySynStreamIR syn_stream(1); 2468 SpdySynStreamIR syn_stream(1);
2469 syn_stream.set_priority(4); 2469 syn_stream.set_priority(4);
2470 syn_stream.SetHeader("bar", "foo"); 2470 syn_stream.SetHeader("bar", "foo");
2471 syn_stream.SetHeader("foo", "bar"); 2471 syn_stream.SetHeader("foo", "bar");
2472 SpdySerializedFrame frame(framer.SerializeSynStream(syn_stream)); 2472 SpdySerializedFrame frame(framer.SerializeSynStream(syn_stream));
2473 const unsigned char* frame_data = 2473 const unsigned char* frame_data =
2474 reinterpret_cast<const unsigned char*>(frame.data()); 2474 reinterpret_cast<const unsigned char*>(frame.data());
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2595 2595
2596 SpdyFramer framer(spdy_version_); 2596 SpdyFramer framer(spdy_version_);
2597 framer.set_enable_compression(true); 2597 framer.set_enable_compression(true);
2598 2598
2599 { 2599 {
2600 const char kDescription[] = "SYN_REPLY frame, no FIN"; 2600 const char kDescription[] = "SYN_REPLY frame, no FIN";
2601 2601
2602 // clang-format off 2602 // clang-format off
2603 const unsigned char kV3FrameData[] = { 2603 const unsigned char kV3FrameData[] = {
2604 0x80, 0x03, 0x00, 0x02, 2604 0x80, 0x03, 0x00, 0x02,
2605 0x00, 0x00, 0x00, 0x30, 2605 0x00, 0x00, 0x00, 0x31,
2606 0x00, 0x00, 0x00, 0x01, 2606 0x00, 0x00, 0x00, 0x01,
2607 0x38, 0xea, 0xe3, 0xc6, 2607 0x38, 0xea, 0xe3, 0xc6,
2608 0xa7, 0xc2, 0x02, 0xe5, 2608 0xa7, 0xc2, 0x02, 0xe5,
2609 0x0e, 0x50, 0xc2, 0x4b, 2609 0x0e, 0x50, 0xc2, 0x4b,
2610 0x4a, 0x04, 0xe5, 0x0b, 2610 0x4a, 0x04, 0xe5, 0x0b,
2611 0x66, 0x80, 0x00, 0x4a, 2611 0x66, 0x80, 0x00, 0x4a,
2612 0xcb, 0xcf, 0x07, 0x08, 2612 0xcb, 0xcf, 0x07, 0x08,
2613 0x20, 0x10, 0x95, 0x96, 2613 0x20, 0x10, 0x95, 0x96,
2614 0x9f, 0x0f, 0xa2, 0x00, 2614 0x9f, 0x0f, 0xa2, 0x00,
2615 0x02, 0x28, 0x29, 0xb1, 2615 0x02, 0x28, 0x29, 0xb1,
2616 0x08, 0x20, 0x00, 0x00, 2616 0x08, 0x20, 0x80, 0x00,
2617 0x00, 0x00, 0xff, 0xff, 2617 0x00, 0x00, 0x00, 0xff,
2618 0xff,
2618 }; 2619 };
2619
2620 const unsigned char kV3SIMDFrameData[] = { 2620 const unsigned char kV3SIMDFrameData[] = {
2621 0x80, 0x03, 0x00, 0x02, 2621 0x80, 0x03, 0x00, 0x02,
2622 0x00, 0x00, 0x00, 0x2b, 2622 0x00, 0x00, 0x00, 0x2c,
2623 0x00, 0x00, 0x00, 0x01, 2623 0x00, 0x00, 0x00, 0x01,
2624 0x38, 0xea, 0xe3, 0xc6, 2624 0x38, 0xea, 0xe3, 0xc6,
2625 0xa7, 0xc2, 0x02, 0xe5, 2625 0xa7, 0xc2, 0x02, 0xe5,
2626 0x0e, 0x50, 0xc2, 0x4b, 2626 0x0e, 0x50, 0xc2, 0x4b,
2627 0x4a, 0x04, 0xe5, 0x0b, 2627 0x4a, 0x04, 0xe5, 0x0b,
2628 0x66, 0x80, 0x00, 0x4a, 2628 0x66, 0x80, 0x00, 0x4a,
2629 0xcb, 0xcf, 0x07, 0x08, 2629 0xcb, 0xcf, 0x07, 0x08,
2630 0x20, 0x24, 0x0a, 0x20, 2630 0x20, 0x24, 0x0a, 0x20,
2631 0x80, 0x92, 0x12, 0x8b, 2631 0x80, 0x92, 0x12, 0x8b,
2632 0x00, 0x02, 0x00, 0x00, 2632 0x00, 0x02, 0x08, 0x00,
2633 0x00, 0xff, 0xff, 2633 0x00, 0x00, 0xff, 0xff,
2634 }; 2634 };
2635 // clang-format on 2635 // clang-format on
2636 2636
2637 SpdySynReplyIR syn_reply(1); 2637 SpdySynReplyIR syn_reply(1);
2638 syn_reply.SetHeader("bar", "foo"); 2638 syn_reply.SetHeader("bar", "foo");
2639 syn_reply.SetHeader("foo", "bar"); 2639 syn_reply.SetHeader("foo", "bar");
2640 SpdySerializedFrame frame(framer.SerializeSynReply(syn_reply)); 2640 SpdySerializedFrame frame(framer.SerializeSynReply(syn_reply));
2641 const unsigned char* frame_data = 2641 const unsigned char* frame_data =
2642 reinterpret_cast<const unsigned char*>(frame.data()); 2642 reinterpret_cast<const unsigned char*>(frame.data());
2643 if (IsSpdy3()) { 2643 if (IsSpdy3()) {
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
3296 TEST_P(SpdyFramerTest, CreateHeadersCompressed) { 3296 TEST_P(SpdyFramerTest, CreateHeadersCompressed) {
3297 SpdyFramer framer(spdy_version_); 3297 SpdyFramer framer(spdy_version_);
3298 framer.set_enable_compression(true); 3298 framer.set_enable_compression(true);
3299 3299
3300 { 3300 {
3301 const char kDescription[] = "HEADERS frame, no FIN"; 3301 const char kDescription[] = "HEADERS frame, no FIN";
3302 3302
3303 // clang-format off 3303 // clang-format off
3304 const unsigned char kV3FrameData[] = { 3304 const unsigned char kV3FrameData[] = {
3305 0x80, 0x03, 0x00, 0x08, 3305 0x80, 0x03, 0x00, 0x08,
3306 0x00, 0x00, 0x00, 0x30, 3306 0x00, 0x00, 0x00, 0x31,
3307 0x00, 0x00, 0x00, 0x01, 3307 0x00, 0x00, 0x00, 0x01,
3308 0x38, 0xea, 0xe3, 0xc6, 3308 0x38, 0xea, 0xe3, 0xc6,
3309 0xa7, 0xc2, 0x02, 0xe5, 3309 0xa7, 0xc2, 0x02, 0xe5,
3310 0x0e, 0x50, 0xc2, 0x4b, 3310 0x0e, 0x50, 0xc2, 0x4b,
3311 0x4a, 0x04, 0xe5, 0x0b, 3311 0x4a, 0x04, 0xe5, 0x0b,
3312 0x66, 0x80, 0x00, 0x4a, 3312 0x66, 0x80, 0x00, 0x4a,
3313 0xcb, 0xcf, 0x07, 0x08, 3313 0xcb, 0xcf, 0x07, 0x08,
3314 0x20, 0x10, 0x95, 0x96, 3314 0x20, 0x10, 0x95, 0x96,
3315 0x9f, 0x0f, 0xa2, 0x00, 3315 0x9f, 0x0f, 0xa2, 0x00,
3316 0x02, 0x28, 0x29, 0xb1, 3316 0x02, 0x28, 0x29, 0xb1,
3317 0x08, 0x20, 0x00, 0x00, 3317 0x08, 0x20, 0x80, 0x00,
3318 0x00, 0x00, 0xff, 0xff, 3318 0x00, 0x00, 0x00, 0xff,
3319 0xff,
3319 }; 3320 };
3320 const unsigned char kV3SIMDFrameData[] = { 3321 const unsigned char kV3SIMDFrameData[] = {
3321 0x80, 0x03, 0x00, 0x08, 3322 0x80, 0x03, 0x00, 0x08,
3322 0x00, 0x00, 0x00, 0x2b, 3323 0x00, 0x00, 0x00, 0x2c,
3323 0x00, 0x00, 0x00, 0x01, 3324 0x00, 0x00, 0x00, 0x01,
3324 0x38, 0xea, 0xe3, 0xc6, 3325 0x38, 0xea, 0xe3, 0xc6,
3325 0xa7, 0xc2, 0x02, 0xe5, 3326 0xa7, 0xc2, 0x02, 0xe5,
3326 0x0e, 0x50, 0xc2, 0x4b, 3327 0x0e, 0x50, 0xc2, 0x4b,
3327 0x4a, 0x04, 0xe5, 0x0b, 3328 0x4a, 0x04, 0xe5, 0x0b,
3328 0x66, 0x80, 0x00, 0x4a, 3329 0x66, 0x80, 0x00, 0x4a,
3329 0xcb, 0xcf, 0x07, 0x08, 3330 0xcb, 0xcf, 0x07, 0x08,
3330 0x20, 0x24, 0x0a, 0x20, 3331 0x20, 0x24, 0x0a, 0x20,
3331 0x80, 0x92, 0x12, 0x8b, 3332 0x80, 0x92, 0x12, 0x8b,
3332 0x00, 0x02, 0x00, 0x00, 3333 0x00, 0x02, 0x08, 0x00,
3333 0x00, 0xff, 0xff, 3334 0x00, 0x00, 0xff, 0xff,
3334 }; 3335 };
3335 // clang-format on 3336 // clang-format on
3336 3337
3337 SpdyHeadersIR headers_ir(1); 3338 SpdyHeadersIR headers_ir(1);
3338 headers_ir.SetHeader("bar", "foo"); 3339 headers_ir.SetHeader("bar", "foo");
3339 headers_ir.SetHeader("foo", "bar"); 3340 headers_ir.SetHeader("foo", "bar");
3340 SpdySerializedFrame frame(framer.SerializeHeaders(headers_ir)); 3341 SpdySerializedFrame frame(framer.SerializeHeaders(headers_ir));
3341 const unsigned char* frame_data = 3342 const unsigned char* frame_data =
3342 reinterpret_cast<const unsigned char*>(frame.data()); 3343 reinterpret_cast<const unsigned char*>(frame.data());
3343 if (IsSpdy3()) { 3344 if (IsSpdy3()) {
(...skipping 2919 matching lines...) Expand 10 before | Expand all | Expand 10 after
6263 6264
6264 EXPECT_EQ(1, visitor->data_frame_count_); 6265 EXPECT_EQ(1, visitor->data_frame_count_);
6265 EXPECT_EQ(strlen(four_score), static_cast<unsigned>(visitor->data_bytes_)); 6266 EXPECT_EQ(strlen(four_score), static_cast<unsigned>(visitor->data_bytes_));
6266 EXPECT_EQ(0, visitor->headers_frame_count_); 6267 EXPECT_EQ(0, visitor->headers_frame_count_);
6267 } 6268 }
6268 } 6269 }
6269 6270
6270 } // namespace test 6271 } // namespace test
6271 6272
6272 } // namespace net 6273 } // namespace net
OLDNEW
« no previous file with comments | « AUTHORS ('k') | net/spdy/spdy_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698