| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <fstream> | 5 #include <fstream> |
| 6 #include <iostream> | 6 #include <iostream> |
| 7 | 7 |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 // This tests that sdch will degrade to pass through, and is what allows robust | 272 // This tests that sdch will degrade to pass through, and is what allows robust |
| 273 // handling when the response *might* be sdch,gzip by simply adding in the | 273 // handling when the response *might* be sdch,gzip by simply adding in the |
| 274 // tentative sdch decode. | 274 // tentative sdch decode. |
| 275 // All test code is otherwise modeled after the "basic" scenario above. | 275 // All test code is otherwise modeled after the "basic" scenario above. |
| 276 TEST_F(GZipUnitTest, DecodeGZipWithMistakenSdch) { | 276 TEST_F(GZipUnitTest, DecodeGZipWithMistakenSdch) { |
| 277 // Decode the compressed data with filter | 277 // Decode the compressed data with filter |
| 278 std::vector<Filter::FilterType> filter_types; | 278 std::vector<Filter::FilterType> filter_types; |
| 279 filter_types.push_back(Filter::FILTER_TYPE_SDCH); | 279 filter_types.push_back(Filter::FILTER_TYPE_SDCH); |
| 280 filter_types.push_back(Filter::FILTER_TYPE_GZIP); | 280 filter_types.push_back(Filter::FILTER_TYPE_GZIP); |
| 281 MockFilterContext filter_context(kDefaultBufferSize); | 281 MockFilterContext filter_context(kDefaultBufferSize); |
| 282 // We need a good response code to be sure that a proxy isn't injecting an |
| 283 // error page (As is done by BlueCoat proxies and described in bug 8916). |
| 284 filter_context.SetResponseCode(200); |
| 282 scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); | 285 scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); |
| 283 ASSERT_TRUE(filter.get()); | 286 ASSERT_TRUE(filter.get()); |
| 284 memcpy(filter->stream_buffer()->data(), gzip_encode_buffer_, | 287 memcpy(filter->stream_buffer()->data(), gzip_encode_buffer_, |
| 285 gzip_encode_len_); | 288 gzip_encode_len_); |
| 286 filter->FlushStreamBuffer(gzip_encode_len_); | 289 filter->FlushStreamBuffer(gzip_encode_len_); |
| 287 | 290 |
| 288 char gzip_decode_buffer[kDefaultBufferSize]; | 291 char gzip_decode_buffer[kDefaultBufferSize]; |
| 289 int gzip_decode_size = kDefaultBufferSize; | 292 int gzip_decode_size = kDefaultBufferSize; |
| 290 filter->ReadData(gzip_decode_buffer, &gzip_decode_size); | 293 filter->ReadData(gzip_decode_buffer, &gzip_decode_size); |
| 291 | 294 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 int corrupt_decode_size = kDefaultBufferSize; | 420 int corrupt_decode_size = kDefaultBufferSize; |
| 418 | 421 |
| 419 int code = DecodeAllWithFilter(filter.get(), corrupt_data, corrupt_data_len, | 422 int code = DecodeAllWithFilter(filter.get(), corrupt_data, corrupt_data_len, |
| 420 corrupt_decode_buffer, &corrupt_decode_size); | 423 corrupt_decode_buffer, &corrupt_decode_size); |
| 421 | 424 |
| 422 // Expect failures | 425 // Expect failures |
| 423 EXPECT_TRUE(code == Filter::FILTER_ERROR); | 426 EXPECT_TRUE(code == Filter::FILTER_ERROR); |
| 424 } | 427 } |
| 425 | 428 |
| 426 } // namespace | 429 } // namespace |
| OLD | NEW |