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

Side by Side Diff: ios/components/io_thread/ios_io_thread_unittest.mm

Issue 2908613002: Move common functionality of IOSChromeIOThread to ios/components. (Closed)
Patch Set: Respond to comments. Created 3 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
« no previous file with comments | « ios/components/io_thread/ios_io_thread.mm ('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
(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/ios_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/test/url_request/url_request_failed_job.h"
17 #include "net/url_request/url_request_filter.h"
18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "testing/gtest_mac.h"
20 #include "testing/platform_test.h"
21
22 #if !defined(__has_feature) || !__has_feature(objc_arc)
23 #error "This file requires ARC support."
24 #endif
25
26 namespace {
27
28 // A concrete implementation of IOThread for testing.
29 class TestIOThread : public io_thread::IOSIOThread {
30 public:
31 TestIOThread(PrefService* local_state, net_log::ChromeNetLog* net_log)
32 : IOSIOThread(local_state, net_log) {}
33 ~TestIOThread() override {}
34
35 // Dummy implementations of virtual methods.
36 std::unique_ptr<net::NetworkDelegate> CreateSystemNetworkDelegate() override {
37 return nullptr;
38 }
39 std::string GetChannelString() const override { return std::string(); }
40 };
41
42 } // namespace
43
44 class IOSIOThreadTest : public PlatformTest {
45 public:
46 IOSIOThreadTest()
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 ~IOSIOThreadTest() 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 // Tests the creation of an IOSIOThread and verifies that it returns a system
64 // url request context.
65 TEST_F(IOSIOThreadTest, AssertSystemUrlRequestContext) {
66 PrefServiceFactory pref_service_factory;
67 pref_service_factory.set_user_prefs(
68 make_scoped_refptr(new TestingPrefStore()));
69
70 scoped_refptr<PrefRegistrySimple> pref_registry = new PrefRegistrySimple;
71 PrefProxyConfigTrackerImpl::RegisterPrefs(pref_registry.get());
72 ssl_config::SSLConfigServiceManager::RegisterPrefs(pref_registry.get());
73
74 std::unique_ptr<PrefService> pref_service(
75 pref_service_factory.Create(pref_registry.get()));
76
77 std::unique_ptr<TestIOThread> test_io_thread(
78 new TestIOThread(pref_service.get(), nullptr));
79
80 ASSERT_TRUE(test_io_thread->system_url_request_context_getter());
81 }
OLDNEW
« no previous file with comments | « ios/components/io_thread/ios_io_thread.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698