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/filter.h" | 5 #include "net/filter/filter.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 encoding_types.clear(); | 142 encoding_types.clear(); |
143 encoding_types.push_back(Filter::FILTER_TYPE_GZIP); | 143 encoding_types.push_back(Filter::FILTER_TYPE_GZIP); |
144 Filter::FixupEncodingTypes(filter_context, &encoding_types); | 144 Filter::FixupEncodingTypes(filter_context, &encoding_types); |
145 ASSERT_EQ(1U, encoding_types.size()); | 145 ASSERT_EQ(1U, encoding_types.size()); |
146 EXPECT_EQ(Filter::FILTER_TYPE_GZIP, encoding_types.front()); | 146 EXPECT_EQ(Filter::FILTER_TYPE_GZIP, encoding_types.front()); |
147 } | 147 } |
148 | 148 |
149 // Make sure a series of three pass-through filters copies the data cleanly. | 149 // Make sure a series of three pass-through filters copies the data cleanly. |
150 // Regression test for http://crbug.com/418975. | 150 // Regression test for http://crbug.com/418975. |
151 TEST(FilterTest, ThreeFilterChain) { | 151 TEST(FilterTest, ThreeFilterChain) { |
152 scoped_ptr<PassThroughFilter> filter1(new PassThroughFilter); | 152 std::unique_ptr<PassThroughFilter> filter1(new PassThroughFilter); |
153 scoped_ptr<PassThroughFilter> filter2(new PassThroughFilter); | 153 std::unique_ptr<PassThroughFilter> filter2(new PassThroughFilter); |
154 scoped_ptr<PassThroughFilter> filter3(new PassThroughFilter); | 154 std::unique_ptr<PassThroughFilter> filter3(new PassThroughFilter); |
155 | 155 |
156 filter1->InitBuffer(32 * 1024); | 156 filter1->InitBuffer(32 * 1024); |
157 filter2->InitBuffer(32 * 1024); | 157 filter2->InitBuffer(32 * 1024); |
158 filter3->InitBuffer(32 * 1024); | 158 filter3->InitBuffer(32 * 1024); |
159 | 159 |
160 filter2->next_filter_ = std::move(filter3); | 160 filter2->next_filter_ = std::move(filter3); |
161 filter1->next_filter_ = std::move(filter2); | 161 filter1->next_filter_ = std::move(filter2); |
162 | 162 |
163 // Initialize the input array with a varying byte sequence. | 163 // Initialize the input array with a varying byte sequence. |
164 const size_t input_array_size = 64 * 1024; | 164 const size_t input_array_size = 64 * 1024; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 amount_to_copy); | 204 amount_to_copy); |
205 filter1->FlushStreamBuffer(amount_to_copy); | 205 filter1->FlushStreamBuffer(amount_to_copy); |
206 read_array_index += amount_to_copy; | 206 read_array_index += amount_to_copy; |
207 } while (true); | 207 } while (true); |
208 | 208 |
209 EXPECT_EQ(read_array_index, input_array_size); | 209 EXPECT_EQ(read_array_index, input_array_size); |
210 EXPECT_EQ(compare_array_index, input_array_size); | 210 EXPECT_EQ(compare_array_index, input_array_size); |
211 } | 211 } |
212 | 212 |
213 } // Namespace net | 213 } // Namespace net |
OLD | NEW |