| 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 19 matching lines...) Expand all Loading... |
| 30 // gulp, but (with careful selection of intermediate buffers) that it takes | 30 // gulp, but (with careful selection of intermediate buffers) that it takes |
| 31 // several sdch buffers worth of data to satisfy the sdch filter. See detailed | 31 // several sdch buffers worth of data to satisfy the sdch filter. See detailed |
| 32 // CHECK() calls in FilterChaining test for specifics. | 32 // CHECK() calls in FilterChaining test for specifics. |
| 33 static const char kTestData[] = "0000000000000000000000000000000000000000000000" | 33 static const char kTestData[] = "0000000000000000000000000000000000000000000000" |
| 34 "0000000000000000000000000000TestData " | 34 "0000000000000000000000000000TestData " |
| 35 "SdchCompression1SdchCompression2SdchCompression3SdchCompression" | 35 "SdchCompression1SdchCompression2SdchCompression3SdchCompression" |
| 36 "00000000000000000000000000000000000000000000000000000000000000000000000000" | 36 "00000000000000000000000000000000000000000000000000000000000000000000000000" |
| 37 "000000000000000000000000000000000000000\n"; | 37 "000000000000000000000000000000000000000\n"; |
| 38 | 38 |
| 39 // Note SDCH compressed data will include a reference to the SDCH dictionary. | 39 // Note SDCH compressed data will include a reference to the SDCH dictionary. |
| 40 static const char kCompressedTestData[] = | 40 static const char kSdchCompressedTestData[] = |
| 41 "\326\303\304\0\0\001M\0\201S\202\004\0\201E\006\001" | 41 "\326\303\304\0\0\001M\0\201S\202\004\0\201E\006\001" |
| 42 "00000000000000000000000000000000000000000000000000000000000000000000000000" | 42 "00000000000000000000000000000000000000000000000000000000000000000000000000" |
| 43 "TestData 00000000000000000000000000000000000000000000000000000000000000000" | 43 "TestData 00000000000000000000000000000000000000000000000000000000000000000" |
| 44 "000000000000000000000000000000000000000000000000\n\001S\023\077\001r\r"; | 44 "000000000000000000000000000000000000000000000000\n\001S\023\077\001r\r"; |
| 45 | 45 |
| 46 //------------------------------------------------------------------------------ | 46 //------------------------------------------------------------------------------ |
| 47 | 47 |
| 48 class SdchFilterTest : public testing::Test { | 48 class SdchFilterTest : public testing::Test { |
| 49 protected: | 49 protected: |
| 50 SdchFilterTest() | 50 SdchFilterTest() |
| 51 : test_vcdiff_dictionary_(kTestVcdiffDictionary, | 51 : test_vcdiff_dictionary_(kTestVcdiffDictionary, |
| 52 sizeof(kTestVcdiffDictionary) - 1), | 52 sizeof(kTestVcdiffDictionary) - 1), |
| 53 vcdiff_compressed_data_(kCompressedTestData, | 53 vcdiff_compressed_data_(kSdchCompressedTestData, |
| 54 sizeof(kCompressedTestData) - 1), | 54 sizeof(kSdchCompressedTestData) - 1), |
| 55 expanded_(kTestData, sizeof(kTestData) - 1), | 55 expanded_(kTestData, sizeof(kTestData) - 1), |
| 56 sdch_manager_(new SdchManager) { | 56 sdch_manager_(new SdchManager) { |
| 57 sdch_manager_->EnableSdchSupport(""); | 57 sdch_manager_->EnableSdchSupport(""); |
| 58 } | 58 } |
| 59 | 59 |
| 60 std::string NewSdchCompressedData(const std::string dictionary); | 60 std::string NewSdchCompressedData(const std::string dictionary); |
| 61 | 61 |
| 62 const std::string test_vcdiff_dictionary_; | 62 const std::string test_vcdiff_dictionary_; |
| 63 const std::string vcdiff_compressed_data_; | 63 const std::string vcdiff_compressed_data_; |
| 64 const std::string expanded_; // Desired final, decompressed data. | 64 const std::string expanded_; // Desired final, decompressed data. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 Filter::FilterStatus status = filter->ReadData(output_buffer, | 164 Filter::FilterStatus status = filter->ReadData(output_buffer, |
| 165 &output_bytes_or_buffer_size); | 165 &output_bytes_or_buffer_size); |
| 166 | 166 |
| 167 EXPECT_EQ(0, output_bytes_or_buffer_size); | 167 EXPECT_EQ(0, output_bytes_or_buffer_size); |
| 168 EXPECT_EQ(Filter::FILTER_NEED_MORE_DATA, status); | 168 EXPECT_EQ(Filter::FILTER_NEED_MORE_DATA, status); |
| 169 } | 169 } |
| 170 | 170 |
| 171 TEST_F(SdchFilterTest, PassThroughWhenTentative) { | 171 TEST_F(SdchFilterTest, PassThroughWhenTentative) { |
| 172 std::vector<Filter::FilterType> filter_types; | 172 std::vector<Filter::FilterType> filter_types; |
| 173 // Selective a tentative filter (which can fall back to pass through). | 173 // Selective a tentative filter (which can fall back to pass through). |
| 174 filter_types.push_back(Filter::FILTER_TYPE_SDCH_POSSIBLE); | 174 filter_types.push_back(Filter::FILTER_TYPE_GZIP_HELPING_SDCH); |
| 175 const int kInputBufferSize(30); | 175 const int kInputBufferSize(30); |
| 176 char output_buffer[20]; | 176 char output_buffer[20]; |
| 177 MockFilterContext filter_context(kInputBufferSize); | 177 MockFilterContext filter_context(kInputBufferSize); |
| 178 // Response code needs to be 200 to allow a pass through. | 178 // Response code needs to be 200 to allow a pass through. |
| 179 filter_context.SetResponseCode(200); | 179 filter_context.SetResponseCode(200); |
| 180 std::string url_string("http://ignore.com"); | 180 std::string url_string("http://ignore.com"); |
| 181 filter_context.SetURL(GURL(url_string)); | 181 filter_context.SetURL(GURL(url_string)); |
| 182 scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); | 182 scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); |
| 183 | 183 |
| 184 // Supply enough data to force a pass-through mode, which means we have | 184 // Supply enough data to force a pass-through mode.. |
| 185 // provided more than 9 characters that can't be a dictionary hash. | 185 std::string non_gzip_content("not GZIPed data"); |
| 186 std::string non_sdch_content("This is not SDCH"); | |
| 187 | 186 |
| 188 char* input_buffer = filter->stream_buffer()->data(); | 187 char* input_buffer = filter->stream_buffer()->data(); |
| 189 int input_buffer_size = filter->stream_buffer_size(); | 188 int input_buffer_size = filter->stream_buffer_size(); |
| 190 EXPECT_EQ(kInputBufferSize, input_buffer_size); | 189 EXPECT_EQ(kInputBufferSize, input_buffer_size); |
| 191 | 190 |
| 192 EXPECT_LT(static_cast<int>(non_sdch_content.size()), | 191 EXPECT_LT(static_cast<int>(non_gzip_content.size()), |
| 193 input_buffer_size); | 192 input_buffer_size); |
| 194 memcpy(input_buffer, non_sdch_content.data(), | 193 memcpy(input_buffer, non_gzip_content.data(), |
| 195 non_sdch_content.size()); | 194 non_gzip_content.size()); |
| 196 filter->FlushStreamBuffer(non_sdch_content.size()); | 195 filter->FlushStreamBuffer(non_gzip_content.size()); |
| 197 | 196 |
| 198 // Try to read output. | 197 // Try to read output. |
| 199 int output_bytes_or_buffer_size = sizeof(output_buffer); | 198 int output_bytes_or_buffer_size = sizeof(output_buffer); |
| 200 Filter::FilterStatus status = filter->ReadData(output_buffer, | 199 Filter::FilterStatus status = filter->ReadData(output_buffer, |
| 201 &output_bytes_or_buffer_size); | 200 &output_bytes_or_buffer_size); |
| 202 | 201 |
| 203 EXPECT_TRUE(non_sdch_content.size() == | 202 EXPECT_EQ(non_gzip_content.size(), |
| 204 static_cast<size_t>(output_bytes_or_buffer_size)); | 203 static_cast<size_t>(output_bytes_or_buffer_size)); |
| 205 ASSERT_TRUE(sizeof(output_buffer) > | 204 ASSERT_GT(sizeof(output_buffer), |
| 206 static_cast<size_t>(output_bytes_or_buffer_size)); | 205 static_cast<size_t>(output_bytes_or_buffer_size)); |
| 207 output_buffer[output_bytes_or_buffer_size] = '\0'; | 206 output_buffer[output_bytes_or_buffer_size] = '\0'; |
| 208 EXPECT_TRUE(non_sdch_content == output_buffer); | 207 EXPECT_TRUE(non_gzip_content == output_buffer); |
| 209 EXPECT_EQ(Filter::FILTER_NEED_MORE_DATA, status); | 208 EXPECT_EQ(Filter::FILTER_NEED_MORE_DATA, status); |
| 210 } | 209 } |
| 211 | 210 |
| 212 TEST_F(SdchFilterTest, RefreshBadReturnCode) { | 211 TEST_F(SdchFilterTest, RefreshBadReturnCode) { |
| 213 std::vector<Filter::FilterType> filter_types; | 212 std::vector<Filter::FilterType> filter_types; |
| 214 // Selective a tentative filter (which can fall back to pass through). | 213 // Selective a tentative filter (which can fall back to pass through). |
| 215 filter_types.push_back(Filter::FILTER_TYPE_SDCH_POSSIBLE); | 214 filter_types.push_back(Filter::FILTER_TYPE_SDCH_POSSIBLE); |
| 216 const int kInputBufferSize(30); | 215 const int kInputBufferSize(30); |
| 217 char output_buffer[20]; | 216 char output_buffer[20]; |
| 218 MockFilterContext filter_context(kInputBufferSize); | 217 MockFilterContext filter_context(kInputBufferSize); |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 // Only claim to have sdch content, but really use the gzipped sdch content. | 925 // Only claim to have sdch content, but really use the gzipped sdch content. |
| 927 // System should automatically add the missing (optional) gzip. | 926 // System should automatically add the missing (optional) gzip. |
| 928 std::vector<Filter::FilterType> filter_types; | 927 std::vector<Filter::FilterType> filter_types; |
| 929 filter_types.push_back(Filter::FILTER_TYPE_SDCH); | 928 filter_types.push_back(Filter::FILTER_TYPE_SDCH); |
| 930 | 929 |
| 931 const int kInputBufferSize(100); | 930 const int kInputBufferSize(100); |
| 932 MockFilterContext filter_context(kInputBufferSize); | 931 MockFilterContext filter_context(kInputBufferSize); |
| 933 filter_context.SetMimeType("anything/mime"); | 932 filter_context.SetMimeType("anything/mime"); |
| 934 filter_context.SetSdchResponse(true); | 933 filter_context.SetSdchResponse(true); |
| 935 Filter::FixupEncodingTypes(filter_context, &filter_types); | 934 Filter::FixupEncodingTypes(filter_context, &filter_types); |
| 935 ASSERT_EQ(filter_types.size(), 2u); |
| 936 EXPECT_EQ(filter_types[0], Filter::FILTER_TYPE_SDCH); |
| 937 EXPECT_EQ(filter_types[1], Filter::FILTER_TYPE_GZIP_HELPING_SDCH); |
| 936 | 938 |
| 937 // First try with a large buffer (larger than test input, or compressed data). | 939 // First try with a large buffer (larger than test input, or compressed data). |
| 938 filter_context.SetURL(url); | 940 filter_context.SetURL(url); |
| 939 scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); | 941 scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); |
| 940 | 942 |
| 941 | 943 |
| 942 // Verify that chained filter is waiting for data. | 944 // Verify that chained filter is waiting for data. |
| 943 char tiny_output_buffer[10]; | 945 char tiny_output_buffer[10]; |
| 944 int tiny_output_size = sizeof(tiny_output_buffer); | 946 int tiny_output_size = sizeof(tiny_output_buffer); |
| 945 EXPECT_EQ(Filter::FILTER_NEED_MORE_DATA, | 947 EXPECT_EQ(Filter::FILTER_NEED_MORE_DATA, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 956 filter.reset(Filter::Factory(filter_types, filter_context)); | 958 filter.reset(Filter::Factory(filter_types, filter_context)); |
| 957 | 959 |
| 958 feed_block_size = 1; | 960 feed_block_size = 1; |
| 959 output_block_size = 1; | 961 output_block_size = 1; |
| 960 output.clear(); | 962 output.clear(); |
| 961 EXPECT_TRUE(FilterTestData(gzip_compressed_sdch, feed_block_size, | 963 EXPECT_TRUE(FilterTestData(gzip_compressed_sdch, feed_block_size, |
| 962 output_block_size, filter.get(), &output)); | 964 output_block_size, filter.get(), &output)); |
| 963 EXPECT_EQ(output, expanded_); | 965 EXPECT_EQ(output, expanded_); |
| 964 } | 966 } |
| 965 | 967 |
| 968 TEST_F(SdchFilterTest, AcceptGzipSdchIfGzip) { |
| 969 // Construct a valid SDCH dictionary from a VCDIFF dictionary. |
| 970 const std::string kSampleDomain = "sdchtest.com"; |
| 971 std::string dictionary(NewSdchDictionary(kSampleDomain)); |
| 972 |
| 973 std::string url_string = "http://" + kSampleDomain; |
| 974 |
| 975 GURL url(url_string); |
| 976 EXPECT_TRUE(sdch_manager_->AddSdchDictionary(dictionary, url)); |
| 977 |
| 978 std::string sdch_compressed(NewSdchCompressedData(dictionary)); |
| 979 |
| 980 // Use Gzip to compress the sdch sdch_compressed data. |
| 981 std::string gzip_compressed_sdch = gzip_compress(sdch_compressed); |
| 982 |
| 983 // Some proxies strip the content encoding statement down to a mere gzip, but |
| 984 // pass through the original content (with full sdch,gzip encoding). |
| 985 // Only claim to have gzip content, but really use the gzipped sdch content. |
| 986 // System should automatically add the missing (optional) sdch. |
| 987 std::vector<Filter::FilterType> filter_types; |
| 988 filter_types.push_back(Filter::FILTER_TYPE_GZIP); |
| 989 |
| 990 const int kInputBufferSize(100); |
| 991 MockFilterContext filter_context(kInputBufferSize); |
| 992 filter_context.SetMimeType("anything/mime"); |
| 993 filter_context.SetSdchResponse(true); |
| 994 Filter::FixupEncodingTypes(filter_context, &filter_types); |
| 995 ASSERT_EQ(filter_types.size(), 3u); |
| 996 EXPECT_EQ(filter_types[0], Filter::FILTER_TYPE_SDCH_POSSIBLE); |
| 997 EXPECT_EQ(filter_types[1], Filter::FILTER_TYPE_GZIP_HELPING_SDCH); |
| 998 EXPECT_EQ(filter_types[2], Filter::FILTER_TYPE_GZIP); |
| 999 |
| 1000 // First try with a large buffer (larger than test input, or compressed data). |
| 1001 filter_context.SetURL(url); |
| 1002 scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); |
| 1003 |
| 1004 |
| 1005 // Verify that chained filter is waiting for data. |
| 1006 char tiny_output_buffer[10]; |
| 1007 int tiny_output_size = sizeof(tiny_output_buffer); |
| 1008 EXPECT_EQ(Filter::FILTER_NEED_MORE_DATA, |
| 1009 filter->ReadData(tiny_output_buffer, &tiny_output_size)); |
| 1010 |
| 1011 size_t feed_block_size = 100; |
| 1012 size_t output_block_size = 100; |
| 1013 std::string output; |
| 1014 EXPECT_TRUE(FilterTestData(gzip_compressed_sdch, feed_block_size, |
| 1015 output_block_size, filter.get(), &output)); |
| 1016 EXPECT_EQ(output, expanded_); |
| 1017 |
| 1018 // Next try with a tiny buffer to cover edge effects. |
| 1019 filter.reset(Filter::Factory(filter_types, filter_context)); |
| 1020 |
| 1021 feed_block_size = 1; |
| 1022 output_block_size = 1; |
| 1023 output.clear(); |
| 1024 EXPECT_TRUE(FilterTestData(gzip_compressed_sdch, feed_block_size, |
| 1025 output_block_size, filter.get(), &output)); |
| 1026 EXPECT_EQ(output, expanded_); |
| 1027 } |
| 1028 |
| 1029 TEST_F(SdchFilterTest, DefaultSdchGzipIfEmpty) { |
| 1030 // Construct a valid SDCH dictionary from a VCDIFF dictionary. |
| 1031 const std::string kSampleDomain = "sdchtest.com"; |
| 1032 std::string dictionary(NewSdchDictionary(kSampleDomain)); |
| 1033 |
| 1034 std::string url_string = "http://" + kSampleDomain; |
| 1035 |
| 1036 GURL url(url_string); |
| 1037 EXPECT_TRUE(sdch_manager_->AddSdchDictionary(dictionary, url)); |
| 1038 |
| 1039 std::string sdch_compressed(NewSdchCompressedData(dictionary)); |
| 1040 |
| 1041 // Use Gzip to compress the sdch sdch_compressed data. |
| 1042 std::string gzip_compressed_sdch = gzip_compress(sdch_compressed); |
| 1043 |
| 1044 // Only claim to have non-encoded content, but really use the gzipped sdch |
| 1045 // content. |
| 1046 // System should automatically add the missing (optional) sdch,gzip. |
| 1047 std::vector<Filter::FilterType> filter_types; |
| 1048 |
| 1049 const int kInputBufferSize(100); |
| 1050 MockFilterContext filter_context(kInputBufferSize); |
| 1051 filter_context.SetMimeType("anything/mime"); |
| 1052 filter_context.SetSdchResponse(true); |
| 1053 Filter::FixupEncodingTypes(filter_context, &filter_types); |
| 1054 ASSERT_EQ(filter_types.size(), 2u); |
| 1055 EXPECT_EQ(filter_types[0], Filter::FILTER_TYPE_SDCH_POSSIBLE); |
| 1056 EXPECT_EQ(filter_types[1], Filter::FILTER_TYPE_GZIP_HELPING_SDCH); |
| 1057 |
| 1058 // First try with a large buffer (larger than test input, or compressed data). |
| 1059 filter_context.SetURL(url); |
| 1060 scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); |
| 1061 |
| 1062 |
| 1063 // Verify that chained filter is waiting for data. |
| 1064 char tiny_output_buffer[10]; |
| 1065 int tiny_output_size = sizeof(tiny_output_buffer); |
| 1066 EXPECT_EQ(Filter::FILTER_NEED_MORE_DATA, |
| 1067 filter->ReadData(tiny_output_buffer, &tiny_output_size)); |
| 1068 |
| 1069 size_t feed_block_size = 100; |
| 1070 size_t output_block_size = 100; |
| 1071 std::string output; |
| 1072 EXPECT_TRUE(FilterTestData(gzip_compressed_sdch, feed_block_size, |
| 1073 output_block_size, filter.get(), &output)); |
| 1074 EXPECT_EQ(output, expanded_); |
| 1075 |
| 1076 // Next try with a tiny buffer to cover edge effects. |
| 1077 filter.reset(Filter::Factory(filter_types, filter_context)); |
| 1078 |
| 1079 feed_block_size = 1; |
| 1080 output_block_size = 1; |
| 1081 output.clear(); |
| 1082 EXPECT_TRUE(FilterTestData(gzip_compressed_sdch, feed_block_size, |
| 1083 output_block_size, filter.get(), &output)); |
| 1084 EXPECT_EQ(output, expanded_); |
| 1085 } |
| 1086 |
| 1087 TEST_F(SdchFilterTest, AcceptGzipGzipSdchIfGzip) { |
| 1088 // Construct a valid SDCH dictionary from a VCDIFF dictionary. |
| 1089 const std::string kSampleDomain = "sdchtest.com"; |
| 1090 std::string dictionary(NewSdchDictionary(kSampleDomain)); |
| 1091 |
| 1092 std::string url_string = "http://" + kSampleDomain; |
| 1093 |
| 1094 GURL url(url_string); |
| 1095 EXPECT_TRUE(sdch_manager_->AddSdchDictionary(dictionary, url)); |
| 1096 |
| 1097 std::string sdch_compressed(NewSdchCompressedData(dictionary)); |
| 1098 |
| 1099 // Vodaphone (UK) Mobile Broadband provides double gzipped sdch with a content |
| 1100 // encoding of merely gzip (apparently, only listing the extra level of |
| 1101 // wrapper compression they added, but discarding the actual content encoding. |
| 1102 // Use Gzip to double compress the sdch sdch_compressed data. |
| 1103 std::string double_gzip_compressed_sdch = gzip_compress(gzip_compress( |
| 1104 sdch_compressed)); |
| 1105 |
| 1106 // Only claim to have gzip content, but really use the double gzipped sdch |
| 1107 // content. |
| 1108 // System should automatically add the missing (optional) sdch, gzip decoders. |
| 1109 std::vector<Filter::FilterType> filter_types; |
| 1110 filter_types.push_back(Filter::FILTER_TYPE_GZIP); |
| 1111 |
| 1112 const int kInputBufferSize(100); |
| 1113 MockFilterContext filter_context(kInputBufferSize); |
| 1114 filter_context.SetMimeType("anything/mime"); |
| 1115 filter_context.SetSdchResponse(true); |
| 1116 Filter::FixupEncodingTypes(filter_context, &filter_types); |
| 1117 ASSERT_EQ(filter_types.size(), 3u); |
| 1118 EXPECT_EQ(filter_types[0], Filter::FILTER_TYPE_SDCH_POSSIBLE); |
| 1119 EXPECT_EQ(filter_types[1], Filter::FILTER_TYPE_GZIP_HELPING_SDCH); |
| 1120 EXPECT_EQ(filter_types[2], Filter::FILTER_TYPE_GZIP); |
| 1121 |
| 1122 // First try with a large buffer (larger than test input, or compressed data). |
| 1123 filter_context.SetURL(url); |
| 1124 scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); |
| 1125 |
| 1126 |
| 1127 // Verify that chained filter is waiting for data. |
| 1128 char tiny_output_buffer[10]; |
| 1129 int tiny_output_size = sizeof(tiny_output_buffer); |
| 1130 EXPECT_EQ(Filter::FILTER_NEED_MORE_DATA, |
| 1131 filter->ReadData(tiny_output_buffer, &tiny_output_size)); |
| 1132 |
| 1133 size_t feed_block_size = 100; |
| 1134 size_t output_block_size = 100; |
| 1135 std::string output; |
| 1136 EXPECT_TRUE(FilterTestData(double_gzip_compressed_sdch, feed_block_size, |
| 1137 output_block_size, filter.get(), &output)); |
| 1138 EXPECT_EQ(output, expanded_); |
| 1139 |
| 1140 // Next try with a tiny buffer to cover edge effects. |
| 1141 filter.reset(Filter::Factory(filter_types, filter_context)); |
| 1142 |
| 1143 feed_block_size = 1; |
| 1144 output_block_size = 1; |
| 1145 output.clear(); |
| 1146 EXPECT_TRUE(FilterTestData(double_gzip_compressed_sdch, feed_block_size, |
| 1147 output_block_size, filter.get(), &output)); |
| 1148 EXPECT_EQ(output, expanded_); |
| 1149 } |
| 1150 |
| 966 TEST_F(SdchFilterTest, DomainSupported) { | 1151 TEST_F(SdchFilterTest, DomainSupported) { |
| 967 GURL test_url("http://www.test.com"); | 1152 GURL test_url("http://www.test.com"); |
| 968 GURL google_url("http://www.google.com"); | 1153 GURL google_url("http://www.google.com"); |
| 969 | 1154 |
| 970 EXPECT_TRUE(SdchManager::sdch_enabled()); | 1155 EXPECT_TRUE(SdchManager::sdch_enabled()); |
| 971 EXPECT_TRUE(SdchManager::Global()->IsInSupportedDomain(test_url)); | 1156 EXPECT_TRUE(SdchManager::Global()->IsInSupportedDomain(test_url)); |
| 972 sdch_manager_->EnableSdchSupport(".google.com"); | 1157 sdch_manager_->EnableSdchSupport(".google.com"); |
| 973 EXPECT_FALSE(SdchManager::Global()->IsInSupportedDomain(test_url)); | 1158 EXPECT_FALSE(SdchManager::Global()->IsInSupportedDomain(test_url)); |
| 974 EXPECT_TRUE(SdchManager::Global()->IsInSupportedDomain(google_url)); | 1159 EXPECT_TRUE(SdchManager::Global()->IsInSupportedDomain(google_url)); |
| 975 } | 1160 } |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 | 1392 |
| 1208 // And can reset them to false. | 1393 // And can reset them to false. |
| 1209 sdch_manager_->SetAllowLatencyExperiment(url, false); | 1394 sdch_manager_->SetAllowLatencyExperiment(url, false); |
| 1210 EXPECT_FALSE(sdch_manager_->AllowLatencyExperiment(url)); | 1395 EXPECT_FALSE(sdch_manager_->AllowLatencyExperiment(url)); |
| 1211 EXPECT_TRUE(sdch_manager_->AllowLatencyExperiment(url2)); | 1396 EXPECT_TRUE(sdch_manager_->AllowLatencyExperiment(url2)); |
| 1212 | 1397 |
| 1213 sdch_manager_->SetAllowLatencyExperiment(url2, false); | 1398 sdch_manager_->SetAllowLatencyExperiment(url2, false); |
| 1214 EXPECT_FALSE(sdch_manager_->AllowLatencyExperiment(url)); | 1399 EXPECT_FALSE(sdch_manager_->AllowLatencyExperiment(url)); |
| 1215 EXPECT_FALSE(sdch_manager_->AllowLatencyExperiment(url2)); | 1400 EXPECT_FALSE(sdch_manager_->AllowLatencyExperiment(url2)); |
| 1216 } | 1401 } |
| OLD | NEW |