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

Unified Diff: net/filter/brotli_source_stream_unittest.cc

Issue 2451833004: Fix net::BrotliSourceStream to ignore trailing data. (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« net/filter/brotli_source_stream.cc ('K') | « net/filter/brotli_source_stream.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/filter/brotli_source_stream_unittest.cc
diff --git a/net/filter/brotli_source_stream_unittest.cc b/net/filter/brotli_source_stream_unittest.cc
index 4a0fd1e70f320f6c9b19a934a04de65b3336e327..eedb39ce9096e1f708dc89da2d7bd18c23ac19bb 100644
--- a/net/filter/brotli_source_stream_unittest.cc
+++ b/net/filter/brotli_source_stream_unittest.cc
@@ -98,6 +98,29 @@ TEST_F(BrotliSourceStreamTest, DecodeBrotliOneBlockSync) {
EXPECT_EQ("BROTLI", brotli_stream()->Description());
}
+// If there are data after decoding is done, ignore the data. crbug.com/659311.
+TEST_F(BrotliSourceStreamTest, IgnoreExtraData) {
+ std::string response_with_extra_data(encoded_buffer(), encoded_len());
+ size_t extra_length = 1000;
+ response_with_extra_data.append(extra_length, 'x');
+ source()->AddReadResult(response_with_extra_data.c_str(),
+ encoded_len() + extra_length, OK,
+ MockSourceStream::SYNC);
+ out_buffer_ = new IOBufferWithSize(kDefaultBufferSize);
+ std::string actual_output;
+ TestCompletionCallback callback;
+ while (true) {
+ int bytes_read = ReadStream(callback);
+ if (bytes_read == OK)
+ break;
+ ASSERT_GT(bytes_read, OK);
+ actual_output.append(out_data(), bytes_read);
+ }
+ EXPECT_EQ(source_data_len(), actual_output.size());
+ EXPECT_EQ(source_data(), actual_output);
+ EXPECT_EQ("BROTLI", brotli_stream()->Description());
+}
+
// Basic scenario: decoding brotli data with big enough buffer.
TEST_F(BrotliSourceStreamTest, DecodeBrotliTwoBlockSync) {
source()->AddReadResult(encoded_buffer(), 10, OK, MockSourceStream::SYNC);
« net/filter/brotli_source_stream.cc ('K') | « net/filter/brotli_source_stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698