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

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

Issue 2682523002: Use TaskScheduler in directory_lister.cc. (Closed)
Patch Set: remove ScopedTaskScheduler from TokenBindingURLRequestTest Created 3 years, 10 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
« no previous file with comments | « net/url_request/url_request_file_dir_job_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 private: 770 private:
771 bool on_ssl_certificate_error_called_ = false; 771 bool on_ssl_certificate_error_called_ = false;
772 SSLInfo ssl_info_; 772 SSLInfo ssl_info_;
773 }; 773 };
774 774
775 } // namespace 775 } // namespace
776 776
777 // Inherit PlatformTest since we require the autorelease pool on Mac OS X. 777 // Inherit PlatformTest since we require the autorelease pool on Mac OS X.
778 class URLRequestTest : public PlatformTest { 778 class URLRequestTest : public PlatformTest {
779 public: 779 public:
780 URLRequestTest() : default_context_(true) { 780 URLRequestTest()
781 : scoped_task_scheduler_(base::MessageLoop::current()),
782 default_context_(true) {
781 default_context_.set_network_delegate(&default_network_delegate_); 783 default_context_.set_network_delegate(&default_network_delegate_);
782 default_context_.set_net_log(&net_log_); 784 default_context_.set_net_log(&net_log_);
783 job_factory_impl_ = new URLRequestJobFactoryImpl(); 785 job_factory_impl_ = new URLRequestJobFactoryImpl();
784 job_factory_.reset(job_factory_impl_); 786 job_factory_.reset(job_factory_impl_);
785 } 787 }
786 788
787 ~URLRequestTest() override { 789 ~URLRequestTest() override {
788 // URLRequestJobs may post clean-up tasks on destruction. 790 // URLRequestJobs may post clean-up tasks on destruction.
789 base::RunLoop().RunUntilIdle(); 791 base::RunLoop().RunUntilIdle();
790 } 792 }
(...skipping 26 matching lines...) Expand all
817 819
818 // Adds the TestJobInterceptor to the default context. 820 // Adds the TestJobInterceptor to the default context.
819 TestJobInterceptor* AddTestInterceptor() { 821 TestJobInterceptor* AddTestInterceptor() {
820 TestJobInterceptor* protocol_handler_ = new TestJobInterceptor(); 822 TestJobInterceptor* protocol_handler_ = new TestJobInterceptor();
821 job_factory_impl_->SetProtocolHandler("http", nullptr); 823 job_factory_impl_->SetProtocolHandler("http", nullptr);
822 job_factory_impl_->SetProtocolHandler("http", 824 job_factory_impl_->SetProtocolHandler("http",
823 base::WrapUnique(protocol_handler_)); 825 base::WrapUnique(protocol_handler_));
824 return protocol_handler_; 826 return protocol_handler_;
825 } 827 }
826 828
829 private:
830 base::test::ScopedTaskScheduler scoped_task_scheduler_;
831
827 protected: 832 protected:
828 TestNetLog net_log_; 833 TestNetLog net_log_;
829 TestNetworkDelegate default_network_delegate_; // Must outlive URLRequest. 834 TestNetworkDelegate default_network_delegate_; // Must outlive URLRequest.
830 URLRequestJobFactoryImpl* job_factory_impl_; 835 URLRequestJobFactoryImpl* job_factory_impl_;
831 std::unique_ptr<URLRequestJobFactory> job_factory_; 836 std::unique_ptr<URLRequestJobFactory> job_factory_;
832 TestURLRequestContext default_context_; 837 TestURLRequestContext default_context_;
833 }; 838 };
834 839
835 TEST_F(URLRequestTest, AboutBlankTest) { 840 TEST_F(URLRequestTest, AboutBlankTest) {
836 TestDelegate d; 841 TestDelegate d;
(...skipping 2606 matching lines...) Expand 10 before | Expand all | Expand 10 after
3443 const bool online_rev_checking_; 3448 const bool online_rev_checking_;
3444 const bool rev_checking_required_local_anchors_; 3449 const bool rev_checking_required_local_anchors_;
3445 const bool token_binding_enabled_; 3450 const bool token_binding_enabled_;
3446 uint16_t min_version_; 3451 uint16_t min_version_;
3447 }; 3452 };
3448 3453
3449 // TODO(svaldez): Update tests to use EmbeddedTestServer. 3454 // TODO(svaldez): Update tests to use EmbeddedTestServer.
3450 #if !defined(OS_IOS) 3455 #if !defined(OS_IOS)
3451 class TokenBindingURLRequestTest : public URLRequestTestHTTP { 3456 class TokenBindingURLRequestTest : public URLRequestTestHTTP {
3452 public: 3457 public:
3453 TokenBindingURLRequestTest() 3458 TokenBindingURLRequestTest() = default;
3454 : scoped_task_scheduler_(base::MessageLoop::current()) {}
3455 3459
3456 void SetUp() override { 3460 void SetUp() override {
3457 default_context_.set_ssl_config_service( 3461 default_context_.set_ssl_config_service(
3458 new TestSSLConfigService(false, false, false, true)); 3462 new TestSSLConfigService(false, false, false, true));
3459 channel_id_service_.reset( 3463 channel_id_service_.reset(
3460 new ChannelIDService(new DefaultChannelIDStore(NULL))); 3464 new ChannelIDService(new DefaultChannelIDStore(NULL)));
3461 default_context_.set_channel_id_service(channel_id_service_.get()); 3465 default_context_.set_channel_id_service(channel_id_service_.get());
3462 URLRequestTestHTTP::SetUp(); 3466 URLRequestTestHTTP::SetUp();
3463 } 3467 }
3464 3468
3465 protected: 3469 protected:
3466 // Required by ChannelIDService.
3467 base::test::ScopedTaskScheduler scoped_task_scheduler_;
3468 std::unique_ptr<ChannelIDService> channel_id_service_; 3470 std::unique_ptr<ChannelIDService> channel_id_service_;
3469 }; 3471 };
3470 3472
3471 TEST_F(TokenBindingURLRequestTest, TokenBindingTest) { 3473 TEST_F(TokenBindingURLRequestTest, TokenBindingTest) {
3472 SpawnedTestServer::SSLOptions ssl_options; 3474 SpawnedTestServer::SSLOptions ssl_options;
3473 ssl_options.supported_token_binding_params.push_back(TB_PARAM_ECDSAP256); 3475 ssl_options.supported_token_binding_params.push_back(TB_PARAM_ECDSAP256);
3474 SpawnedTestServer https_test_server(SpawnedTestServer::TYPE_HTTPS, 3476 SpawnedTestServer https_test_server(SpawnedTestServer::TYPE_HTTPS,
3475 ssl_options, 3477 ssl_options,
3476 base::FilePath(kTestFilePath)); 3478 base::FilePath(kTestFilePath));
3477 ASSERT_TRUE(https_test_server.Start()); 3479 ASSERT_TRUE(https_test_server.Start());
(...skipping 7389 matching lines...) Expand 10 before | Expand all | Expand 10 after
10867 AddTestInterceptor()->set_main_intercept_job(std::move(job)); 10869 AddTestInterceptor()->set_main_intercept_job(std::move(job));
10868 10870
10869 req->Start(); 10871 req->Start();
10870 req->Cancel(); 10872 req->Cancel();
10871 base::RunLoop().RunUntilIdle(); 10873 base::RunLoop().RunUntilIdle();
10872 EXPECT_EQ(ERR_ABORTED, d.request_status()); 10874 EXPECT_EQ(ERR_ABORTED, d.request_status());
10873 EXPECT_EQ(0, d.received_redirect_count()); 10875 EXPECT_EQ(0, d.received_redirect_count());
10874 } 10876 }
10875 10877
10876 } // namespace net 10878 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_file_dir_job_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698