| 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 "chrome/browser/safe_browsing/safe_browsing_store_file.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_store_file.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/md5.h" | 9 #include "base/md5.h" |
| 9 #include "base/scoped_temp_dir.h" | |
| 10 #include "chrome/browser/safe_browsing/safe_browsing_store_unittest_helper.h" | 10 #include "chrome/browser/safe_browsing/safe_browsing_store_unittest_helper.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "testing/platform_test.h" | 12 #include "testing/platform_test.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 const FilePath::CharType kFolderPrefix[] = | 16 const FilePath::CharType kFolderPrefix[] = |
| 17 FILE_PATH_LITERAL("SafeBrowsingTestStoreFile"); | 17 FILE_PATH_LITERAL("SafeBrowsingTestStoreFile"); |
| 18 | 18 |
| 19 class SafeBrowsingStoreFileTest : public PlatformTest { | 19 class SafeBrowsingStoreFileTest : public PlatformTest { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 37 store_->Delete(); | 37 store_->Delete(); |
| 38 store_.reset(); | 38 store_.reset(); |
| 39 | 39 |
| 40 PlatformTest::TearDown(); | 40 PlatformTest::TearDown(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void OnCorruptionDetected() { | 43 void OnCorruptionDetected() { |
| 44 corruption_detected_ = true; | 44 corruption_detected_ = true; |
| 45 } | 45 } |
| 46 | 46 |
| 47 ScopedTempDir temp_dir_; | 47 base::ScopedTempDir temp_dir_; |
| 48 FilePath filename_; | 48 FilePath filename_; |
| 49 scoped_ptr<SafeBrowsingStoreFile> store_; | 49 scoped_ptr<SafeBrowsingStoreFile> store_; |
| 50 bool corruption_detected_; | 50 bool corruption_detected_; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 TEST_STORE(SafeBrowsingStoreFileTest, store_.get(), filename_); | 53 TEST_STORE(SafeBrowsingStoreFileTest, store_.get(), filename_); |
| 54 | 54 |
| 55 // Test that Delete() deletes the temporary store, if present. | 55 // Test that Delete() deletes the temporary store, if present. |
| 56 TEST_F(SafeBrowsingStoreFileTest, DeleteTemp) { | 56 TEST_F(SafeBrowsingStoreFileTest, DeleteTemp) { |
| 57 const FilePath temp_file = | 57 const FilePath temp_file = |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 EXPECT_GE(fputs("hello", file.get()), 0); | 187 EXPECT_GE(fputs("hello", file.get()), 0); |
| 188 } | 188 } |
| 189 ASSERT_TRUE(store_->BeginUpdate()); | 189 ASSERT_TRUE(store_->BeginUpdate()); |
| 190 EXPECT_FALSE(corruption_detected_); | 190 EXPECT_FALSE(corruption_detected_); |
| 191 EXPECT_FALSE(store_->CheckValidity()); | 191 EXPECT_FALSE(store_->CheckValidity()); |
| 192 EXPECT_TRUE(corruption_detected_); | 192 EXPECT_TRUE(corruption_detected_); |
| 193 EXPECT_TRUE(store_->CancelUpdate()); | 193 EXPECT_TRUE(store_->CancelUpdate()); |
| 194 } | 194 } |
| 195 | 195 |
| 196 } // namespace | 196 } // namespace |
| OLD | NEW |