| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/files/scoped_temp_dir.h" |
| 7 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 9 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 10 #include "base/scoped_temp_dir.h" | |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/test/thread_test_helper.h" | 12 #include "base/test/thread_test_helper.h" |
| 13 #include "chrome/browser/net/clear_on_exit_policy.h" | 13 #include "chrome/browser/net/clear_on_exit_policy.h" |
| 14 #include "chrome/browser/net/sqlite_server_bound_cert_store.h" | 14 #include "chrome/browser/net/sqlite_server_bound_cert_store.h" |
| 15 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
| 16 #include "content/public/test/test_browser_thread.h" | 16 #include "content/public/test/test_browser_thread.h" |
| 17 #include "net/base/cert_test_util.h" | 17 #include "net/base/cert_test_util.h" |
| 18 #include "net/base/test_data_directory.h" | 18 #include "net/base/test_data_directory.h" |
| 19 #include "sql/statement.h" | 19 #include "sql/statement.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 store_->AddServerBoundCert( | 72 store_->AddServerBoundCert( |
| 73 net::DefaultServerBoundCertStore::ServerBoundCert( | 73 net::DefaultServerBoundCertStore::ServerBoundCert( |
| 74 "google.com", | 74 "google.com", |
| 75 net::CLIENT_CERT_RSA_SIGN, | 75 net::CLIENT_CERT_RSA_SIGN, |
| 76 base::Time::FromInternalValue(1), | 76 base::Time::FromInternalValue(1), |
| 77 base::Time::FromInternalValue(2), | 77 base::Time::FromInternalValue(2), |
| 78 "a", "b")); | 78 "a", "b")); |
| 79 } | 79 } |
| 80 | 80 |
| 81 content::TestBrowserThread db_thread_; | 81 content::TestBrowserThread db_thread_; |
| 82 ScopedTempDir temp_dir_; | 82 base::ScopedTempDir temp_dir_; |
| 83 scoped_refptr<SQLiteServerBoundCertStore> store_; | 83 scoped_refptr<SQLiteServerBoundCertStore> store_; |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 // Test if data is stored as expected in the SQLite database. | 86 // Test if data is stored as expected in the SQLite database. |
| 87 TEST_F(SQLiteServerBoundCertStoreTest, TestPersistence) { | 87 TEST_F(SQLiteServerBoundCertStoreTest, TestPersistence) { |
| 88 store_->AddServerBoundCert( | 88 store_->AddServerBoundCert( |
| 89 net::DefaultServerBoundCertStore::ServerBoundCert( | 89 net::DefaultServerBoundCertStore::ServerBoundCert( |
| 90 "foo.com", | 90 "foo.com", |
| 91 net::CLIENT_CERT_ECDSA_SIGN, | 91 net::CLIENT_CERT_ECDSA_SIGN, |
| 92 base::Time::FromInternalValue(3), | 92 base::Time::FromInternalValue(3), |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 475 |
| 476 store_->Flush(base::Bind(&CallbackCounter::Callback, counter.get())); | 476 store_->Flush(base::Bind(&CallbackCounter::Callback, counter.get())); |
| 477 | 477 |
| 478 scoped_refptr<base::ThreadTestHelper> helper( | 478 scoped_refptr<base::ThreadTestHelper> helper( |
| 479 new base::ThreadTestHelper( | 479 new base::ThreadTestHelper( |
| 480 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))); | 480 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))); |
| 481 ASSERT_TRUE(helper->Run()); | 481 ASSERT_TRUE(helper->Run()); |
| 482 | 482 |
| 483 ASSERT_EQ(1, counter->callback_count()); | 483 ASSERT_EQ(1, counter->callback_count()); |
| 484 } | 484 } |
| OLD | NEW |