| 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/base/sdch_manager.h" |
| 5 #include "net/filter/filter.h" | 6 #include "net/filter/filter.h" |
| 6 #include "net/filter/mock_filter_context.h" | 7 #include "net/filter/mock_filter_context.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 9 |
| 9 namespace net { | 10 namespace net { |
| 10 | 11 |
| 11 class FilterTest : public testing::Test { | 12 class FilterTest : public testing::Test { |
| 12 }; | 13 }; |
| 13 | 14 |
| 14 TEST(FilterTest, ContentTypeId) { | 15 TEST(FilterTest, ContentTypeId) { |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 // Except on downloads, where they just get saved. | 341 // Except on downloads, where they just get saved. |
| 341 encoding_types.clear(); | 342 encoding_types.clear(); |
| 342 encoding_types.push_back(Filter::FILTER_TYPE_GZIP); | 343 encoding_types.push_back(Filter::FILTER_TYPE_GZIP); |
| 343 filter_context.SetDownload(true); | 344 filter_context.SetDownload(true); |
| 344 filter_context.SetMimeType(kHtmlMime); | 345 filter_context.SetMimeType(kHtmlMime); |
| 345 filter_context.SetURL(GURL(kGzUrl)); | 346 filter_context.SetURL(GURL(kGzUrl)); |
| 346 Filter::FixupEncodingTypes(filter_context, &encoding_types); | 347 Filter::FixupEncodingTypes(filter_context, &encoding_types); |
| 347 EXPECT_TRUE(encoding_types.empty()); | 348 EXPECT_TRUE(encoding_types.empty()); |
| 348 } | 349 } |
| 349 | 350 |
| 351 // Check that Filter::Factory doesn't crash if SDCH is disabled. |
| 352 TEST(FilterTest, FilterFactoryWithDisabledSDCHSupport) { |
| 353 MockFilterContext filter_context; |
| 354 |
| 355 // Disable SDCH support |
| 356 SdchManager::EnableSdchSupport(false); |
| 357 EXPECT_TRUE(SdchManager::Global() == NULL); |
| 358 EXPECT_FALSE(SdchManager::sdch_enabled()); |
| 359 |
| 360 std::vector<Filter::FilterType> encoding_types; |
| 361 Filter* filter; |
| 362 |
| 363 // Adding just GZIP should provide valid filter. |
| 364 encoding_types.clear(); |
| 365 encoding_types.push_back(Filter::FILTER_TYPE_GZIP); |
| 366 filter = Filter::Factory(encoding_types, filter_context); |
| 367 ASSERT_TRUE(filter != NULL); |
| 368 |
| 369 // Adding just SDCH should provide NULL filter. |
| 370 encoding_types.clear(); |
| 371 encoding_types.push_back(Filter::FILTER_TYPE_SDCH); |
| 372 filter = Filter::Factory(encoding_types, filter_context); |
| 373 ASSERT_EQ(NULL, filter); |
| 374 |
| 375 // Adding both GZIP and SDCH should provide NULL filter. |
| 376 encoding_types.clear(); |
| 377 encoding_types.push_back(Filter::FILTER_TYPE_GZIP); |
| 378 encoding_types.push_back(Filter::FILTER_TYPE_SDCH); |
| 379 filter = Filter::Factory(encoding_types, filter_context); |
| 380 ASSERT_EQ(NULL, filter); |
| 381 } |
| 382 |
| 350 } // namespace net | 383 } // namespace net |
| OLD | NEW |