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 <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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 | 740 |
741 std::string sdch_compressed(NewSdchCompressedData(dictionary)); | 741 std::string sdch_compressed(NewSdchCompressedData(dictionary)); |
742 | 742 |
743 // Use Gzip to compress the sdch sdch_compressed data. | 743 // Use Gzip to compress the sdch sdch_compressed data. |
744 std::string gzip_compressed_sdch = gzip_compress(sdch_compressed); | 744 std::string gzip_compressed_sdch = gzip_compress(sdch_compressed); |
745 | 745 |
746 // Only claim to have sdch content, but really use the gzipped sdch content. | 746 // Only claim to have sdch content, but really use the gzipped sdch content. |
747 // System should automatically add the missing (optional) gzip. | 747 // System should automatically add the missing (optional) gzip. |
748 std::vector<Filter::FilterType> filter_types; | 748 std::vector<Filter::FilterType> filter_types; |
749 filter_types.push_back(Filter::FILTER_TYPE_SDCH); | 749 filter_types.push_back(Filter::FILTER_TYPE_SDCH); |
750 Filter::FixupEncodingTypes(true, "anything/mime", &filter_types); | 750 |
| 751 const int kInputBufferSize(100); |
| 752 MockFilterContext filter_context(kInputBufferSize); |
| 753 filter_context.SetMimeType("anything/mime"); |
| 754 filter_context.SetSdchResponse(true); |
| 755 Filter::FixupEncodingTypes(filter_context, &filter_types); |
751 | 756 |
752 // First try with a large buffer (larger than test input, or compressed data). | 757 // First try with a large buffer (larger than test input, or compressed data). |
753 const int kInputBufferSize(100); | |
754 MockFilterContext filter_context(kInputBufferSize); | |
755 filter_context.SetURL(url); | 758 filter_context.SetURL(url); |
756 scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); | 759 scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); |
757 | 760 |
758 | 761 |
759 // Verify that chained filter is waiting for data. | 762 // Verify that chained filter is waiting for data. |
760 char tiny_output_buffer[10]; | 763 char tiny_output_buffer[10]; |
761 int tiny_output_size = sizeof(tiny_output_buffer); | 764 int tiny_output_size = sizeof(tiny_output_buffer); |
762 EXPECT_EQ(Filter::FILTER_NEED_MORE_DATA, | 765 EXPECT_EQ(Filter::FILTER_NEED_MORE_DATA, |
763 filter->ReadData(tiny_output_buffer, &tiny_output_size)); | 766 filter->ReadData(tiny_output_buffer, &tiny_output_size)); |
764 | 767 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 | 958 |
956 TEST_F(SdchFilterTest, DictionaryTooLarge) { | 959 TEST_F(SdchFilterTest, DictionaryTooLarge) { |
957 std::string dictionary_domain(".google.com"); | 960 std::string dictionary_domain(".google.com"); |
958 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 961 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
959 | 962 |
960 dictionary_text.append( | 963 dictionary_text.append( |
961 SdchManager::kMaxDictionarySize + 1 - dictionary_text.size(), ' '); | 964 SdchManager::kMaxDictionarySize + 1 - dictionary_text.size(), ' '); |
962 EXPECT_FALSE(sdch_manager_->AddSdchDictionary(dictionary_text, | 965 EXPECT_FALSE(sdch_manager_->AddSdchDictionary(dictionary_text, |
963 GURL("http://" + dictionary_domain))); | 966 GURL("http://" + dictionary_domain))); |
964 } | 967 } |
OLD | NEW |