| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1662 | 1662 |
| 1663 // A variant of SyncableDirectoryTest that uses a real sqlite database. | 1663 // A variant of SyncableDirectoryTest that uses a real sqlite database. |
| 1664 class OnDiskSyncableDirectoryTest : public SyncableDirectoryTest { | 1664 class OnDiskSyncableDirectoryTest : public SyncableDirectoryTest { |
| 1665 protected: | 1665 protected: |
| 1666 // SetUp() is called before each test case is run. | 1666 // SetUp() is called before each test case is run. |
| 1667 // The sqlite3 DB is deleted before each test is run. | 1667 // The sqlite3 DB is deleted before each test is run. |
| 1668 virtual void SetUp() { | 1668 virtual void SetUp() { |
| 1669 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 1669 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 1670 file_path_ = temp_dir_.path().Append( | 1670 file_path_ = temp_dir_.path().Append( |
| 1671 FILE_PATH_LITERAL("Test.sqlite3")); | 1671 FILE_PATH_LITERAL("Test.sqlite3")); |
| 1672 base::Delete(file_path_, true); | 1672 base::DeleteFile(file_path_, true); |
| 1673 CreateDirectory(); | 1673 CreateDirectory(); |
| 1674 } | 1674 } |
| 1675 | 1675 |
| 1676 virtual void TearDown() { | 1676 virtual void TearDown() { |
| 1677 // This also closes file handles. | 1677 // This also closes file handles. |
| 1678 dir_->SaveChanges(); | 1678 dir_->SaveChanges(); |
| 1679 dir_.reset(); | 1679 dir_.reset(); |
| 1680 base::Delete(file_path_, true); | 1680 base::DeleteFile(file_path_, true); |
| 1681 } | 1681 } |
| 1682 | 1682 |
| 1683 // Creates a new directory. Deletes the old directory, if it exists. | 1683 // Creates a new directory. Deletes the old directory, if it exists. |
| 1684 void CreateDirectory() { | 1684 void CreateDirectory() { |
| 1685 test_directory_ = | 1685 test_directory_ = |
| 1686 TestDirectory::Create(&encryptor_, &handler_, kName, file_path_); | 1686 TestDirectory::Create(&encryptor_, &handler_, kName, file_path_); |
| 1687 dir_.reset(test_directory_); | 1687 dir_.reset(test_directory_); |
| 1688 ASSERT_TRUE(dir_.get()); | 1688 ASSERT_TRUE(dir_.get()); |
| 1689 ASSERT_EQ(OPENED, dir_->Open(kName, &delegate_, | 1689 ASSERT_EQ(OPENED, dir_->Open(kName, &delegate_, |
| 1690 NullTransactionObserver())); | 1690 NullTransactionObserver())); |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2118 &handler_, | 2118 &handler_, |
| 2119 NULL, | 2119 NULL, |
| 2120 NULL, | 2120 NULL, |
| 2121 NULL); | 2121 NULL); |
| 2122 DirOpenResult result = | 2122 DirOpenResult result = |
| 2123 dir.Open("ScopeTest", &delegate_, NullTransactionObserver()); | 2123 dir.Open("ScopeTest", &delegate_, NullTransactionObserver()); |
| 2124 ASSERT_EQ(result, OPENED); | 2124 ASSERT_EQ(result, OPENED); |
| 2125 dir.Close(); | 2125 dir.Close(); |
| 2126 | 2126 |
| 2127 // Closing the directory should have released the backing database file. | 2127 // Closing the directory should have released the backing database file. |
| 2128 ASSERT_TRUE(base::Delete(path, true)); | 2128 ASSERT_TRUE(base::DeleteFile(path, true)); |
| 2129 } | 2129 } |
| 2130 | 2130 |
| 2131 class StressTransactionsDelegate : public base::PlatformThread::Delegate { | 2131 class StressTransactionsDelegate : public base::PlatformThread::Delegate { |
| 2132 public: | 2132 public: |
| 2133 StressTransactionsDelegate(Directory* dir, int thread_number) | 2133 StressTransactionsDelegate(Directory* dir, int thread_number) |
| 2134 : dir_(dir), | 2134 : dir_(dir), |
| 2135 thread_number_(thread_number) {} | 2135 thread_number_(thread_number) {} |
| 2136 | 2136 |
| 2137 private: | 2137 private: |
| 2138 Directory* const dir_; | 2138 Directory* const dir_; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2294 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); | 2294 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); |
| 2295 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); | 2295 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); |
| 2296 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); | 2296 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); |
| 2297 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); | 2297 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); |
| 2298 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); | 2298 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); |
| 2299 } | 2299 } |
| 2300 | 2300 |
| 2301 } // namespace | 2301 } // namespace |
| 2302 } // namespace syncable | 2302 } // namespace syncable |
| 2303 } // namespace syncer | 2303 } // namespace syncer |
| OLD | NEW |