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

Side by Side Diff: chrome/browser/chromeos/net/client_cert_store_chromeos_unittest.cc

Issue 2720143003: Revert of Use TaskScheduler instead of WorkerPool in client_cert_store_chromeos.cc. (Closed)
Patch Set: rebase Created 3 years, 9 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
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/net/client_cert_store_chromeos.h" 5 #include "chrome/browser/chromeos/net/client_cert_store_chromeos.h"
6 6
7 #include <memory>
7 #include <string> 8 #include <string>
8 9
9 #include "base/callback.h" 10 #include "base/callback.h"
10 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
11 #include "base/location.h" 12 #include "base/location.h"
12 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/run_loop.h" 15 #include "base/run_loop.h"
15 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
16 #include "base/test/scoped_task_scheduler.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "chrome/browser/chromeos/certificate_provider/certificate_provider.h" 18 #include "chrome/browser/chromeos/certificate_provider/certificate_provider.h"
19 #include "crypto/scoped_test_nss_db.h" 19 #include "crypto/scoped_test_nss_db.h"
20 #include "net/cert/x509_certificate.h" 20 #include "net/cert/x509_certificate.h"
21 #include "net/ssl/ssl_cert_request_info.h" 21 #include "net/ssl/ssl_cert_request_info.h"
22 #include "net/test/cert_test_util.h" 22 #include "net/test/cert_test_util.h"
23 #include "net/test/test_data_directory.h" 23 #include "net/test/test_data_directory.h"
24 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
25 25
26 namespace chromeos { 26 namespace chromeos {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 bool init_finished_; 70 bool init_finished_;
71 bool init_called_ = false; 71 bool init_called_ = false;
72 base::Closure pending_callback_; 72 base::Closure pending_callback_;
73 scoped_refptr<net::X509Certificate> not_allowed_cert_; 73 scoped_refptr<net::X509Certificate> not_allowed_cert_;
74 }; 74 };
75 75
76 } // namespace 76 } // namespace
77 77
78 class ClientCertStoreChromeOSTest : public ::testing::Test { 78 class ClientCertStoreChromeOSTest : public ::testing::Test {
79 public: 79 public:
80 ClientCertStoreChromeOSTest() {} 80 ClientCertStoreChromeOSTest() : message_loop_(new base::MessageLoopForIO()) {}
81 81
82 scoped_refptr<net::X509Certificate> ImportCertToSlot( 82 scoped_refptr<net::X509Certificate> ImportCertToSlot(
83 const std::string& cert_filename, 83 const std::string& cert_filename,
84 const std::string& key_filename, 84 const std::string& key_filename,
85 PK11SlotInfo* slot) { 85 PK11SlotInfo* slot) {
86 return net::ImportClientCertAndKeyFromFile( 86 return net::ImportClientCertAndKeyFromFile(
87 net::GetTestCertsDirectory(), cert_filename, key_filename, slot); 87 net::GetTestCertsDirectory(), cert_filename, key_filename, slot);
88 } 88 }
89 89
90 private: 90 private:
91 base::test::ScopedTaskScheduler scoped_task_scheduler_; 91 std::unique_ptr<base::MessageLoop> message_loop_;
gab 2017/02/28 01:42:40 Can this just be a base::MessageLoopForIO member?
92 }; 92 };
93 93
94 // Ensure that cert requests, that are started before the filter is initialized, 94 // Ensure that cert requests, that are started before the filter is initialized,
95 // will wait for the initialization and succeed afterwards. 95 // will wait for the initialization and succeed afterwards.
96 TEST_F(ClientCertStoreChromeOSTest, RequestWaitsForNSSInitAndSucceeds) { 96 TEST_F(ClientCertStoreChromeOSTest, RequestWaitsForNSSInitAndSucceeds) {
97 crypto::ScopedTestNSSDB test_db; 97 crypto::ScopedTestNSSDB test_db;
98 ASSERT_TRUE(test_db.is_open()); 98 ASSERT_TRUE(test_db.is_open());
99 99
100 TestCertFilter* cert_filter = 100 TestCertFilter* cert_filter =
101 new TestCertFilter(false /* init asynchronously */); 101 new TestCertFilter(false /* init asynchronously */);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 base::RunLoop run_loop; 227 base::RunLoop run_loop;
228 net::CertificateList selected_certs; 228 net::CertificateList selected_certs;
229 store.GetClientCerts(*request, &selected_certs, run_loop.QuitClosure()); 229 store.GetClientCerts(*request, &selected_certs, run_loop.QuitClosure());
230 run_loop.Run(); 230 run_loop.Run();
231 231
232 ASSERT_EQ(1u, selected_certs.size()); 232 ASSERT_EQ(1u, selected_certs.size());
233 EXPECT_TRUE(cert_1->Equals(selected_certs[0].get())); 233 EXPECT_TRUE(cert_1->Equals(selected_certs[0].get()));
234 } 234 }
235 235
236 } // namespace chromeos 236 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698