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

Side by Side Diff: net/url_request/url_request_job_unittest.cc

Issue 10299002: Stop refcounting URLRequestContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More fixes Created 8 years, 7 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/url_request/url_request_job.h" 5 #include "net/url_request/url_request_job.h"
6 6
7 #include "net/http/http_transaction_unittest.h" 7 #include "net/http/http_transaction_unittest.h"
8 #include "net/url_request/url_request_test_util.h" 8 #include "net/url_request/url_request_test_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 27 matching lines...) Expand all
38 38
39 } // namespace 39 } // namespace
40 40
41 TEST(URLRequestJob, TransactionNotifiedWhenDone) { 41 TEST(URLRequestJob, TransactionNotifiedWhenDone) {
42 TestDelegate d; 42 TestDelegate d;
43 TestURLRequest req(GURL(kGZip_Transaction.url), &d); 43 TestURLRequest req(GURL(kGZip_Transaction.url), &d);
44 MockNetworkLayer network_layer; 44 MockNetworkLayer network_layer;
45 45
46 AddMockTransaction(&kGZip_Transaction); 46 AddMockTransaction(&kGZip_Transaction);
47 47
48 scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext()); 48 TestURLRequestContext context;
49 context->set_http_transaction_factory(&network_layer); 49 context.set_http_transaction_factory(&network_layer);
50 req.set_context(context); 50 req.set_context(&context);
51 req.set_method("GET"); 51 req.set_method("GET");
52 req.Start(); 52 req.Start();
53 53
54 MessageLoop::current()->Run(); 54 MessageLoop::current()->Run();
55 55
56 EXPECT_TRUE(network_layer.done_reading_called()); 56 EXPECT_TRUE(network_layer.done_reading_called());
57 57
58 RemoveMockTransaction(&kGZip_Transaction); 58 RemoveMockTransaction(&kGZip_Transaction);
59 } 59 }
60 60
61 TEST(URLRequestJob, SyncTransactionNotifiedWhenDone) { 61 TEST(URLRequestJob, SyncTransactionNotifiedWhenDone) {
62 TestDelegate d; 62 TestDelegate d;
63 TestURLRequest req(GURL(kGZip_Transaction.url), &d); 63 TestURLRequest req(GURL(kGZip_Transaction.url), &d);
64 MockNetworkLayer network_layer; 64 MockNetworkLayer network_layer;
65 65
66 MockTransaction transaction(kGZip_Transaction); 66 MockTransaction transaction(kGZip_Transaction);
67 transaction.test_mode = TEST_MODE_SYNC_ALL; 67 transaction.test_mode = TEST_MODE_SYNC_ALL;
68 AddMockTransaction(&transaction); 68 AddMockTransaction(&transaction);
69 69
70 scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext()); 70 TestURLRequestContext context;
71 context->set_http_transaction_factory(&network_layer); 71 context.set_http_transaction_factory(&network_layer);
72 req.set_context(context); 72 req.set_context(&context);
73 req.set_method("GET"); 73 req.set_method("GET");
74 req.Start(); 74 req.Start();
75 75
76 MessageLoop::current()->Run(); 76 MessageLoop::current()->Run();
77 77
78 EXPECT_TRUE(network_layer.done_reading_called()); 78 EXPECT_TRUE(network_layer.done_reading_called());
79 79
80 RemoveMockTransaction(&transaction); 80 RemoveMockTransaction(&transaction);
81 } 81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698