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

Side by Side Diff: chrome/browser/safe_browsing/download_protection_service_unittest.cc

Issue 11413050: chrome/browser: Update calls from RunAllPending() to RunUntilIdle(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/safe_browsing/download_protection_service.h" 5 #include "chrome/browser/safe_browsing/download_protection_service.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/base_paths.h" 10 #include "base/base_paths.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // Start real threads for the IO and File threads so that the DCHECKs 120 // Start real threads for the IO and File threads so that the DCHECKs
121 // to test that we're on the correct thread work. 121 // to test that we're on the correct thread work.
122 io_thread_.reset(new content::TestBrowserThread(BrowserThread::IO)); 122 io_thread_.reset(new content::TestBrowserThread(BrowserThread::IO));
123 ASSERT_TRUE(io_thread_->Start()); 123 ASSERT_TRUE(io_thread_->Start());
124 sb_service_ = new StrictMock<MockSafeBrowsingService>(); 124 sb_service_ = new StrictMock<MockSafeBrowsingService>();
125 sb_service_->Initialize(); 125 sb_service_->Initialize();
126 signature_util_ = new StrictMock<MockSignatureUtil>(); 126 signature_util_ = new StrictMock<MockSignatureUtil>();
127 download_service_ = sb_service_->download_protection_service(); 127 download_service_ = sb_service_->download_protection_service();
128 download_service_->signature_util_ = signature_util_; 128 download_service_->signature_util_ = signature_util_;
129 download_service_->SetEnabled(true); 129 download_service_->SetEnabled(true);
130 msg_loop_.RunAllPending(); 130 msg_loop_.RunUntilIdle();
131 131
132 FilePath source_path; 132 FilePath source_path;
133 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &source_path)); 133 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &source_path));
134 testdata_path_ = source_path 134 testdata_path_ = source_path
135 .AppendASCII("chrome") 135 .AppendASCII("chrome")
136 .AppendASCII("test") 136 .AppendASCII("test")
137 .AppendASCII("data") 137 .AppendASCII("data")
138 .AppendASCII("safe_browsing") 138 .AppendASCII("safe_browsing")
139 .AppendASCII("download_protection"); 139 .AppendASCII("download_protection");
140 } 140 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 return remote_address == request.resources(i).remote_ip(); 175 return remote_address == request.resources(i).remote_ip();
176 } 176 }
177 } 177 }
178 return false; 178 return false;
179 } 179 }
180 180
181 // Flushes any pending tasks in the message loops of all threads. 181 // Flushes any pending tasks in the message loops of all threads.
182 void FlushThreadMessageLoops() { 182 void FlushThreadMessageLoops() {
183 BrowserThread::GetBlockingPool()->FlushForTesting(); 183 BrowserThread::GetBlockingPool()->FlushForTesting();
184 FlushMessageLoop(BrowserThread::IO); 184 FlushMessageLoop(BrowserThread::IO);
185 msg_loop_.RunAllPending(); 185 msg_loop_.RunUntilIdle();
186 } 186 }
187 187
188 // Proxy for private method. 188 // Proxy for private method.
189 static void GetCertificateWhitelistStrings( 189 static void GetCertificateWhitelistStrings(
190 const net::X509Certificate& certificate, 190 const net::X509Certificate& certificate,
191 const net::X509Certificate& issuer, 191 const net::X509Certificate& issuer,
192 std::vector<std::string>* whitelist_strings) { 192 std::vector<std::string>* whitelist_strings) {
193 DownloadProtectionService::GetCertificateWhitelistStrings( 193 DownloadProtectionService::GetCertificateWhitelistStrings(
194 certificate, issuer, whitelist_strings); 194 certificate, issuer, whitelist_strings);
195 } 195 }
(...skipping 11 matching lines...) Expand all
207 net::X509Certificate::CreateCertificateListFromBytes( 207 net::X509Certificate::CreateCertificateListFromBytes(
208 cert_data.data(), 208 cert_data.data(),
209 cert_data.size(), 209 cert_data.size(),
210 net::X509Certificate::FORMAT_PEM_CERT_SEQUENCE); 210 net::X509Certificate::FORMAT_PEM_CERT_SEQUENCE);
211 return certs.empty() ? NULL : certs[0]; 211 return certs.empty() ? NULL : certs[0];
212 } 212 }
213 213
214 private: 214 private:
215 // Helper functions for FlushThreadMessageLoops. 215 // Helper functions for FlushThreadMessageLoops.
216 void RunAllPendingAndQuitUI() { 216 void RunAllPendingAndQuitUI() {
217 MessageLoop::current()->RunAllPending(); 217 MessageLoop::current()->RunUntilIdle();
218 BrowserThread::PostTask( 218 BrowserThread::PostTask(
219 BrowserThread::UI, 219 BrowserThread::UI,
220 FROM_HERE, 220 FROM_HERE,
221 base::Bind(&DownloadProtectionServiceTest::QuitMessageLoop, 221 base::Bind(&DownloadProtectionServiceTest::QuitMessageLoop,
222 base::Unretained(this))); 222 base::Unretained(this)));
223 } 223 }
224 224
225 void QuitMessageLoop() { 225 void QuitMessageLoop() {
226 MessageLoop::current()->Quit(); 226 MessageLoop::current()->Quit();
227 } 227 }
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 GetCertificateWhitelistStrings(*cert, *issuer_cert, &whitelist_strings); 870 GetCertificateWhitelistStrings(*cert, *issuer_cert, &whitelist_strings);
871 EXPECT_THAT(whitelist_strings, ElementsAre(cert_base + "/OU=unit")); 871 EXPECT_THAT(whitelist_strings, ElementsAre(cert_base + "/OU=unit"));
872 872
873 cert = ReadTestCertificate("test_c.pem"); 873 cert = ReadTestCertificate("test_c.pem");
874 ASSERT_TRUE(cert.get()); 874 ASSERT_TRUE(cert.get());
875 whitelist_strings.clear(); 875 whitelist_strings.clear();
876 GetCertificateWhitelistStrings(*cert, *issuer_cert, &whitelist_strings); 876 GetCertificateWhitelistStrings(*cert, *issuer_cert, &whitelist_strings);
877 EXPECT_THAT(whitelist_strings, ElementsAre()); 877 EXPECT_THAT(whitelist_strings, ElementsAre());
878 } 878 }
879 } // namespace safe_browsing 879 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698