OLD | NEW |
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 "net/filter/filter.h" | 5 #include "net/filter/filter.h" |
6 #include "net/filter/mock_filter_context.h" | 6 #include "net/filter/mock_filter_context.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 // Check to be sure that gzip can survive with other mime types. | 76 // Check to be sure that gzip can survive with other mime types. |
77 encoding_types.clear(); | 77 encoding_types.clear(); |
78 encoding_types.push_back(Filter::FILTER_TYPE_GZIP); | 78 encoding_types.push_back(Filter::FILTER_TYPE_GZIP); |
79 filter_context.SetMimeType("other/mime"); | 79 filter_context.SetMimeType("other/mime"); |
80 Filter::FixupEncodingTypes(filter_context, &encoding_types); | 80 Filter::FixupEncodingTypes(filter_context, &encoding_types); |
81 ASSERT_EQ(1U, encoding_types.size()); | 81 ASSERT_EQ(1U, encoding_types.size()); |
82 EXPECT_EQ(Filter::FILTER_TYPE_GZIP, encoding_types.front()); | 82 EXPECT_EQ(Filter::FILTER_TYPE_GZIP, encoding_types.front()); |
83 } | 83 } |
84 | 84 |
| 85 TEST(FilterTest, GzipContentDispositionFilename) { |
| 86 MockFilterContext filter_context; |
| 87 filter_context.SetSdchResponse(false); |
| 88 |
| 89 const std::string kGzipMime("application/x-tar"); |
| 90 const std::string kContentDisposition("attachment; filename=\"foo.tgz\""); |
| 91 const std::string kURL("http://foo.com/getfoo.php"); |
| 92 std::vector<Filter::FilterType> encoding_types; |
| 93 |
| 94 encoding_types.push_back(Filter::FILTER_TYPE_GZIP); |
| 95 filter_context.SetMimeType(kGzipMime); |
| 96 filter_context.SetURL(GURL(kURL)); |
| 97 filter_context.SetContentDisposition(kContentDisposition); |
| 98 Filter::FixupEncodingTypes(filter_context, &encoding_types); |
| 99 ASSERT_EQ(0U, encoding_types.size()); |
| 100 } |
| 101 |
85 TEST(FilterTest, SdchEncoding) { | 102 TEST(FilterTest, SdchEncoding) { |
86 // Handle content encodings including SDCH. | 103 // Handle content encodings including SDCH. |
87 const std::string kTextHtmlMime("text/html"); | 104 const std::string kTextHtmlMime("text/html"); |
88 MockFilterContext filter_context; | 105 MockFilterContext filter_context; |
89 filter_context.SetSdchResponse(true); | 106 filter_context.SetSdchResponse(true); |
90 | 107 |
91 std::vector<Filter::FilterType> encoding_types; | 108 std::vector<Filter::FilterType> encoding_types; |
92 | 109 |
93 // Check for most common encoding, and verify it survives unchanged. | 110 // Check for most common encoding, and verify it survives unchanged. |
94 encoding_types.clear(); | 111 encoding_types.clear(); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 encoding_types.clear(); | 358 encoding_types.clear(); |
342 encoding_types.push_back(Filter::FILTER_TYPE_GZIP); | 359 encoding_types.push_back(Filter::FILTER_TYPE_GZIP); |
343 filter_context.SetDownload(true); | 360 filter_context.SetDownload(true); |
344 filter_context.SetMimeType(kHtmlMime); | 361 filter_context.SetMimeType(kHtmlMime); |
345 filter_context.SetURL(GURL(kGzUrl)); | 362 filter_context.SetURL(GURL(kGzUrl)); |
346 Filter::FixupEncodingTypes(filter_context, &encoding_types); | 363 Filter::FixupEncodingTypes(filter_context, &encoding_types); |
347 EXPECT_TRUE(encoding_types.empty()); | 364 EXPECT_TRUE(encoding_types.empty()); |
348 } | 365 } |
349 | 366 |
350 } // namespace net | 367 } // namespace net |
OLD | NEW |