summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-25 00:22:02 +0000
committerjar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-25 00:22:02 +0000
commitd6c7938dcdc49d3477642af60ae23aa3cc2750be (patch)
tree0d91a71d6dacb8dd126ea98376ca8e8ee96ed68b
parente2951cf3bd7e591a64ad5199a61531dac0ec58d2 (diff)
downloadchromium_src-d6c7938dcdc49d3477642af60ae23aa3cc2750be.zip
chromium_src-d6c7938dcdc49d3477642af60ae23aa3cc2750be.tar.gz
chromium_src-d6c7938dcdc49d3477642af60ae23aa3cc2750be.tar.bz2
Correct typo in SDCH (filter chaining) unit test, and enable test
A line got deleted between testing and landing, which caused the chaining test to break. I disabled the chaining test when the tree went red, but this CL has the one-line fix (to the test). I also found that the last series of edits (switching to using status of FILTER_NEED_MORE_DATA rather than an empty input buffer) was not completely tested :-(. This also explains how I added the typo to the test but did not notice it. :-( :-( This too had a required one line of editing (in the filter constructor to use that status at startup). I then added a test line to catch the constructor problem, and did a bit of lint cleanup. Remaining TODO items center on: a) Security restriction changes and/or tests. b) Error recovery from network stripping of protocol headers (some proxy servers may strip headers, and require SDCH to be disabled along with output a meta-refresh page (hack)). r=huanr Review URL: http://codereview.chromium.org/4219 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2582 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/base/filter.cc2
-rw-r--r--net/base/sdch_filter_unitest.cc17
2 files changed, 13 insertions, 6 deletions
diff --git a/net/base/filter.cc b/net/base/filter.cc
index f6a114a..577e232 100644
--- a/net/base/filter.cc
+++ b/net/base/filter.cc
@@ -142,7 +142,7 @@ Filter::Filter()
next_stream_data_(NULL),
stream_data_len_(0),
next_filter_(NULL),
- last_status_(FILTER_OK) {
+ last_status_(FILTER_NEED_MORE_DATA) {
}
Filter::~Filter() {}
diff --git a/net/base/sdch_filter_unitest.cc b/net/base/sdch_filter_unitest.cc
index 6cfd1ce..7ba02fe 100644
--- a/net/base/sdch_filter_unitest.cc
+++ b/net/base/sdch_filter_unitest.cc
@@ -226,7 +226,7 @@ TEST_F(SdchFilterTest, BasicDictionary) {
status = FilterTestData(compressed, feed_block_size, output_block_size,
filter.get(), &output);
EXPECT_FALSE(status); // Couldn't decode.
- EXPECT_TRUE(output == ""); // No output written.
+ EXPECT_EQ(output.size(), 0u); // No output written.
// Now check that path restrictions on dictionary are being enforced.
@@ -269,7 +269,7 @@ TEST_F(SdchFilterTest, BasicDictionary) {
status = FilterTestData(compressed_for_path, feed_block_size,
output_block_size, filter.get(), &output);
EXPECT_FALSE(status); // Couldn't decode.
- EXPECT_TRUE(output == ""); // No output written.
+ EXPECT_EQ(output.size(), 0u); // No output written.
// Create a dictionary with a port restriction, by prefixing old dictionary.
@@ -324,7 +324,7 @@ TEST_F(SdchFilterTest, BasicDictionary) {
status = FilterTestData(compressed_for_port, feed_block_size,
output_block_size, filter.get(), &output);
EXPECT_FALSE(status); // Couldn't decode.
- EXPECT_TRUE(output == ""); // No output written.
+ EXPECT_EQ(output.size(), 0u); // No output written.
}
@@ -332,8 +332,9 @@ TEST_F(SdchFilterTest, BasicDictionary) {
// is processed by the next one. This is most critical for SDCH, which is
// routinely followed by gzip (during encoding). The filter we'll test for will
// do the gzip decoding first, and then decode the SDCH content.
-// TODO(jar): Enable test which fails in net_unittests.exe
-TEST_F(SdchFilterTest, DISABLED_FilterChaining) {
+TEST_F(SdchFilterTest, FilterChaining) {
+ SdchManager::enable_sdch_support("");
+
const std::string kSampleDomain = "sdchtest.com";
// Construct a valid SDCH dictionary from a VCDIFF dictionary.
@@ -418,6 +419,12 @@ TEST_F(SdchFilterTest, DISABLED_FilterChaining) {
kInputBufferSize));
filter->SetURL(url);
+ // Verify that chained filter is waiting for data.
+ char tiny_output_buffer[10];
+ int tiny_output_size = sizeof(tiny_output_buffer);
+ EXPECT_EQ(Filter::FILTER_NEED_MORE_DATA,
+ filter->ReadData(tiny_output_buffer, &tiny_output_size));
+
size_t feed_block_size = 100;
size_t output_block_size = 100;
std::string output;