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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 }; | 62 }; |
63 | 63 |
64 TEST(URLRequestJobFactoryTest, NoProtocolHandler) { | 64 TEST(URLRequestJobFactoryTest, NoProtocolHandler) { |
65 TestDelegate delegate; | 65 TestDelegate delegate; |
66 TestURLRequestContext request_context; | 66 TestURLRequestContext request_context; |
67 std::unique_ptr<URLRequest> request(request_context.CreateRequest( | 67 std::unique_ptr<URLRequest> request(request_context.CreateRequest( |
68 GURL("foo://bar"), DEFAULT_PRIORITY, &delegate)); | 68 GURL("foo://bar"), DEFAULT_PRIORITY, &delegate)); |
69 request->Start(); | 69 request->Start(); |
70 | 70 |
71 base::RunLoop().Run(); | 71 base::RunLoop().Run(); |
72 EXPECT_EQ(ERR_UNKNOWN_URL_SCHEME, delegate.request_status()); | 72 EXPECT_EQ(URLRequestStatus::FAILED, request->status().status()); |
| 73 EXPECT_THAT(request->status().error(), IsError(ERR_UNKNOWN_URL_SCHEME)); |
73 } | 74 } |
74 | 75 |
75 TEST(URLRequestJobFactoryTest, BasicProtocolHandler) { | 76 TEST(URLRequestJobFactoryTest, BasicProtocolHandler) { |
76 TestDelegate delegate; | 77 TestDelegate delegate; |
77 URLRequestJobFactoryImpl job_factory; | 78 URLRequestJobFactoryImpl job_factory; |
78 TestURLRequestContext request_context; | 79 TestURLRequestContext request_context; |
79 request_context.set_job_factory(&job_factory); | 80 request_context.set_job_factory(&job_factory); |
80 job_factory.SetProtocolHandler("foo", | 81 job_factory.SetProtocolHandler("foo", |
81 base::WrapUnique(new DummyProtocolHandler)); | 82 base::WrapUnique(new DummyProtocolHandler)); |
82 std::unique_ptr<URLRequest> request(request_context.CreateRequest( | 83 std::unique_ptr<URLRequest> request(request_context.CreateRequest( |
83 GURL("foo://bar"), DEFAULT_PRIORITY, &delegate)); | 84 GURL("foo://bar"), DEFAULT_PRIORITY, &delegate)); |
84 request->Start(); | 85 request->Start(); |
85 | 86 |
86 base::RunLoop().Run(); | 87 base::RunLoop().Run(); |
87 EXPECT_EQ(OK, delegate.request_status()); | 88 EXPECT_EQ(URLRequestStatus::SUCCESS, request->status().status()); |
| 89 EXPECT_THAT(request->status().error(), IsOk()); |
88 } | 90 } |
89 | 91 |
90 TEST(URLRequestJobFactoryTest, DeleteProtocolHandler) { | 92 TEST(URLRequestJobFactoryTest, DeleteProtocolHandler) { |
91 URLRequestJobFactoryImpl job_factory; | 93 URLRequestJobFactoryImpl job_factory; |
92 TestURLRequestContext request_context; | 94 TestURLRequestContext request_context; |
93 request_context.set_job_factory(&job_factory); | 95 request_context.set_job_factory(&job_factory); |
94 job_factory.SetProtocolHandler("foo", | 96 job_factory.SetProtocolHandler("foo", |
95 base::WrapUnique(new DummyProtocolHandler)); | 97 base::WrapUnique(new DummyProtocolHandler)); |
96 job_factory.SetProtocolHandler("foo", nullptr); | 98 job_factory.SetProtocolHandler("foo", nullptr); |
97 } | 99 } |
98 | 100 |
99 } // namespace | 101 } // namespace |
100 | 102 |
101 } // namespace net | 103 } // namespace net |
OLD | NEW |