| 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 "net/filter/brotli_filter.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 5 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 6 #include "base/memory/scoped_ptr.h" | |
| 7 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 8 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
| 9 #include "net/filter/brotli_filter.h" | |
| 10 #include "net/filter/mock_filter_context.h" | 12 #include "net/filter/mock_filter_context.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "testing/platform_test.h" | 14 #include "testing/platform_test.h" |
| 13 | 15 |
| 14 namespace { | 16 namespace { |
| 15 const int kDefaultBufferSize = 4096; | 17 const int kDefaultBufferSize = 4096; |
| 16 const int kSmallBufferSize = 128; | 18 const int kSmallBufferSize = 128; |
| 17 } // namespace | 19 } // namespace |
| 18 | 20 |
| 19 namespace net { | 21 namespace net { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 Filter::FactoryForTests(filter_types, filter_context_, buffer_size)); | 130 Filter::FactoryForTests(filter_types, filter_context_, buffer_size)); |
| 129 ASSERT_TRUE(filter_.get()); | 131 ASSERT_TRUE(filter_.get()); |
| 130 } | 132 } |
| 131 | 133 |
| 132 const char* source_buffer() const { return source_buffer_.data(); } | 134 const char* source_buffer() const { return source_buffer_.data(); } |
| 133 int source_len() const { return static_cast<int>(source_buffer_.size()); } | 135 int source_len() const { return static_cast<int>(source_buffer_.size()); } |
| 134 | 136 |
| 135 const char* encoded_buffer() const { return encoded_buffer_.data(); } | 137 const char* encoded_buffer() const { return encoded_buffer_.data(); } |
| 136 int encoded_len() const { return static_cast<int>(encoded_buffer_.size()); } | 138 int encoded_len() const { return static_cast<int>(encoded_buffer_.size()); } |
| 137 | 139 |
| 138 scoped_ptr<Filter> filter_; | 140 std::unique_ptr<Filter> filter_; |
| 139 | 141 |
| 140 private: | 142 private: |
| 141 MockFilterContext filter_context_; | 143 MockFilterContext filter_context_; |
| 142 std::string source_buffer_; | 144 std::string source_buffer_; |
| 143 std::string encoded_buffer_; | 145 std::string encoded_buffer_; |
| 144 }; | 146 }; |
| 145 | 147 |
| 146 // Basic scenario: decoding brotli data with big enough buffer. | 148 // Basic scenario: decoding brotli data with big enough buffer. |
| 147 TEST_F(BrotliUnitTest, DecodeBrotli) { | 149 TEST_F(BrotliUnitTest, DecodeBrotli) { |
| 148 InitFilter(); | 150 InitFilter(); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 int decode_size = kDefaultBufferSize; | 262 int decode_size = kDefaultBufferSize; |
| 261 int code = DecodeAllWithFilter(filter_.get(), data, data_len, decode_buffer, | 263 int code = DecodeAllWithFilter(filter_.get(), data, data_len, decode_buffer, |
| 262 &decode_size); | 264 &decode_size); |
| 263 | 265 |
| 264 // Expect success / empty output. | 266 // Expect success / empty output. |
| 265 EXPECT_EQ(Filter::FILTER_DONE, code); | 267 EXPECT_EQ(Filter::FILTER_DONE, code); |
| 266 EXPECT_EQ(0, decode_size); | 268 EXPECT_EQ(0, decode_size); |
| 267 } | 269 } |
| 268 | 270 |
| 269 } // namespace net | 271 } // namespace net |
| OLD | NEW |