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

Unified Diff: chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc

Issue 10447117: Unwire the clear on exit preference from the storage systems. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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
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 03d7a508155f385fc3678ca42c4a28e1716957e2..f085be02db5ecf7b8b0b8b44d21fece2cb81a26d 100644
--- a/chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc
+++ b/chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc
@@ -82,37 +82,6 @@ class SQLiteServerBoundCertStoreTest : public testing::Test {
scoped_refptr<SQLiteServerBoundCertStore> store_;
};
-TEST_F(SQLiteServerBoundCertStoreTest, KeepOnDestruction) {
- store_->SetClearLocalStateOnExit(false);
- store_ = NULL;
- // Make sure we wait until the destructor has run.
- scoped_refptr<base::ThreadTestHelper> helper(
- new base::ThreadTestHelper(
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)));
- ASSERT_TRUE(helper->Run());
-
- ASSERT_TRUE(file_util::PathExists(
- temp_dir_.path().Append(chrome::kOBCertFilename)));
- ASSERT_TRUE(file_util::Delete(
- temp_dir_.path().Append(chrome::kOBCertFilename), false));
-}
-
-TEST_F(SQLiteServerBoundCertStoreTest, RemoveOnDestruction) {
- store_->SetClearLocalStateOnExit(true);
- // Replace the store effectively destroying the current one and forcing it
- // to write its data to disk. Then we can see if after loading it again it
- // is still there.
- store_ = NULL;
- // Make sure we wait until the destructor has run.
- scoped_refptr<base::ThreadTestHelper> helper(
- new base::ThreadTestHelper(
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)));
- ASSERT_TRUE(helper->Run());
-
- ASSERT_FALSE(file_util::PathExists(
- temp_dir_.path().Append(chrome::kOBCertFilename)));
-}
-
// Test if data is stored as expected in the SQLite database.
TEST_F(SQLiteServerBoundCertStoreTest, TestPersistence) {
store_->AddServerBoundCert(
@@ -548,12 +517,13 @@ bool CertificateExistsInList(
#endif
TEST_F(SQLiteServerBoundCertStoreTest, MAYBE_TestClearOnExitPolicy) {
// First, delete a possibly existing store.
- store_->SetClearLocalStateOnExit(true);
store_ = NULL;
scoped_refptr<base::ThreadTestHelper> helper(
new base::ThreadTestHelper(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)));
ASSERT_TRUE(helper->Run());
+ ASSERT_TRUE(file_util::Delete(
+ temp_dir_.path().Append(chrome::kOBCertFilename), false));
// Create a new store with three certificates in it.
store_ = new SQLiteServerBoundCertStore(
@@ -602,7 +572,21 @@ TEST_F(SQLiteServerBoundCertStoreTest, MAYBE_TestClearOnExitPolicy) {
ASSERT_TRUE(store_->Load(&certs.get()));
ASSERT_EQ(3U, certs.size());
- // Delete the store. This should apply the clear on exit policy.
+ // We've put a exit policy in place, but force the state to be saved.
+ store_->SaveSessionState();
+ store_ = NULL;
+ ASSERT_TRUE(helper->Run());
+
+ // Reload the store and check that the certs are still there.
+ store_ = new SQLiteServerBoundCertStore(
+ temp_dir_.path().Append(chrome::kOBCertFilename), clear_policy.get());
+
+ // Reload and test for persistence
+ certs.reset();
+ ASSERT_TRUE(store_->Load(&certs.get()));
+ ASSERT_EQ(3U, certs.size());
+
+ // Delete the store. This time, the exit policy should be in place.
store_ = NULL;
// Make sure we wait until the destructor has run.
ASSERT_TRUE(helper->Run());

Powered by Google App Engine
This is Rietveld 408576698