| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/safe_browsing/safe_browsing_store_sqlite.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_store_sqlite.h" |
| 6 | 6 |
| 7 #include "chrome/browser/safe_browsing/safe_browsing_store_unittest_helper.h" | 7 #include "chrome/browser/safe_browsing/safe_browsing_store_unittest_helper.h" |
| 8 #include "chrome/test/file_test_utils.h" | 8 #include "chrome/test/file_test_utils.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "testing/platform_test.h" | 10 #include "testing/platform_test.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 const FilePath::CharType kFolderPrefix[] = | 14 const FilePath::CharType kFolderPrefix[] = |
| 15 FILE_PATH_LITERAL("SafeBrowsingTestStoreSqlite"); | 15 FILE_PATH_LITERAL("SafeBrowsingTestStoreSqlite"); |
| 16 | 16 |
| 17 class SafeBrowsingStoreSqliteTest : public PlatformTest { | 17 class SafeBrowsingStoreSqliteTest : public PlatformTest { |
| 18 public: | 18 public: |
| 19 virtual void SetUp() { | 19 virtual void SetUp() { |
| 20 PlatformTest::SetUp(); | 20 PlatformTest::SetUp(); |
| 21 | 21 |
| 22 FilePath temp_dir; | 22 FilePath temp_dir; |
| 23 ASSERT_TRUE(file_util::CreateNewTempDirectory(kFolderPrefix, &temp_dir)); | 23 ASSERT_TRUE(file_util::CreateNewTempDirectory(kFolderPrefix, &temp_dir)); |
| 24 | 24 |
| 25 file_deleter_.reset(new FileAutoDeleter(temp_dir)); | 25 file_deleter_.reset(new FileAutoDeleter(temp_dir)); |
| 26 | 26 |
| 27 filename_ = temp_dir; | 27 filename_ = temp_dir; |
| 28 filename_.AppendASCII("SafeBrowsingTestStore"); | 28 filename_ = filename_.AppendASCII("SafeBrowsingTestStore"); |
| 29 file_util::Delete(filename_, false); | 29 file_util::Delete(filename_, false); |
| 30 | 30 |
| 31 const FilePath journal_file = | 31 const FilePath journal_file = |
| 32 SafeBrowsingStoreSqlite::JournalFileForFilename(filename_); | 32 SafeBrowsingStoreSqlite::JournalFileForFilename(filename_); |
| 33 file_util::Delete(journal_file, false); | 33 file_util::Delete(journal_file, false); |
| 34 | 34 |
| 35 store_.reset(new SafeBrowsingStoreSqlite()); | 35 store_.reset(new SafeBrowsingStoreSqlite()); |
| 36 store_->Init(filename_, NULL); | 36 store_->Init(filename_, NULL); |
| 37 } | 37 } |
| 38 virtual void TearDown() { | 38 virtual void TearDown() { |
| 39 store_->Delete(); | 39 store_->Delete(); |
| 40 store_.reset(); | 40 store_.reset(); |
| 41 file_deleter_.reset(); | 41 file_deleter_.reset(); |
| 42 | 42 |
| 43 PlatformTest::TearDown(); | 43 PlatformTest::TearDown(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 scoped_ptr<FileAutoDeleter> file_deleter_; | 46 scoped_ptr<FileAutoDeleter> file_deleter_; |
| 47 FilePath filename_; | 47 FilePath filename_; |
| 48 scoped_ptr<SafeBrowsingStoreSqlite> store_; | 48 scoped_ptr<SafeBrowsingStoreSqlite> store_; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 TEST_STORE(SafeBrowsingStoreSqliteTest, store_.get(), filename_); | 51 TEST_STORE(SafeBrowsingStoreSqliteTest, store_.get(), filename_); |
| 52 | 52 |
| 53 } // namespace | 53 } // namespace |
| OLD | NEW |