| Index: net/filter/filter_unittest.cc
|
| diff --git a/net/filter/filter_unittest.cc b/net/filter/filter_unittest.cc
|
| index 3b912520f82d68a41601cfecaec9fa309357289a..5a6ed6276a74c1d8dd0066defdaf0d544081d840 100644
|
| --- a/net/filter/filter_unittest.cc
|
| +++ b/net/filter/filter_unittest.cc
|
| @@ -2,6 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "net/base/sdch_manager.h"
|
| #include "net/filter/filter.h"
|
| #include "net/filter/mock_filter_context.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| @@ -347,4 +348,36 @@ TEST(FilterTest, SupportedMimeGzip) {
|
| EXPECT_TRUE(encoding_types.empty());
|
| }
|
|
|
| +// Check that Filter::Factory doesn't crash if SDCH is disabled.
|
| +TEST(FilterTest, FilterFactoryWithDisabledSDCHSupport) {
|
| + MockFilterContext filter_context;
|
| +
|
| + // Disable SDCH support
|
| + SdchManager::EnableSdchSupport(false);
|
| + EXPECT_TRUE(SdchManager::Global() == NULL);
|
| + EXPECT_FALSE(SdchManager::sdch_enabled());
|
| +
|
| + std::vector<Filter::FilterType> encoding_types;
|
| + Filter* filter;
|
| +
|
| + // Adding just GZIP should provide valid filter.
|
| + encoding_types.clear();
|
| + encoding_types.push_back(Filter::FILTER_TYPE_GZIP);
|
| + filter = Filter::Factory(encoding_types, filter_context);
|
| + ASSERT_TRUE(filter != NULL);
|
| +
|
| + // Adding just SDCH should provide NULL filter.
|
| + encoding_types.clear();
|
| + encoding_types.push_back(Filter::FILTER_TYPE_SDCH);
|
| + filter = Filter::Factory(encoding_types, filter_context);
|
| + ASSERT_EQ(NULL, filter);
|
| +
|
| + // Adding both GZIP and SDCH should provide NULL filter.
|
| + encoding_types.clear();
|
| + encoding_types.push_back(Filter::FILTER_TYPE_GZIP);
|
| + encoding_types.push_back(Filter::FILTER_TYPE_SDCH);
|
| + filter = Filter::Factory(encoding_types, filter_context);
|
| + ASSERT_EQ(NULL, filter);
|
| +}
|
| +
|
| } // namespace net
|
|
|