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

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

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

Powered by Google App Engine
This is Rietveld 408576698