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

Unified Diff: net/url_request/url_request_job_unittest.cc

Issue 7569027: net: Notify the http job and cache transaction about a filter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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/url_request/url_request_job.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_job_unittest.cc
===================================================================
--- net/url_request/url_request_job_unittest.cc (revision 0)
+++ net/url_request/url_request_job_unittest.cc (revision 0)
@@ -0,0 +1,81 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/url_request/url_request_job.h"
+
+#include "net/http/http_transaction_unittest.h"
+#include "net/url_request/url_request_test_util.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+// This is a header that signals the end of the data.
+const char kGzipGata[] = "\x1f\x08b\x08\0\0\0\0\0\0\3\3\0\0\0\0\0\0\0\0";
+
+void GZipServer(const net::HttpRequestInfo* request,
+ std::string* response_status, std::string* response_headers,
+ std::string* response_data) {
+ response_data->assign(kGzipGata, sizeof(kGzipGata));
+}
+
+const MockTransaction kGZip_Transaction = {
+ "http://www.google.com/gzyp",
+ "GET",
+ base::Time(),
+ "",
+ net::LOAD_NORMAL,
+ "HTTP/1.1 200 OK",
+ "Cache-Control: max-age=10000\n"
+ "Content-Encoding: gzip\n"
+ "Content-Length: 30\n", // Intentionally wrong.
+ base::Time(),
+ "",
+ TEST_MODE_NORMAL,
+ &GZipServer,
+ 0
+};
+
+} // namespace
+
+TEST(URLRequestJob, TransactionNotifiedWhenDone) {
+ TestDelegate d;
+ TestURLRequest req(GURL(kGZip_Transaction.url), &d);
+ MockNetworkLayer network_layer;
+
+ AddMockTransaction(&kGZip_Transaction);
+
+ scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext());
+ context->set_http_transaction_factory(&network_layer);
+ req.set_context(context);
+ req.set_method("GET");
+ req.Start();
+
+ MessageLoop::current()->Run();
+
+ EXPECT_TRUE(network_layer.done_reading_called());
+
+ RemoveMockTransaction(&kGZip_Transaction);
+}
+
+TEST(URLRequestJob, SyncTransactionNotifiedWhenDone) {
+ TestDelegate d;
+ TestURLRequest req(GURL(kGZip_Transaction.url), &d);
+ MockNetworkLayer network_layer;
+
+ MockTransaction transaction(kGZip_Transaction);
+ transaction.test_mode = TEST_MODE_SYNC_ALL;
+ AddMockTransaction(&transaction);
+
+ scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext());
+ context->set_http_transaction_factory(&network_layer);
+ req.set_context(context);
+ req.set_method("GET");
+ req.Start();
+
+ MessageLoop::current()->Run();
+
+ EXPECT_TRUE(network_layer.done_reading_called());
+
+ RemoveMockTransaction(&transaction);
+}
Property changes on: net\url_request\url_request_job_unittest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « net/url_request/url_request_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698