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(URLRequestStatus::FAILED, request->status().status()); | 72 EXPECT_EQ(ERR_UNKNOWN_URL_SCHEME, delegate.request_status()); |
73 EXPECT_THAT(request->status().error(), IsError(ERR_UNKNOWN_URL_SCHEME)); | |
74 } | 73 } |
75 | 74 |
76 TEST(URLRequestJobFactoryTest, BasicProtocolHandler) { | 75 TEST(URLRequestJobFactoryTest, BasicProtocolHandler) { |
77 TestDelegate delegate; | 76 TestDelegate delegate; |
78 URLRequestJobFactoryImpl job_factory; | 77 URLRequestJobFactoryImpl job_factory; |
79 TestURLRequestContext request_context; | 78 TestURLRequestContext request_context; |
80 request_context.set_job_factory(&job_factory); | 79 request_context.set_job_factory(&job_factory); |
81 job_factory.SetProtocolHandler("foo", | 80 job_factory.SetProtocolHandler("foo", |
82 base::WrapUnique(new DummyProtocolHandler)); | 81 base::WrapUnique(new DummyProtocolHandler)); |
83 std::unique_ptr<URLRequest> request(request_context.CreateRequest( | 82 std::unique_ptr<URLRequest> request(request_context.CreateRequest( |
84 GURL("foo://bar"), DEFAULT_PRIORITY, &delegate)); | 83 GURL("foo://bar"), DEFAULT_PRIORITY, &delegate)); |
85 request->Start(); | 84 request->Start(); |
86 | 85 |
87 base::RunLoop().Run(); | 86 base::RunLoop().Run(); |
88 EXPECT_EQ(URLRequestStatus::SUCCESS, request->status().status()); | 87 EXPECT_EQ(OK, delegate.request_status()); |
89 EXPECT_THAT(request->status().error(), IsOk()); | |
90 } | 88 } |
91 | 89 |
92 TEST(URLRequestJobFactoryTest, DeleteProtocolHandler) { | 90 TEST(URLRequestJobFactoryTest, DeleteProtocolHandler) { |
93 URLRequestJobFactoryImpl job_factory; | 91 URLRequestJobFactoryImpl job_factory; |
94 TestURLRequestContext request_context; | 92 TestURLRequestContext request_context; |
95 request_context.set_job_factory(&job_factory); | 93 request_context.set_job_factory(&job_factory); |
96 job_factory.SetProtocolHandler("foo", | 94 job_factory.SetProtocolHandler("foo", |
97 base::WrapUnique(new DummyProtocolHandler)); | 95 base::WrapUnique(new DummyProtocolHandler)); |
98 job_factory.SetProtocolHandler("foo", nullptr); | 96 job_factory.SetProtocolHandler("foo", nullptr); |
99 } | 97 } |
100 | 98 |
101 } // namespace | 99 } // namespace |
102 | 100 |
103 } // namespace net | 101 } // namespace net |
OLD | NEW |