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