OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/filter/gzip_filter.h" |
| 6 |
5 #include <fstream> | 7 #include <fstream> |
| 8 #include <memory> |
6 #include <ostream> | 9 #include <ostream> |
7 | 10 |
8 #include "base/bit_cast.h" | 11 #include "base/bit_cast.h" |
9 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/path_service.h" | 13 #include "base/path_service.h" |
12 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
13 #include "net/filter/gzip_filter.h" | |
14 #include "net/filter/mock_filter_context.h" | 15 #include "net/filter/mock_filter_context.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "testing/platform_test.h" | 17 #include "testing/platform_test.h" |
17 #include "third_party/zlib/zlib.h" | 18 #include "third_party/zlib/zlib.h" |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 const int kDefaultBufferSize = 4096; | 22 const int kDefaultBufferSize = 4096; |
22 const int kSmallBufferSize = 128; | 23 const int kSmallBufferSize = 128; |
23 | 24 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 std::vector<Filter::FilterType> filter_types; | 227 std::vector<Filter::FilterType> filter_types; |
227 filter_types.push_back(type); | 228 filter_types.push_back(type); |
228 filter_.reset(Filter::FactoryForTests(filter_types, filter_context_, | 229 filter_.reset(Filter::FactoryForTests(filter_types, filter_context_, |
229 buffer_size)); | 230 buffer_size)); |
230 ASSERT_TRUE(filter_.get()); | 231 ASSERT_TRUE(filter_.get()); |
231 } | 232 } |
232 | 233 |
233 const char* source_buffer() const { return source_buffer_.data(); } | 234 const char* source_buffer() const { return source_buffer_.data(); } |
234 int source_len() const { return static_cast<int>(source_buffer_.size()); } | 235 int source_len() const { return static_cast<int>(source_buffer_.size()); } |
235 | 236 |
236 scoped_ptr<Filter> filter_; | 237 std::unique_ptr<Filter> filter_; |
237 | 238 |
238 std::string source_buffer_; | 239 std::string source_buffer_; |
239 | 240 |
240 char* deflate_encode_buffer_; | 241 char* deflate_encode_buffer_; |
241 int deflate_encode_len_; | 242 int deflate_encode_len_; |
242 | 243 |
243 char* gzip_encode_buffer_; | 244 char* gzip_encode_buffer_; |
244 int gzip_encode_len_; | 245 int gzip_encode_len_; |
245 | 246 |
246 private: | 247 private: |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 int corrupt_decode_size = kDefaultBufferSize; | 380 int corrupt_decode_size = kDefaultBufferSize; |
380 | 381 |
381 int code = DecodeAllWithFilter(filter_.get(), corrupt_data, corrupt_data_len, | 382 int code = DecodeAllWithFilter(filter_.get(), corrupt_data, corrupt_data_len, |
382 corrupt_decode_buffer, &corrupt_decode_size); | 383 corrupt_decode_buffer, &corrupt_decode_size); |
383 | 384 |
384 // Expect failures | 385 // Expect failures |
385 EXPECT_TRUE(code == Filter::FILTER_ERROR); | 386 EXPECT_TRUE(code == Filter::FILTER_ERROR); |
386 } | 387 } |
387 | 388 |
388 } // namespace net | 389 } // namespace net |
OLD | NEW |