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

Unified 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, 5 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ios_chrome_io_thread_unittest.mm
diff --git a/ios/chrome/browser/ios_chrome_io_thread_unittest.mm b/ios/chrome/browser/ios_chrome_io_thread_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..3f5f7f01230a4573b2f63118020a8ad846197e96
--- /dev/null
+++ b/ios/chrome/browser/ios_chrome_io_thread_unittest.mm
@@ -0,0 +1,87 @@
+// Copyright 2016 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/chrome/browser/ios_chrome_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_fetcher.h"
+#include "net/url_request/url_fetcher_delegate.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"
+
+namespace {
+
+// A delegate interface for users of URLFetcher.
+class TestURLFetcherDelegate : public net::URLFetcherDelegate {
+ public:
+ TestURLFetcherDelegate() {}
+ ~TestURLFetcherDelegate() override {}
+
+ // net::URLFetcherDelegate implementation.
+ void OnURLFetchComplete(const net::URLFetcher* source) override {}
+};
+
+} // namespace
+
+class IOSChromeIOThreadTest : public PlatformTest {
+ public:
+ IOSChromeIOThreadTest()
+ : loop_(base::MessageLoop::TYPE_IO),
+ ui_thread_(web::WebThread::UI, &loop_),
+ io_thread_(web::WebThread::IO, &loop_) {
+ net::URLRequestFailedJob::AddUrlHandler();
+ }
+
+ ~IOSChromeIOThreadTest() override {
+ net::URLRequestFilter::GetInstance()->ClearHandlers();
+ }
+
+ private:
+ base::MessageLoop loop_;
+ web::TestWebThread ui_thread_;
+ web::TestWebThread io_thread_;
+};
+
+TEST_F(IOSChromeIOThreadTest, AssertNoUrlRequests) {
+ 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()));
+
+ // Create and init IOSChromeIOThread.
+ std::unique_ptr<IOSChromeIOThread> ios_chrome_io_thread(
+ new IOSChromeIOThread(pref_service.get(), nullptr));
+ web::WebThreadDelegate* web_thread_delegate =
+ static_cast<web::WebThreadDelegate*>(ios_chrome_io_thread.get());
+ web_thread_delegate->Init();
+
+ // Create and start fetcher.
+ TestURLFetcherDelegate fetcher_delegate;
+ std::unique_ptr<net::URLFetcher> fetcher = net::URLFetcher::Create(
+ net::URLRequestFailedJob::GetMockHttpUrl(net::ERR_IO_PENDING),
+ net::URLFetcher::GET, &fetcher_delegate);
+ fetcher->SetRequestContext(
+ ios_chrome_io_thread->system_url_request_context_getter());
+ fetcher->Start();
+ base::RunLoop().RunUntilIdle();
+ // Verify that there is no AssertNoUrlRequests triggered during CleanUp.
+ web_thread_delegate->CleanUp();
+}
« 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