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

Side by Side Diff: ios/chrome/browser/ios_chrome_io_thread_unittest.mm

Issue 2170103002: Notify SystemURLRequestContextGetter before shutdown on iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Few more comments. Created 4 years, 4 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/chrome/browser/ios_chrome_io_thread.mm ('k') | ios/chrome/ios_chrome_tests.gyp » ('j') | 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 2016 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/chrome/browser/ios_chrome_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_fetcher.h"
18 #include "net/url_request/url_fetcher_delegate.h"
19 #include "net/url_request/url_request_filter.h"
20 #include "testing/gtest/include/gtest/gtest.h"
21 #include "testing/gtest_mac.h"
22 #include "testing/platform_test.h"
23
24 namespace {
25
26 // A delegate interface for users of URLFetcher.
27 class TestURLFetcherDelegate : public net::URLFetcherDelegate {
28 public:
29 TestURLFetcherDelegate() {}
30 ~TestURLFetcherDelegate() override {}
31
32 // net::URLFetcherDelegate implementation.
33 void OnURLFetchComplete(const net::URLFetcher* source) override {}
34 };
35
36 } // namespace
37
38 class IOSChromeIOThreadTest : public PlatformTest {
39 public:
40 IOSChromeIOThreadTest()
41 : loop_(base::MessageLoop::TYPE_IO),
42 ui_thread_(web::WebThread::UI, &loop_),
43 io_thread_(web::WebThread::IO, &loop_) {
44 net::URLRequestFailedJob::AddUrlHandler();
45 }
46
47 ~IOSChromeIOThreadTest() override {
48 net::URLRequestFilter::GetInstance()->ClearHandlers();
49 }
50
51 private:
52 base::MessageLoop loop_;
53 web::TestWebThread ui_thread_;
54 web::TestWebThread io_thread_;
55 };
56
57 TEST_F(IOSChromeIOThreadTest, AssertNoUrlRequests) {
58 PrefServiceFactory pref_service_factory;
59 pref_service_factory.set_user_prefs(
60 make_scoped_refptr(new TestingPrefStore()));
61
62 scoped_refptr<PrefRegistrySimple> pref_registry = new PrefRegistrySimple;
63 PrefProxyConfigTrackerImpl::RegisterPrefs(pref_registry.get());
64 ssl_config::SSLConfigServiceManager::RegisterPrefs(pref_registry.get());
65
66 std::unique_ptr<PrefService> pref_service(
67 pref_service_factory.Create(pref_registry.get()));
68
69 // Create and init IOSChromeIOThread.
70 std::unique_ptr<IOSChromeIOThread> ios_chrome_io_thread(
71 new IOSChromeIOThread(pref_service.get(), nullptr));
72 web::WebThreadDelegate* web_thread_delegate =
73 static_cast<web::WebThreadDelegate*>(ios_chrome_io_thread.get());
74 web_thread_delegate->Init();
75
76 // Create and start fetcher.
77 TestURLFetcherDelegate fetcher_delegate;
78 std::unique_ptr<net::URLFetcher> fetcher = net::URLFetcher::Create(
79 net::URLRequestFailedJob::GetMockHttpUrl(net::ERR_IO_PENDING),
80 net::URLFetcher::GET, &fetcher_delegate);
81 fetcher->SetRequestContext(
82 ios_chrome_io_thread->system_url_request_context_getter());
83 fetcher->Start();
84 base::RunLoop().RunUntilIdle();
85 // Verify that there is no AssertNoUrlRequests triggered during CleanUp.
86 web_thread_delegate->CleanUp();
87 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/ios_chrome_io_thread.mm ('k') | ios/chrome/ios_chrome_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698