Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ios/components/io_thread/io_thread.h" | |
| 6 | |
| 7 #include "base/message_loop/message_loop.h" | |
| 8 #include "base/run_loop.h" | |
| 9 #include "components/prefs/pref_registry_simple.h" | |
| 10 #include "components/prefs/pref_service.h" | |
| 11 #include "components/prefs/pref_service_factory.h" | |
| 12 #include "components/prefs/testing_pref_store.h" | |
| 13 #include "components/proxy_config/pref_proxy_config_tracker_impl.h" | |
| 14 #include "components/ssl_config/ssl_config_service_manager.h" | |
| 15 #include "ios/web/public/test/test_web_thread.h" | |
| 16 #include "net/base/network_delegate_impl.h" | |
| 17 #include "net/test/url_request/url_request_failed_job.h" | |
| 18 #include "net/url_request/url_request_filter.h" | |
| 19 #include "testing/gtest/include/gtest/gtest.h" | |
| 20 #include "testing/gtest_mac.h" | |
| 21 #include "testing/platform_test.h" | |
| 22 | |
| 23 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 24 #error "This file requires ARC support." | |
| 25 #endif | |
| 26 | |
| 27 namespace { | |
| 28 | |
| 29 // A concrete implementation of IOThread for testing. | |
| 30 class TestIOThread : public io_thread::IOThread { | |
| 31 public: | |
| 32 TestIOThread(PrefService* local_state, net_log::ChromeNetLog* net_log) | |
| 33 : IOThread(local_state, net_log) {} | |
| 34 ~TestIOThread() override {} | |
| 35 | |
| 36 // Dummy implementations of virtual methods. | |
| 37 std::unique_ptr<net::NetworkDelegate> GetSystemNetworkDelegate() override { | |
| 38 return base::MakeUnique<net::NetworkDelegateImpl>(); | |
| 39 } | |
| 40 }; | |
| 41 | |
| 42 } // namespace | |
| 43 | |
| 44 class IOThreadTest : public PlatformTest { | |
| 45 public: | |
| 46 IOThreadTest() | |
| 47 : loop_(base::MessageLoop::TYPE_IO), | |
| 48 ui_thread_(web::WebThread::UI, &loop_), | |
| 49 io_thread_(web::WebThread::IO, &loop_) { | |
| 50 net::URLRequestFailedJob::AddUrlHandler(); | |
| 51 } | |
| 52 | |
| 53 ~IOThreadTest() override { | |
| 54 net::URLRequestFilter::GetInstance()->ClearHandlers(); | |
| 55 } | |
| 56 | |
| 57 private: | |
| 58 base::MessageLoop loop_; | |
| 59 web::TestWebThread ui_thread_; | |
| 60 web::TestWebThread io_thread_; | |
| 61 }; | |
| 62 | |
| 63 TEST_F(IOThreadTest, AssertSystemUrlRequestContext) { | |
|
Eugene But (OOO till 7-30)
2017/05/25 22:05:22
Please add comments describing what is tested here
michaeldo
2017/05/26 07:24:44
Done.
| |
| 64 PrefServiceFactory pref_service_factory; | |
| 65 pref_service_factory.set_user_prefs( | |
| 66 make_scoped_refptr(new TestingPrefStore())); | |
| 67 | |
| 68 scoped_refptr<PrefRegistrySimple> pref_registry = new PrefRegistrySimple; | |
| 69 PrefProxyConfigTrackerImpl::RegisterPrefs(pref_registry.get()); | |
| 70 ssl_config::SSLConfigServiceManager::RegisterPrefs(pref_registry.get()); | |
| 71 | |
| 72 std::unique_ptr<PrefService> pref_service( | |
| 73 pref_service_factory.Create(pref_registry.get())); | |
| 74 | |
| 75 std::unique_ptr<TestIOThread> test_io_thread( | |
| 76 new TestIOThread(pref_service.get(), nullptr)); | |
| 77 | |
| 78 ASSERT_TRUE(test_io_thread->system_url_request_context_getter()); | |
| 79 } | |
| OLD | NEW |