OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/files/file_util.h" | 5 #include "base/files/file_util.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "net/base/io_buffer.h" | 8 #include "net/base/io_buffer.h" |
9 #include "net/filter/brotli_filter.h" | 9 #include "net/filter/brotli_filter.h" |
10 #include "net/filter/mock_filter_context.h" | 10 #include "net/filter/mock_filter_context.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 char corrupt_decode_buffer[kDefaultBufferSize]; | 243 char corrupt_decode_buffer[kDefaultBufferSize]; |
244 int corrupt_decode_size = kDefaultBufferSize; | 244 int corrupt_decode_size = kDefaultBufferSize; |
245 | 245 |
246 int code = DecodeAllWithFilter(filter_.get(), corrupt_data, corrupt_data_len, | 246 int code = DecodeAllWithFilter(filter_.get(), corrupt_data, corrupt_data_len, |
247 corrupt_decode_buffer, &corrupt_decode_size); | 247 corrupt_decode_buffer, &corrupt_decode_size); |
248 | 248 |
249 // Expect failures | 249 // Expect failures |
250 EXPECT_EQ(Filter::FILTER_ERROR, code); | 250 EXPECT_EQ(Filter::FILTER_ERROR, code); |
251 } | 251 } |
252 | 252 |
| 253 // Decoding brotli stream with empty output data. |
| 254 TEST_F(BrotliUnitTest, DecodeEmptyData) { |
| 255 char data[1] = {6}; // WBITS = 16, ISLAST = 1, ISLASTEMPTY = 1 |
| 256 int data_len = 1; |
| 257 |
| 258 InitFilter(); |
| 259 char decode_buffer[kDefaultBufferSize]; |
| 260 int decode_size = kDefaultBufferSize; |
| 261 int code = DecodeAllWithFilter(filter_.get(), data, data_len, decode_buffer, |
| 262 &decode_size); |
| 263 |
| 264 // Expect success / empty output. |
| 265 EXPECT_EQ(Filter::FILTER_DONE, code); |
| 266 EXPECT_EQ(0, decode_size); |
| 267 } |
| 268 |
253 } // namespace net | 269 } // namespace net |
OLD | NEW |