| Index: chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc
|
| diff --git a/chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc b/chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc
|
| index 6c62fe7695c98f17c190aaea9128f96a20012252..3dc1b4501b863344bbab5a5c003debe07012e201 100644
|
| --- a/chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc
|
| +++ b/chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc
|
| @@ -8,6 +8,7 @@
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/scoped_vector.h"
|
| #include "base/message_loop.h"
|
| +#include "base/run_loop.h"
|
| #include "base/stl_util.h"
|
| #include "base/test/thread_test_helper.h"
|
| #include "chrome/browser/net/clear_on_exit_policy.h"
|
| @@ -25,7 +26,26 @@ using content::BrowserThread;
|
| class SQLiteServerBoundCertStoreTest : public testing::Test {
|
| public:
|
| SQLiteServerBoundCertStoreTest()
|
| - : db_thread_(BrowserThread::DB) {
|
| + : db_thread_(BrowserThread::DB),
|
| + io_thread_(BrowserThread::IO, &message_loop_) {}
|
| +
|
| + void Load(
|
| + ScopedVector<net::DefaultServerBoundCertStore::ServerBoundCert>* certs) {
|
| + base::RunLoop run_loop;
|
| + store_->Load(base::Bind(&SQLiteServerBoundCertStoreTest::OnLoaded,
|
| + base::Unretained(this),
|
| + &run_loop));
|
| + run_loop.Run();
|
| + certs->swap(certs_);
|
| + certs_.clear();
|
| + }
|
| +
|
| + void OnLoaded(
|
| + base::RunLoop* run_loop,
|
| + scoped_ptr<ScopedVector<
|
| + net::DefaultServerBoundCertStore::ServerBoundCert> > certs) {
|
| + certs_.swap(*certs);
|
| + run_loop->Quit();
|
| }
|
|
|
| protected:
|
| @@ -66,7 +86,7 @@ class SQLiteServerBoundCertStoreTest : public testing::Test {
|
| store_ = new SQLiteServerBoundCertStore(
|
| temp_dir_.path().Append(chrome::kOBCertFilename), NULL);
|
| ScopedVector<net::DefaultServerBoundCertStore::ServerBoundCert> certs;
|
| - ASSERT_TRUE(store_->Load(&certs.get()));
|
| + Load(&certs);
|
| ASSERT_EQ(0u, certs.size());
|
| // Make sure the store gets written at least once.
|
| store_->AddServerBoundCert(
|
| @@ -78,9 +98,12 @@ class SQLiteServerBoundCertStoreTest : public testing::Test {
|
| "a", "b"));
|
| }
|
|
|
| + MessageLoopForIO message_loop_;
|
| content::TestBrowserThread db_thread_;
|
| + content::TestBrowserThread io_thread_;
|
| base::ScopedTempDir temp_dir_;
|
| scoped_refptr<SQLiteServerBoundCertStore> store_;
|
| + ScopedVector<net::DefaultServerBoundCertStore::ServerBoundCert> certs_;
|
| };
|
|
|
| // Test if data is stored as expected in the SQLite database.
|
| @@ -107,7 +130,7 @@ TEST_F(SQLiteServerBoundCertStoreTest, TestPersistence) {
|
| temp_dir_.path().Append(chrome::kOBCertFilename), NULL);
|
|
|
| // Reload and test for persistence
|
| - ASSERT_TRUE(store_->Load(&certs.get()));
|
| + Load(&certs);
|
| ASSERT_EQ(2U, certs.size());
|
| net::DefaultServerBoundCertStore::ServerBoundCert* ec_cert;
|
| net::DefaultServerBoundCertStore::ServerBoundCert* rsa_cert;
|
| @@ -142,7 +165,7 @@ TEST_F(SQLiteServerBoundCertStoreTest, TestPersistence) {
|
| temp_dir_.path().Append(chrome::kOBCertFilename), NULL);
|
|
|
| // Reload and check if the cert has been removed.
|
| - ASSERT_TRUE(store_->Load(&certs.get()));
|
| + Load(&certs);
|
| ASSERT_EQ(0U, certs.size());
|
| }
|
|
|
| @@ -193,7 +216,7 @@ TEST_F(SQLiteServerBoundCertStoreTest, TestUpgradeV1) {
|
| store_ = new SQLiteServerBoundCertStore(v1_db_path, NULL);
|
|
|
| // Load the database and ensure the certs can be read and are marked as RSA.
|
| - ASSERT_TRUE(store_->Load(&certs.get()));
|
| + Load(&certs);
|
| ASSERT_EQ(2U, certs.size());
|
|
|
| ASSERT_STREQ("google.com", certs[0]->server_identifier().c_str());
|
| @@ -281,7 +304,7 @@ TEST_F(SQLiteServerBoundCertStoreTest, TestUpgradeV2) {
|
| store_ = new SQLiteServerBoundCertStore(v2_db_path, NULL);
|
|
|
| // Load the database and ensure the certs can be read and are marked as RSA.
|
| - ASSERT_TRUE(store_->Load(&certs.get()));
|
| + Load(&certs);
|
| ASSERT_EQ(2U, certs.size());
|
|
|
| ASSERT_STREQ("google.com", certs[0]->server_identifier().c_str());
|
| @@ -371,7 +394,7 @@ TEST_F(SQLiteServerBoundCertStoreTest, TestUpgradeV3) {
|
| store_ = new SQLiteServerBoundCertStore(v3_db_path, NULL);
|
|
|
| // Load the database and ensure the certs can be read and are marked as RSA.
|
| - ASSERT_TRUE(store_->Load(&certs.get()));
|
| + Load(&certs);
|
| ASSERT_EQ(2U, certs.size());
|
|
|
| ASSERT_STREQ("google.com", certs[0]->server_identifier().c_str());
|
|
|