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

Side by Side Diff: chrome/browser/io_thread_unittest.cc

Issue 2479593006: Move enable extensions define to a build flag. (Closed)
Patch Set: Merge Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/metrics/field_trial.h" 11 #include "base/metrics/field_trial.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/test/mock_entropy_provider.h" 13 #include "base/test/mock_entropy_provider.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/io_thread.h" 15 #include "chrome/browser/io_thread.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 #include "components/policy/core/common/mock_policy_service.h" 18 #include "components/policy/core/common/mock_policy_service.h"
19 #include "components/prefs/pref_registry_simple.h" 19 #include "components/prefs/pref_registry_simple.h"
20 #include "components/prefs/pref_service.h" 20 #include "components/prefs/pref_service.h"
21 #include "components/prefs/testing_pref_service.h" 21 #include "components/prefs/testing_pref_service.h"
22 #include "components/proxy_config/pref_proxy_config_tracker_impl.h" 22 #include "components/proxy_config/pref_proxy_config_tracker_impl.h"
23 #include "components/proxy_config/proxy_config_pref_names.h" 23 #include "components/proxy_config/proxy_config_pref_names.h"
24 #include "components/variations/variations_associated_data.h" 24 #include "components/variations/variations_associated_data.h"
25 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
26 #include "content/public/test/test_browser_thread_bundle.h" 26 #include "content/public/test/test_browser_thread_bundle.h"
27 #include "extensions/features/features.h"
27 #include "net/cert_net/nss_ocsp.h" 28 #include "net/cert_net/nss_ocsp.h"
28 #include "net/http/http_auth_preferences.h" 29 #include "net/http/http_auth_preferences.h"
29 #include "net/http/http_auth_scheme.h" 30 #include "net/http/http_auth_scheme.h"
30 #include "net/http/http_network_session.h" 31 #include "net/http/http_network_session.h"
31 #include "net/quic/chromium/quic_stream_factory.h" 32 #include "net/quic/chromium/quic_stream_factory.h"
32 #include "net/quic/core/quic_protocol.h" 33 #include "net/quic/core/quic_protocol.h"
33 #include "testing/gmock/include/gmock/gmock.h" 34 #include "testing/gmock/include/gmock/gmock.h"
34 #include "testing/gtest/include/gtest/gtest.h" 35 #include "testing/gtest/include/gtest/gtest.h"
35 36
36 #if defined(ENABLE_EXTENSIONS) 37 #if BUILDFLAG(ENABLE_EXTENSIONS)
37 #include "chrome/browser/extensions/event_router_forwarder.h" 38 #include "chrome/browser/extensions/event_router_forwarder.h"
38 #endif 39 #endif
39 40
40 #if defined(OS_CHROMEOS) 41 #if defined(OS_CHROMEOS)
41 #include "chromeos/dbus/dbus_thread_manager.h" 42 #include "chromeos/dbus/dbus_thread_manager.h"
42 #include "chromeos/network/network_handler.h" 43 #include "chromeos/network/network_handler.h"
43 #endif 44 #endif
44 45
45 namespace test { 46 namespace test {
46 47
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 void CheckCanDelegate(bool expected, const GURL& url) { 100 void CheckCanDelegate(bool expected, const GURL& url) {
100 auto* http_auth_preferences = 101 auto* http_auth_preferences =
101 IOThreadPeer::GetAuthPreferences(io_thread_.get()); 102 IOThreadPeer::GetAuthPreferences(io_thread_.get());
102 EXPECT_EQ(expected, http_auth_preferences->CanDelegate(url)); 103 EXPECT_EQ(expected, http_auth_preferences->CanDelegate(url));
103 } 104 }
104 105
105 protected: 106 protected:
106 IOThreadTestWithIOThreadObject() 107 IOThreadTestWithIOThreadObject()
107 : thread_bundle_(content::TestBrowserThreadBundle::REAL_IO_THREAD | 108 : thread_bundle_(content::TestBrowserThreadBundle::REAL_IO_THREAD |
108 content::TestBrowserThreadBundle::DONT_START_THREADS) { 109 content::TestBrowserThreadBundle::DONT_START_THREADS) {
109 #if defined(ENABLE_EXTENSIONS) 110 #if BUILDFLAG(ENABLE_EXTENSIONS)
110 event_router_forwarder_ = new extensions::EventRouterForwarder; 111 event_router_forwarder_ = new extensions::EventRouterForwarder;
111 #endif 112 #endif
112 PrefRegistrySimple* pref_registry = pref_service_.registry(); 113 PrefRegistrySimple* pref_registry = pref_service_.registry();
113 IOThread::RegisterPrefs(pref_registry); 114 IOThread::RegisterPrefs(pref_registry);
114 PrefProxyConfigTrackerImpl::RegisterPrefs(pref_registry); 115 PrefProxyConfigTrackerImpl::RegisterPrefs(pref_registry);
115 ssl_config::SSLConfigServiceManager::RegisterPrefs(pref_registry); 116 ssl_config::SSLConfigServiceManager::RegisterPrefs(pref_registry);
116 117
117 // Set up default function behaviour. 118 // Set up default function behaviour.
118 EXPECT_CALL(policy_service_, 119 EXPECT_CALL(policy_service_,
119 GetPolicies(policy::PolicyNamespace( 120 GetPolicies(policy::PolicyNamespace(
120 policy::POLICY_DOMAIN_CHROME, std::string()))) 121 policy::POLICY_DOMAIN_CHROME, std::string())))
121 .WillRepeatedly(ReturnRef(policy_map_)); 122 .WillRepeatedly(ReturnRef(policy_map_));
122 123
123 #if defined(OS_CHROMEOS) 124 #if defined(OS_CHROMEOS)
124 // Needed by IOThread constructor. 125 // Needed by IOThread constructor.
125 chromeos::DBusThreadManager::Initialize(); 126 chromeos::DBusThreadManager::Initialize();
126 chromeos::NetworkHandler::Initialize(); 127 chromeos::NetworkHandler::Initialize();
127 #endif 128 #endif
128 // The IOThread constructor registers the IOThread object with as the 129 // The IOThread constructor registers the IOThread object with as the
129 // BrowserThreadDelegate for the io thread. 130 // BrowserThreadDelegate for the io thread.
130 io_thread_.reset(new IOThread(&pref_service_, &policy_service_, nullptr, 131 io_thread_.reset(new IOThread(&pref_service_, &policy_service_, nullptr,
131 #if defined(ENABLE_EXTENSIONS) 132 #if BUILDFLAG(ENABLE_EXTENSIONS)
132 event_router_forwarder_.get() 133 event_router_forwarder_.get()
133 #else 134 #else
134 nullptr 135 nullptr
135 #endif 136 #endif
136 )); 137 ));
137 // Now that IOThread object is registered starting the threads will 138 // Now that IOThread object is registered starting the threads will
138 // call the IOThread::Init(). This sets up the environment needed for 139 // call the IOThread::Init(). This sets up the environment needed for
139 // these tests. 140 // these tests.
140 thread_bundle_.Start(); 141 thread_bundle_.Start();
141 } 142 }
(...skipping 14 matching lines...) Expand all
156 void RunOnIOThreadBlocking(const base::Closure& task) { 157 void RunOnIOThreadBlocking(const base::Closure& task) {
157 base::RunLoop run_loop; 158 base::RunLoop run_loop;
158 content::BrowserThread::PostTaskAndReply( 159 content::BrowserThread::PostTaskAndReply(
159 content::BrowserThread::IO, FROM_HERE, task, run_loop.QuitClosure()); 160 content::BrowserThread::IO, FROM_HERE, task, run_loop.QuitClosure());
160 run_loop.Run(); 161 run_loop.Run();
161 } 162 }
162 163
163 private: 164 private:
164 base::ShadowingAtExitManager at_exit_manager_; 165 base::ShadowingAtExitManager at_exit_manager_;
165 TestingPrefServiceSimple pref_service_; 166 TestingPrefServiceSimple pref_service_;
166 #if defined(ENABLE_EXTENSIONS) 167 #if BUILDFLAG(ENABLE_EXTENSIONS)
167 scoped_refptr<extensions::EventRouterForwarder> event_router_forwarder_; 168 scoped_refptr<extensions::EventRouterForwarder> event_router_forwarder_;
168 #endif 169 #endif
169 policy::PolicyMap policy_map_; 170 policy::PolicyMap policy_map_;
170 policy::MockPolicyService policy_service_; 171 policy::MockPolicyService policy_service_;
171 // The ordering of the declarations of |io_thread_object_| and 172 // The ordering of the declarations of |io_thread_object_| and
172 // |thread_bundle_| matters. An IOThread cannot be deleted until all of 173 // |thread_bundle_| matters. An IOThread cannot be deleted until all of
173 // the globals have been reset to their initial state via CleanUp. As 174 // the globals have been reset to their initial state via CleanUp. As
174 // TestBrowserThreadBundle's destructor is responsible for calling 175 // TestBrowserThreadBundle's destructor is responsible for calling
175 // CleanUp(), the IOThread must be declared before the bundle, so that 176 // CleanUp(), the IOThread must be declared before the bundle, so that
176 // the bundle is deleted first. 177 // the bundle is deleted first.
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 command_line_.AppendSwitchASCII("testing-fixed-http-port", "42"); 460 command_line_.AppendSwitchASCII("testing-fixed-http-port", "42");
460 command_line_.AppendSwitchASCII("testing-fixed-https-port", "137"); 461 command_line_.AppendSwitchASCII("testing-fixed-https-port", "137");
461 462
462 ConfigureParamsFromFieldTrialsAndCommandLine(); 463 ConfigureParamsFromFieldTrialsAndCommandLine();
463 464
464 EXPECT_EQ(42u, params_.testing_fixed_http_port); 465 EXPECT_EQ(42u, params_.testing_fixed_http_port);
465 EXPECT_EQ(137u, params_.testing_fixed_https_port); 466 EXPECT_EQ(137u, params_.testing_fixed_https_port);
466 } 467 }
467 468
468 } // namespace test 469 } // namespace test
OLDNEW
« no previous file with comments | « chrome/browser/io_thread.cc ('k') | chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698