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

Unified Diff: net/filter/sdch_filter_unittest.cc

Issue 380003002: Improve testing for SDCH. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed Isolation test for ChromeOS. Created 6 years, 4 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 | « net/filter/mock_filter_context.cc ('k') | net/http/http_transaction_test_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/filter/sdch_filter_unittest.cc
diff --git a/net/filter/sdch_filter_unittest.cc b/net/filter/sdch_filter_unittest.cc
index 28da615c2e90bedd4b5c01dadf6ade807f8576f6..88a9c392bd81a69ec8ddde883c8691e34362bd99 100644
--- a/net/filter/sdch_filter_unittest.cc
+++ b/net/filter/sdch_filter_unittest.cc
@@ -165,6 +165,25 @@ TEST_F(SdchFilterTest, EmptyInputOk) {
filter_context()->SetURL(GURL(url_string));
scoped_ptr<Filter> filter(Filter::Factory(filter_types, *filter_context()));
+ // With no input data, try to read output.
+ int output_bytes_or_buffer_size = sizeof(output_buffer);
+ Filter::FilterStatus status = filter->ReadData(output_buffer,
+ &output_bytes_or_buffer_size);
+
+ EXPECT_EQ(0, output_bytes_or_buffer_size);
+ EXPECT_EQ(Filter::FILTER_NEED_MORE_DATA, status);
+}
+
+// Make sure that the filter context has everything that might be
+// nuked from it during URLRequest teardown before the SdchFilter
+// destructor.
+TEST_F(SdchFilterTest, SparseContextOk) {
+ std::vector<Filter::FilterType> filter_types;
+ filter_types.push_back(Filter::FILTER_TYPE_SDCH);
+ char output_buffer[20];
+ std::string url_string("http://ignore.com");
+ filter_context()->SetURL(GURL(url_string));
+ scoped_ptr<Filter> filter(Filter::Factory(filter_types, *filter_context()));
// With no input data, try to read output.
int output_bytes_or_buffer_size = sizeof(output_buffer);
@@ -173,6 +192,13 @@ TEST_F(SdchFilterTest, EmptyInputOk) {
EXPECT_EQ(0, output_bytes_or_buffer_size);
EXPECT_EQ(Filter::FILTER_NEED_MORE_DATA, status);
+
+ // Partially tear down context. Anything that goes through request()
+ // without checking it for null in the URLRequestJob::HttpFilterContext
+ // implementation is suspect. Everything that does check it for null should
+ // return null. This is to test for incorrectly relying on filter_context()
+ // from the SdchFilter destructor.
+ filter_context()->NukeUnstableInterfaces();
}
TEST_F(SdchFilterTest, PassThroughWhenTentative) {
« no previous file with comments | « net/filter/mock_filter_context.cc ('k') | net/http/http_transaction_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698