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

Side by Side Diff: chrome/browser/chromeos/extensions/device_local_account_external_policy_loader_unittest.cc

Issue 128993004: Fix subtle bug with the in-process utility thread usage in unit tests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service_unittest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/chromeos/extensions/device_local_account_external_polic y_loader.h" 5 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic y_loader.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/message_loop/message_loop_proxy.h" 13 #include "base/message_loop/message_loop_proxy.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "base/version.h" 18 #include "base/version.h"
19 #include "chrome/browser/chrome_notification_types.h" 19 #include "chrome/browser/chrome_notification_types.h"
20 #include "chrome/browser/extensions/external_provider_impl.h" 20 #include "chrome/browser/extensions/external_provider_impl.h"
21 #include "chrome/browser/extensions/updater/extension_downloader.h" 21 #include "chrome/browser/extensions/updater/extension_downloader.h"
22 #include "chrome/common/chrome_paths.h" 22 #include "chrome/common/chrome_paths.h"
23 #include "chrome/common/extensions/extension_constants.h" 23 #include "chrome/common/extensions/extension_constants.h"
24 #include "chrome/test/base/testing_browser_process.h" 24 #include "chrome/test/base/testing_browser_process.h"
25 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" 25 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h"
26 #include "components/policy/core/common/policy_map.h" 26 #include "components/policy/core/common/policy_map.h"
27 #include "components/policy/core/common/policy_types.h" 27 #include "components/policy/core/common/policy_types.h"
28 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
29 #include "content/public/browser/notification_source.h" 29 #include "content/public/browser/notification_source.h"
30 #include "content/public/browser/render_process_host.h"
31 #include "content/public/test/test_browser_thread_bundle.h" 30 #include "content/public/test/test_browser_thread_bundle.h"
32 #include "content/public/test/test_utils.h" 31 #include "content/public/test/test_utils.h"
33 #include "extensions/browser/external_provider_interface.h" 32 #include "extensions/browser/external_provider_interface.h"
34 #include "extensions/common/extension.h" 33 #include "extensions/common/extension.h"
35 #include "extensions/common/manifest.h" 34 #include "extensions/common/manifest.h"
36 #include "net/url_request/test_url_fetcher_factory.h" 35 #include "net/url_request/test_url_fetcher_factory.h"
37 #include "net/url_request/url_fetcher_delegate.h" 36 #include "net/url_request/url_fetcher_delegate.h"
38 #include "net/url_request/url_request_context_getter.h" 37 #include "net/url_request/url_request_context_getter.h"
39 #include "net/url_request/url_request_test_util.h" 38 #include "net/url_request/url_request_test_util.h"
40 #include "policy/policy_constants.h" 39 #include "policy/policy_constants.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 content::TestBrowserThreadBundle thread_bundle_; 105 content::TestBrowserThreadBundle thread_bundle_;
107 base::ScopedTempDir temp_dir_; 106 base::ScopedTempDir temp_dir_;
108 base::FilePath cache_dir_; 107 base::FilePath cache_dir_;
109 policy::MockCloudPolicyStore store_; 108 policy::MockCloudPolicyStore store_;
110 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 109 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
111 base::FilePath test_dir_; 110 base::FilePath test_dir_;
112 111
113 scoped_refptr<DeviceLocalAccountExternalPolicyLoader> loader_; 112 scoped_refptr<DeviceLocalAccountExternalPolicyLoader> loader_;
114 MockExternalPolicyProviderVisitor visitor_; 113 MockExternalPolicyProviderVisitor visitor_;
115 scoped_ptr<extensions::ExternalProviderImpl> provider_; 114 scoped_ptr<extensions::ExternalProviderImpl> provider_;
115
116 content::InProcessUtilityThreadHelper in_process_utility_thread_helper_;
116 }; 117 };
117 118
118 DeviceLocalAccountExternalPolicyLoaderTest:: 119 DeviceLocalAccountExternalPolicyLoaderTest::
119 DeviceLocalAccountExternalPolicyLoaderTest() 120 DeviceLocalAccountExternalPolicyLoaderTest()
120 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) { 121 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {
121 } 122 }
122 123
123 DeviceLocalAccountExternalPolicyLoaderTest:: 124 DeviceLocalAccountExternalPolicyLoaderTest::
124 ~DeviceLocalAccountExternalPolicyLoaderTest() { 125 ~DeviceLocalAccountExternalPolicyLoaderTest() {
125 } 126 }
(...skipping 10 matching lines...) Expand all
136 137
137 loader_ = new DeviceLocalAccountExternalPolicyLoader(&store_, cache_dir_); 138 loader_ = new DeviceLocalAccountExternalPolicyLoader(&store_, cache_dir_);
138 provider_.reset(new extensions::ExternalProviderImpl( 139 provider_.reset(new extensions::ExternalProviderImpl(
139 &visitor_, 140 &visitor_,
140 loader_, 141 loader_,
141 NULL, 142 NULL,
142 extensions::Manifest::EXTERNAL_POLICY, 143 extensions::Manifest::EXTERNAL_POLICY,
143 extensions::Manifest::EXTERNAL_POLICY_DOWNLOAD, 144 extensions::Manifest::EXTERNAL_POLICY_DOWNLOAD,
144 extensions::Extension::NO_FLAGS)); 145 extensions::Extension::NO_FLAGS));
145 146
146 content::RenderProcessHost::SetRunRendererInProcess(true);
147
148 VerifyAndResetVisitorCallExpectations(); 147 VerifyAndResetVisitorCallExpectations();
149 } 148 }
150 149
151 void DeviceLocalAccountExternalPolicyLoaderTest::TearDown() { 150 void DeviceLocalAccountExternalPolicyLoaderTest::TearDown() {
152 content::RenderProcessHost::SetRunRendererInProcess(false);
153 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext(NULL); 151 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext(NULL);
154 } 152 }
155 153
156 void DeviceLocalAccountExternalPolicyLoaderTest:: 154 void DeviceLocalAccountExternalPolicyLoaderTest::
157 VerifyAndResetVisitorCallExpectations() { 155 VerifyAndResetVisitorCallExpectations() {
158 Mock::VerifyAndClearExpectations(&visitor_); 156 Mock::VerifyAndClearExpectations(&visitor_);
159 EXPECT_CALL(visitor_, OnExternalExtensionFileFound(_, _, _, _, _, _)) 157 EXPECT_CALL(visitor_, OnExternalExtensionFileFound(_, _, _, _, _, _))
160 .Times(0); 158 .Times(0);
161 EXPECT_CALL(visitor_, OnExternalExtensionUpdateUrlFound(_, _, _, _, _)) 159 EXPECT_CALL(visitor_, OnExternalExtensionUpdateUrlFound(_, _, _, _, _))
162 .Times(0); 160 .Times(0);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 loader_->StopCache(shutdown_run_loop.QuitClosure()); 298 loader_->StopCache(shutdown_run_loop.QuitClosure());
301 VerifyAndResetVisitorCallExpectations(); 299 VerifyAndResetVisitorCallExpectations();
302 300
303 // Spin the loop until the cache shutdown callback is invoked. Verify that at 301 // Spin the loop until the cache shutdown callback is invoked. Verify that at
304 // that point, no further file I/O tasks are pending. 302 // that point, no further file I/O tasks are pending.
305 shutdown_run_loop.Run(); 303 shutdown_run_loop.Run();
306 EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting()); 304 EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting());
307 } 305 }
308 306
309 } // namespace chromeos 307 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698