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

Unified Diff: net/filter/sdch_source_stream_unittest.cc

Issue 2446443002: Fix net::SdchSourceStream Passthrough bug (Closed)
Patch Set: mistake made during splitting off change 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
« no previous file with comments | « net/filter/sdch_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/sdch_source_stream_unittest.cc
diff --git a/net/filter/sdch_source_stream_unittest.cc b/net/filter/sdch_source_stream_unittest.cc
index c441d73201facd30020b6d4614e7887d8483e0b8..79ea606ccb74c2eef02f6043e009e65e0bf009b0 100644
--- a/net/filter/sdch_source_stream_unittest.cc
+++ b/net/filter/sdch_source_stream_unittest.cc
@@ -543,4 +543,56 @@ TEST_P(SdchSourceStreamTest, FilterChaining) {
}
}
+// Test that if TYPE_SDCH_POSSIBLE and TYPE_GZIP_FALLBACK are added to a
+// gzipped content, the content can be decoded without problem.
+TEST_P(SdchSourceStreamTest, PossibleSdchActuallyGzip) {
+ int out_buffer_sizes[] = {kBufferSize, kSmallBufferSize};
+ for (auto out_buffer_size : out_buffer_sizes) {
+ char plain_data[] = "Hello, World!";
+ unsigned char gzip_data[] = {
+ // From:
+ // echo -n 'Hello, World!' | gzip | xxd -i | sed -e 's/^/ /'
+ // with the 8 footer bytes removed.
+ 0x1f, 0x8b, 0x08, 0x00, 0x2b, 0x02, 0x84, 0x55, 0x00,
+ 0x03, 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0xd7, 0x51, 0x08,
+ 0xcf, 0x2f, 0xca, 0x49, 0x51, 0x04, 0x00};
+ SetErrorRecovery(SdchSourceStream::Delegate::PASS_THROUGH, std::string());
+ Init();
+ std::unique_ptr<MockDelegate> delegate = GetNewDelegate();
+ MockDelegate* raw_delegate_pointer = delegate.get();
+ MockSourceStream* source = new MockSourceStream();
+ source->AddReadResult(reinterpret_cast<char*>(gzip_data), sizeof(gzip_data),
+ OK, GetParam());
+ source->AddReadResult(
+ reinterpret_cast<char*>(gzip_data) + sizeof(gzip_data), 0, OK,
+ MockSourceStream::SYNC);
+ std::unique_ptr<GzipSourceStream> gzip_source = GzipSourceStream::Create(
+ base::WrapUnique(source), SourceStream::TYPE_GZIP);
+ std::unique_ptr<GzipSourceStream> gzip_fallback_source =
+ GzipSourceStream::Create(std::move(gzip_source),
+ SourceStream::TYPE_GZIP_FALLBACK);
+ std::unique_ptr<SdchSourceStream> sdch_possible(new SdchSourceStream(
+ std::move(gzip_fallback_source), std::move(delegate),
+ SourceStream::TYPE_SDCH_POSSIBLE));
+ std::string actual_output;
+ while (true) {
+ TestCompletionCallback callback;
+ int rv = sdch_possible->Read(out_buffer(), out_buffer_size,
+ callback.callback());
+ if (rv == ERR_IO_PENDING)
+ rv = CompleteReadIfAsync(rv, &callback, source);
+ if (rv == OK)
+ break;
+ ASSERT_GT(rv, OK);
+ if (out_buffer_size == kSmallBufferSize)
+ EXPECT_GE(kSmallBufferSize, static_cast<size_t>(rv));
+
+ actual_output.append(out_data(), rv);
+ }
+ EXPECT_TRUE(raw_delegate_pointer->dictionary_id_error_handled());
+ EXPECT_EQ(plain_data, actual_output);
+ EXPECT_EQ("GZIP,GZIP_FALLBACK,SDCH_POSSIBLE", sdch_possible->Description());
+ }
+}
+
} // namespace net
« no previous file with comments | « net/filter/sdch_source_stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698