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

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

Issue 501163002: Make URLRequest's constructor private, and make URLRequestContext a friend class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge yet again Created 6 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_factory_impl.h" 5 #include "net/url_request/url_request_job_factory_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h"
8 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
9 #include "net/base/request_priority.h" 10 #include "net/base/request_priority.h"
10 #include "net/url_request/url_request.h" 11 #include "net/url_request/url_request.h"
11 #include "net/url_request/url_request_job.h" 12 #include "net/url_request/url_request_job.h"
12 #include "net/url_request/url_request_test_util.h" 13 #include "net/url_request/url_request_test_util.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace net { 16 namespace net {
16 17
17 namespace { 18 namespace {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 return new MockURLRequestJob( 54 return new MockURLRequestJob(
54 request, 55 request,
55 network_delegate, 56 network_delegate,
56 URLRequestStatus(URLRequestStatus::SUCCESS, OK)); 57 URLRequestStatus(URLRequestStatus::SUCCESS, OK));
57 } 58 }
58 }; 59 };
59 60
60 TEST(URLRequestJobFactoryTest, NoProtocolHandler) { 61 TEST(URLRequestJobFactoryTest, NoProtocolHandler) {
61 TestDelegate delegate; 62 TestDelegate delegate;
62 TestURLRequestContext request_context; 63 TestURLRequestContext request_context;
63 TestURLRequest request( 64 scoped_ptr<URLRequest> request(request_context.CreateRequest(
64 GURL("foo://bar"), DEFAULT_PRIORITY, &delegate, &request_context); 65 GURL("foo://bar"), DEFAULT_PRIORITY, &delegate, NULL));
65 request.Start(); 66 request->Start();
66 67
67 base::MessageLoop::current()->Run(); 68 base::MessageLoop::current()->Run();
68 EXPECT_EQ(URLRequestStatus::FAILED, request.status().status()); 69 EXPECT_EQ(URLRequestStatus::FAILED, request->status().status());
69 EXPECT_EQ(ERR_UNKNOWN_URL_SCHEME, request.status().error()); 70 EXPECT_EQ(ERR_UNKNOWN_URL_SCHEME, request->status().error());
70 } 71 }
71 72
72 TEST(URLRequestJobFactoryTest, BasicProtocolHandler) { 73 TEST(URLRequestJobFactoryTest, BasicProtocolHandler) {
73 TestDelegate delegate; 74 TestDelegate delegate;
74 URLRequestJobFactoryImpl job_factory; 75 URLRequestJobFactoryImpl job_factory;
75 TestURLRequestContext request_context; 76 TestURLRequestContext request_context;
76 request_context.set_job_factory(&job_factory); 77 request_context.set_job_factory(&job_factory);
77 job_factory.SetProtocolHandler("foo", new DummyProtocolHandler); 78 job_factory.SetProtocolHandler("foo", new DummyProtocolHandler);
78 TestURLRequest request( 79 scoped_ptr<URLRequest> request(request_context.CreateRequest(
79 GURL("foo://bar"), DEFAULT_PRIORITY, &delegate, &request_context); 80 GURL("foo://bar"), DEFAULT_PRIORITY, &delegate, NULL));
80 request.Start(); 81 request->Start();
81 82
82 base::MessageLoop::current()->Run(); 83 base::MessageLoop::current()->Run();
83 EXPECT_EQ(URLRequestStatus::SUCCESS, request.status().status()); 84 EXPECT_EQ(URLRequestStatus::SUCCESS, request->status().status());
84 EXPECT_EQ(OK, request.status().error()); 85 EXPECT_EQ(OK, request->status().error());
85 } 86 }
86 87
87 TEST(URLRequestJobFactoryTest, DeleteProtocolHandler) { 88 TEST(URLRequestJobFactoryTest, DeleteProtocolHandler) {
88 URLRequestJobFactoryImpl job_factory; 89 URLRequestJobFactoryImpl job_factory;
89 TestURLRequestContext request_context; 90 TestURLRequestContext request_context;
90 request_context.set_job_factory(&job_factory); 91 request_context.set_job_factory(&job_factory);
91 job_factory.SetProtocolHandler("foo", new DummyProtocolHandler); 92 job_factory.SetProtocolHandler("foo", new DummyProtocolHandler);
92 job_factory.SetProtocolHandler("foo", NULL); 93 job_factory.SetProtocolHandler("foo", NULL);
93 } 94 }
94 95
95 } // namespace 96 } // namespace
96 97
97 } // namespace net 98 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_http_job_unittest.cc ('k') | net/url_request/url_request_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698