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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_request_job.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/url_request/url_request_job.h"
6
7 #include "net/http/http_transaction_unittest.h"
8 #include "net/url_request/url_request_test_util.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace {
12
13 // This is a header that signals the end of the data.
14 const char kGzipGata[] = "\x1f\x08b\x08\0\0\0\0\0\0\3\3\0\0\0\0\0\0\0\0";
15
16 void GZipServer(const net::HttpRequestInfo* request,
17 std::string* response_status, std::string* response_headers,
18 std::string* response_data) {
19 response_data->assign(kGzipGata, sizeof(kGzipGata));
20 }
21
22 const MockTransaction kGZip_Transaction = {
23 "http://www.google.com/gzyp",
24 "GET",
25 base::Time(),
26 "",
27 net::LOAD_NORMAL,
28 "HTTP/1.1 200 OK",
29 "Cache-Control: max-age=10000\n"
30 "Content-Encoding: gzip\n"
31 "Content-Length: 30\n", // Intentionally wrong.
32 base::Time(),
33 "",
34 TEST_MODE_NORMAL,
35 &GZipServer,
36 0
37 };
38
39 } // namespace
40
41 TEST(URLRequestJob, TransactionNotifiedWhenDone) {
42 TestDelegate d;
43 TestURLRequest req(GURL(kGZip_Transaction.url), &d);
44 MockNetworkLayer network_layer;
45
46 AddMockTransaction(&kGZip_Transaction);
47
48 scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext());
49 context->set_http_transaction_factory(&network_layer);
50 req.set_context(context);
51 req.set_method("GET");
52 req.Start();
53
54 MessageLoop::current()->Run();
55
56 EXPECT_TRUE(network_layer.done_reading_called());
57
58 RemoveMockTransaction(&kGZip_Transaction);
59 }
60
61 TEST(URLRequestJob, SyncTransactionNotifiedWhenDone) {
62 TestDelegate d;
63 TestURLRequest req(GURL(kGZip_Transaction.url), &d);
64 MockNetworkLayer network_layer;
65
66 MockTransaction transaction(kGZip_Transaction);
67 transaction.test_mode = TEST_MODE_SYNC_ALL;
68 AddMockTransaction(&transaction);
69
70 scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext());
71 context->set_http_transaction_factory(&network_layer);
72 req.set_context(context);
73 req.set_method("GET");
74 req.Start();
75
76 MessageLoop::current()->Run();
77
78 EXPECT_TRUE(network_layer.done_reading_called());
79
80 RemoveMockTransaction(&transaction);
81 }
OLDNEW
« 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