| OLD | NEW |
| 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/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 base::MessageLoop::current()->Run(); | 72 base::MessageLoop::current()->Run(); |
| 73 EXPECT_EQ(URLRequestStatus::FAILED, request->status().status()); | 73 EXPECT_EQ(URLRequestStatus::FAILED, request->status().status()); |
| 74 EXPECT_EQ(ERR_UNKNOWN_URL_SCHEME, request->status().error()); | 74 EXPECT_EQ(ERR_UNKNOWN_URL_SCHEME, request->status().error()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 TEST(URLRequestJobFactoryTest, BasicProtocolHandler) { | 77 TEST(URLRequestJobFactoryTest, BasicProtocolHandler) { |
| 78 TestDelegate delegate; | 78 TestDelegate delegate; |
| 79 URLRequestJobFactoryImpl job_factory; | 79 URLRequestJobFactoryImpl job_factory; |
| 80 TestURLRequestContext request_context; | 80 TestURLRequestContext request_context; |
| 81 request_context.set_job_factory(&job_factory); | 81 request_context.set_job_factory(&job_factory); |
| 82 job_factory.SetProtocolHandler("foo", new DummyProtocolHandler); | 82 job_factory.SetProtocolHandler("foo", |
| 83 make_scoped_ptr(new DummyProtocolHandler)); |
| 83 scoped_ptr<URLRequest> request(request_context.CreateRequest( | 84 scoped_ptr<URLRequest> request(request_context.CreateRequest( |
| 84 GURL("foo://bar"), DEFAULT_PRIORITY, &delegate)); | 85 GURL("foo://bar"), DEFAULT_PRIORITY, &delegate)); |
| 85 request->Start(); | 86 request->Start(); |
| 86 | 87 |
| 87 base::MessageLoop::current()->Run(); | 88 base::MessageLoop::current()->Run(); |
| 88 EXPECT_EQ(URLRequestStatus::SUCCESS, request->status().status()); | 89 EXPECT_EQ(URLRequestStatus::SUCCESS, request->status().status()); |
| 89 EXPECT_EQ(OK, request->status().error()); | 90 EXPECT_EQ(OK, request->status().error()); |
| 90 } | 91 } |
| 91 | 92 |
| 92 TEST(URLRequestJobFactoryTest, DeleteProtocolHandler) { | 93 TEST(URLRequestJobFactoryTest, DeleteProtocolHandler) { |
| 93 URLRequestJobFactoryImpl job_factory; | 94 URLRequestJobFactoryImpl job_factory; |
| 94 TestURLRequestContext request_context; | 95 TestURLRequestContext request_context; |
| 95 request_context.set_job_factory(&job_factory); | 96 request_context.set_job_factory(&job_factory); |
| 96 job_factory.SetProtocolHandler("foo", new DummyProtocolHandler); | 97 job_factory.SetProtocolHandler("foo", |
| 97 job_factory.SetProtocolHandler("foo", NULL); | 98 make_scoped_ptr(new DummyProtocolHandler)); |
| 99 job_factory.SetProtocolHandler("foo", nullptr); |
| 98 } | 100 } |
| 99 | 101 |
| 100 } // namespace | 102 } // namespace |
| 101 | 103 |
| 102 } // namespace net | 104 } // namespace net |
| OLD | NEW |