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

Side by Side Diff: net/filter/sdch_filter_unittest.cc

Issue 380003002: Improve testing for SDCH. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed braino: Added SDHC enable to the tests that need it. Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <limits.h> 5 #include <limits.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 //------------------------------------------------------------------------------ 158 //------------------------------------------------------------------------------
159 159
160 TEST_F(SdchFilterTest, EmptyInputOk) { 160 TEST_F(SdchFilterTest, EmptyInputOk) {
161 std::vector<Filter::FilterType> filter_types; 161 std::vector<Filter::FilterType> filter_types;
162 filter_types.push_back(Filter::FILTER_TYPE_SDCH); 162 filter_types.push_back(Filter::FILTER_TYPE_SDCH);
163 char output_buffer[20]; 163 char output_buffer[20];
164 std::string url_string("http://ignore.com"); 164 std::string url_string("http://ignore.com");
165 filter_context()->SetURL(GURL(url_string)); 165 filter_context()->SetURL(GURL(url_string));
166 scoped_ptr<Filter> filter(Filter::Factory(filter_types, *filter_context())); 166 scoped_ptr<Filter> filter(Filter::Factory(filter_types, *filter_context()));
167 167
168 // With no input data, try to read output.
169 int output_bytes_or_buffer_size = sizeof(output_buffer);
170 Filter::FilterStatus status = filter->ReadData(output_buffer,
171 &output_bytes_or_buffer_size);
172
173 EXPECT_EQ(0, output_bytes_or_buffer_size);
174 EXPECT_EQ(Filter::FILTER_NEED_MORE_DATA, status);
175 }
176
177 // Make sure that the filter context has everything that might be
178 // nuked from it during URLRequest teardown before the SdchFilter
179 // destructor.
180 TEST_F(SdchFilterTest, SparseContextOk) {
181 std::vector<Filter::FilterType> filter_types;
182 filter_types.push_back(Filter::FILTER_TYPE_SDCH);
183 char output_buffer[20];
184 std::string url_string("http://ignore.com");
185 filter_context()->SetURL(GURL(url_string));
186 scoped_ptr<Filter> filter(Filter::Factory(filter_types, *filter_context()));
168 187
169 // With no input data, try to read output. 188 // With no input data, try to read output.
170 int output_bytes_or_buffer_size = sizeof(output_buffer); 189 int output_bytes_or_buffer_size = sizeof(output_buffer);
171 Filter::FilterStatus status = filter->ReadData(output_buffer, 190 Filter::FilterStatus status = filter->ReadData(output_buffer,
172 &output_bytes_or_buffer_size); 191 &output_bytes_or_buffer_size);
173 192
174 EXPECT_EQ(0, output_bytes_or_buffer_size); 193 EXPECT_EQ(0, output_bytes_or_buffer_size);
175 EXPECT_EQ(Filter::FILTER_NEED_MORE_DATA, status); 194 EXPECT_EQ(Filter::FILTER_NEED_MORE_DATA, status);
195
196 // Partially tear down context. Anything that goes through request()
197 // without checking it for null in the URLRequestJob::HttpFilterContext
198 // implementation is suspect. Everything that does check it for null should
199 // return null.
200 filter_context()->NukeUnstableInterfaces();
201 filter_context()->SetRequestTime(base::Time());
mef 2014/07/23 18:34:30 I'm not sure what this does. Should there be some
Randy Smith (Not in Mondays) 2014/07/29 23:44:22 Added an explanatory comment (I'm trying to make t
176 } 202 }
177 203
178 TEST_F(SdchFilterTest, PassThroughWhenTentative) { 204 TEST_F(SdchFilterTest, PassThroughWhenTentative) {
179 std::vector<Filter::FilterType> filter_types; 205 std::vector<Filter::FilterType> filter_types;
180 // Selective a tentative filter (which can fall back to pass through). 206 // Selective a tentative filter (which can fall back to pass through).
181 filter_types.push_back(Filter::FILTER_TYPE_GZIP_HELPING_SDCH); 207 filter_types.push_back(Filter::FILTER_TYPE_GZIP_HELPING_SDCH);
182 char output_buffer[20]; 208 char output_buffer[20];
183 // Response code needs to be 200 to allow a pass through. 209 // Response code needs to be 200 to allow a pass through.
184 filter_context()->SetResponseCode(200); 210 filter_context()->SetResponseCode(200);
185 std::string url_string("http://ignore.com"); 211 std::string url_string("http://ignore.com");
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 1159
1134 feed_block_size = 1; 1160 feed_block_size = 1;
1135 output_block_size = 1; 1161 output_block_size = 1;
1136 output.clear(); 1162 output.clear();
1137 EXPECT_TRUE(FilterTestData(double_gzip_compressed_sdch, feed_block_size, 1163 EXPECT_TRUE(FilterTestData(double_gzip_compressed_sdch, feed_block_size,
1138 output_block_size, filter.get(), &output)); 1164 output_block_size, filter.get(), &output));
1139 EXPECT_EQ(output, expanded_); 1165 EXPECT_EQ(output, expanded_);
1140 } 1166 }
1141 1167
1142 } // namespace net 1168 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698