Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Unified Diff: net/filter/filter_unittest.cc

Issue 166273004: Check that Filter::Factory doesn't crash if SDCH is disabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698