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

Unified Diff: net/cert/nss_cert_database_unittest.cc

Issue 144423007: Make NSSCertDatabase::ListCerts work async on a worker thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cert/nss_cert_database_chromeos_unittest.cc ('k') | net/cert/nss_profile_filter_chromeos.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/nss_cert_database_unittest.cc
diff --git a/net/cert/nss_cert_database_unittest.cc b/net/cert/nss_cert_database_unittest.cc
index 39e1a33a498225b41dd4e0d27ef49a2357ed4dfb..342e0b9701ab26d59c44ae81a74fd2ba72539e82 100644
--- a/net/cert/nss_cert_database_unittest.cc
+++ b/net/cert/nss_cert_database_unittest.cc
@@ -8,11 +8,14 @@
#include <algorithm>
+#include "base/bind.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/lazy_instance.h"
#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/path_service.h"
+#include "base/run_loop.h"
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -41,6 +44,16 @@ using base::ASCIIToUTF16;
namespace net {
+namespace {
+
+void SwapCertList(CertificateList* destination,
+ scoped_ptr<CertificateList> source) {
+ ASSERT_TRUE(destination);
+ destination->swap(*source);
+}
+
+} // namespace
+
class CertDatabaseNSSTest : public testing::Test {
public:
virtual void SetUp() {
@@ -127,11 +140,26 @@ class CertDatabaseNSSTest : public testing::Test {
crypto::ScopedTestNSSDB test_nssdb_;
};
+TEST_F(CertDatabaseNSSTest, ListCertsSync) {
+ // This test isn't terribly useful, though it will at least let valgrind test
+ // for leaks.
+ CertificateList certs;
+ cert_db_->ListCertsSync(&certs);
+ // The test DB is empty, but let's assume there will always be something in
+ // the other slots.
+ EXPECT_LT(0U, certs.size());
+}
+
TEST_F(CertDatabaseNSSTest, ListCerts) {
// This test isn't terribly useful, though it will at least let valgrind test
// for leaks.
CertificateList certs;
- cert_db_->ListCerts(&certs);
+ cert_db_->SetSlowTaskRunnerForTest(base::MessageLoopProxy::current());
+ cert_db_->ListCerts(base::Bind(&SwapCertList, base::Unretained(&certs)));
+ EXPECT_EQ(0U, certs.size());
+
+ base::RunLoop().RunUntilIdle();
+
// The test DB is empty, but let's assume there will always be something in
// the other slots.
EXPECT_LT(0U, certs.size());
« no previous file with comments | « net/cert/nss_cert_database_chromeos_unittest.cc ('k') | net/cert/nss_profile_filter_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698