| Index: ios/components/io_thread/ios_io_thread_unittest.mm
|
| diff --git a/ios/components/io_thread/ios_io_thread_unittest.mm b/ios/components/io_thread/ios_io_thread_unittest.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a01ab20fb25638e20bba4622b3e48307408c3285
|
| --- /dev/null
|
| +++ b/ios/components/io_thread/ios_io_thread_unittest.mm
|
| @@ -0,0 +1,81 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ios/components/io_thread/ios_io_thread.h"
|
| +
|
| +#include "base/message_loop/message_loop.h"
|
| +#include "base/run_loop.h"
|
| +#include "components/prefs/pref_registry_simple.h"
|
| +#include "components/prefs/pref_service.h"
|
| +#include "components/prefs/pref_service_factory.h"
|
| +#include "components/prefs/testing_pref_store.h"
|
| +#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
|
| +#include "components/ssl_config/ssl_config_service_manager.h"
|
| +#include "ios/web/public/test/test_web_thread.h"
|
| +#include "net/test/url_request/url_request_failed_job.h"
|
| +#include "net/url_request/url_request_filter.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "testing/gtest_mac.h"
|
| +#include "testing/platform_test.h"
|
| +
|
| +#if !defined(__has_feature) || !__has_feature(objc_arc)
|
| +#error "This file requires ARC support."
|
| +#endif
|
| +
|
| +namespace {
|
| +
|
| +// A concrete implementation of IOThread for testing.
|
| +class TestIOThread : public io_thread::IOSIOThread {
|
| + public:
|
| + TestIOThread(PrefService* local_state, net_log::ChromeNetLog* net_log)
|
| + : IOSIOThread(local_state, net_log) {}
|
| + ~TestIOThread() override {}
|
| +
|
| + // Dummy implementations of virtual methods.
|
| + std::unique_ptr<net::NetworkDelegate> CreateSystemNetworkDelegate() override {
|
| + return nullptr;
|
| + }
|
| + std::string GetChannelString() const override { return std::string(); }
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +class IOSIOThreadTest : public PlatformTest {
|
| + public:
|
| + IOSIOThreadTest()
|
| + : loop_(base::MessageLoop::TYPE_IO),
|
| + ui_thread_(web::WebThread::UI, &loop_),
|
| + io_thread_(web::WebThread::IO, &loop_) {
|
| + net::URLRequestFailedJob::AddUrlHandler();
|
| + }
|
| +
|
| + ~IOSIOThreadTest() override {
|
| + net::URLRequestFilter::GetInstance()->ClearHandlers();
|
| + }
|
| +
|
| + private:
|
| + base::MessageLoop loop_;
|
| + web::TestWebThread ui_thread_;
|
| + web::TestWebThread io_thread_;
|
| +};
|
| +
|
| +// Tests the creation of an IOSIOThread and verifies that it returns a system
|
| +// url request context.
|
| +TEST_F(IOSIOThreadTest, AssertSystemUrlRequestContext) {
|
| + PrefServiceFactory pref_service_factory;
|
| + pref_service_factory.set_user_prefs(
|
| + make_scoped_refptr(new TestingPrefStore()));
|
| +
|
| + scoped_refptr<PrefRegistrySimple> pref_registry = new PrefRegistrySimple;
|
| + PrefProxyConfigTrackerImpl::RegisterPrefs(pref_registry.get());
|
| + ssl_config::SSLConfigServiceManager::RegisterPrefs(pref_registry.get());
|
| +
|
| + std::unique_ptr<PrefService> pref_service(
|
| + pref_service_factory.Create(pref_registry.get()));
|
| +
|
| + std::unique_ptr<TestIOThread> test_io_thread(
|
| + new TestIOThread(pref_service.get(), nullptr));
|
| +
|
| + ASSERT_TRUE(test_io_thread->system_url_request_context_getter());
|
| +}
|
|
|