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

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

Issue 2090613002: Remove calls to deprecated MessageLoop methods in net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 <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"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/run_loop.h"
13 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
14 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
15 #include "net/base/request_priority.h" 16 #include "net/base/request_priority.h"
16 #include "net/url_request/url_request.h" 17 #include "net/url_request/url_request.h"
17 #include "net/url_request/url_request_job.h" 18 #include "net/url_request/url_request_job.h"
18 #include "net/url_request/url_request_test_util.h" 19 #include "net/url_request/url_request_test_util.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 namespace net { 22 namespace net {
22 23
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 } 56 }
56 }; 57 };
57 58
58 TEST(URLRequestJobFactoryTest, NoProtocolHandler) { 59 TEST(URLRequestJobFactoryTest, NoProtocolHandler) {
59 TestDelegate delegate; 60 TestDelegate delegate;
60 TestURLRequestContext request_context; 61 TestURLRequestContext request_context;
61 std::unique_ptr<URLRequest> request(request_context.CreateRequest( 62 std::unique_ptr<URLRequest> request(request_context.CreateRequest(
62 GURL("foo://bar"), DEFAULT_PRIORITY, &delegate)); 63 GURL("foo://bar"), DEFAULT_PRIORITY, &delegate));
63 request->Start(); 64 request->Start();
64 65
65 base::MessageLoop::current()->Run(); 66 base::RunLoop().Run();
66 EXPECT_EQ(URLRequestStatus::FAILED, request->status().status()); 67 EXPECT_EQ(URLRequestStatus::FAILED, request->status().status());
67 EXPECT_EQ(ERR_UNKNOWN_URL_SCHEME, request->status().error()); 68 EXPECT_EQ(ERR_UNKNOWN_URL_SCHEME, request->status().error());
68 } 69 }
69 70
70 TEST(URLRequestJobFactoryTest, BasicProtocolHandler) { 71 TEST(URLRequestJobFactoryTest, BasicProtocolHandler) {
71 TestDelegate delegate; 72 TestDelegate delegate;
72 URLRequestJobFactoryImpl job_factory; 73 URLRequestJobFactoryImpl job_factory;
73 TestURLRequestContext request_context; 74 TestURLRequestContext request_context;
74 request_context.set_job_factory(&job_factory); 75 request_context.set_job_factory(&job_factory);
75 job_factory.SetProtocolHandler("foo", 76 job_factory.SetProtocolHandler("foo",
76 base::WrapUnique(new DummyProtocolHandler)); 77 base::WrapUnique(new DummyProtocolHandler));
77 std::unique_ptr<URLRequest> request(request_context.CreateRequest( 78 std::unique_ptr<URLRequest> request(request_context.CreateRequest(
78 GURL("foo://bar"), DEFAULT_PRIORITY, &delegate)); 79 GURL("foo://bar"), DEFAULT_PRIORITY, &delegate));
79 request->Start(); 80 request->Start();
80 81
81 base::MessageLoop::current()->Run(); 82 base::RunLoop().Run();
82 EXPECT_EQ(URLRequestStatus::SUCCESS, request->status().status()); 83 EXPECT_EQ(URLRequestStatus::SUCCESS, request->status().status());
83 EXPECT_EQ(OK, request->status().error()); 84 EXPECT_EQ(OK, request->status().error());
84 } 85 }
85 86
86 TEST(URLRequestJobFactoryTest, DeleteProtocolHandler) { 87 TEST(URLRequestJobFactoryTest, DeleteProtocolHandler) {
87 URLRequestJobFactoryImpl job_factory; 88 URLRequestJobFactoryImpl job_factory;
88 TestURLRequestContext request_context; 89 TestURLRequestContext request_context;
89 request_context.set_job_factory(&job_factory); 90 request_context.set_job_factory(&job_factory);
90 job_factory.SetProtocolHandler("foo", 91 job_factory.SetProtocolHandler("foo",
91 base::WrapUnique(new DummyProtocolHandler)); 92 base::WrapUnique(new DummyProtocolHandler));
92 job_factory.SetProtocolHandler("foo", nullptr); 93 job_factory.SetProtocolHandler("foo", nullptr);
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_context_builder_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